summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
Commit message (Collapse)AuthorAgeFilesLines
* btrfs: add btrfs_mount_root() and new file_system_typeMisono, Tomohiro2018-01-221-0/+123
| | | | | | | | | | | | Add btrfs_mount_root() and new file_system_type for preparation of cleanup of btrfs_mount(). Code path is not changed yet. btrfs_mount_root() is almost the same as current btrfs_mount(), but doesn't have subvolume related part. Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: unify extent_page_data type passed as voidDavid Sterba2018-01-221-10/+7
| | | | | | | | Functions called from extent_write_cache_pages used void* as generic callback data, but all of them convert it to extent_page_data, or use it directly. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: sink writepage parameter to extent_write_cache_pagesDavid Sterba2018-01-221-5/+4
| | | | | | | | | The function extent_write_cache_pages is modelled after write_cache_pages which is a generic interface and the writepage parameter makes sense there. In btrfs we know exactly which callback we're going to use, so we can pass it directly. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: sink flush_fn to extent_write_cache_pagesDavid Sterba2018-01-221-6/+4
| | | | | | All callers pass the same value flush_write_bio. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: merge two flush_write_bio helpersDavid Sterba2018-01-221-11/+8
| | | | | | | | flush_epd_write_bio is same as flush_write_bio, no point having two such functions. Merge them to flush_write_bio. The 'noinline' attribute is removed as it does not have any meaning. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: Rename bin_search -> btrfs_bin_searchNikolay Borisov2018-01-221-10/+4
| | | | | | | | | | | Currently there are 2 function doing binary search on btrfs nodes: bin_search and btrfs_bin_search. The latter being a simple wrapper for the former. So eliminate the wrapper and just rename bin_search to btrfs_bin_search. No functional changes Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: sink extent_write_full_page tree argumentNikolay Borisov2018-01-223-8/+4
| | | | | | | | | | The tree argument passed to extent_write_full_page is referenced from the page being passed to the same function. Since we already have enough information to get the reference, remove the function parameter. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: sink extent_write_locked_range tree parameterNikolay Borisov2018-01-223-6/+7
| | | | | | | | | | | This function is called only from submit_compressed_extents and the io tree being passed is always that of the inode. But we are also passing the inode, so just move getting the io tree pointer in extent_write_locked_range to simplify the signature. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: Remove pair of bio_get/put in btrfs_schedule_bioNikolay Borisov2018-01-221-2/+0
| | | | | | | | | | | | | This code was added in 492bb6deee34 ("Btrfs: Hold a reference on bios during submit_bio, add some extra bio checks"). However, holding a reference on a bio is necessary only if it's going to be referenced after the submit_bio returns and the bio is completed. In this particular instance this is not the case so there is no need to hold an extra reference since we directly return. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: Fix out of bounds access in btrfs_search_slotNikolay Borisov2018-01-221-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | When modifying a tree where the root is at BTRFS_MAX_LEVEL - 1 then the level variable is going to be 7 (this is the max height of the tree). On the other hand btrfs_cow_block is always called with "level + 1" as an index into the nodes and slots arrays. This leads to an out of bounds access. Admittdely this will be benign since an OOB access of the nodes array will likely read the 0th element from the slots array, which in this case is going to be 0 (since we start CoW at the top of the tree). The OOB access into the slots array in turn will read the 0th and 1st values of the locks array, which would both be 0 at the time. However, this benign behavior relies on the fact that the path being passed hasn't been initialised, if it has already been used to query a btree then it could potentially have populated the nodes/slots arrays. Fix it by explicitly checking if we are at level 7 (the maximum allowed index in nodes/slots arrays) and explicitly call the CoW routine with NULL for parent's node/slot. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Fixes-coverity-id: 711515 Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: remove duplicate includesPravin Shedge2018-01-221-1/+0
| | | | | | | | These duplicate includes have been found with scripts/checkincludes.pl but they have been removed manually to avoid removing false positives. Signed-off-by: Pravin Shedge <pravin.shedge4linux@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: Handle btrfs_set_extent_delalloc failure in fixup workerNikolay Borisov2018-01-221-2/+9
| | | | | | | | | | | | | | This function was introduced by 247e743cbe6e ("Btrfs: Use async helpers to deal with pages that have been improperly dirtied") and it didn't do any error handling then. This function might very well fail in ENOMEM situation, yet it's not handled, this could lead to inconsistent state. So let's handle the failure by setting the mapping error bit. Cc: stable@vger.kernel.org Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: show options: use helper to convert compression type stringDavid Sterba2018-01-221-7/+2
| | | | | | | Use the helper, if the COMPRESS option is set, the result is always defined and not empty. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: prop: use common helper for type to string conversionDavid Sterba2018-01-221-3/+3
| | | | | | Use the helper for conversion, keep the semantics. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: SETFLAGS ioctl: use helper for compression type conversionDavid Sterba2018-01-221-6/+4
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: compression: add helper for type to string conversionDavid Sterba2018-01-222-0/+17
| | | | | | | There are several places opencoding this conversion, add a helper now that we have 3 compression algorithms. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: remove redundant check in btrfs_get_extent_fiemapNikolay Borisov2018-01-221-1/+1
| | | | | | | | | | | Before returning hole_em in btrfs_get_fiemap_extent we check if it's different than null. However, by the time this null check is triggered we already know hole_em is not null because it means it points to the em we found and it has already been dereferenced. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: Remove unused variable in btrfs_get_extentNikolay Borisov2018-01-221-8/+1
| | | | | | | | | | | trans was statically assigned to NULL and this never changed over the course of btrfs_get_extent. So remove any code which checks whether trans != NULL and just hardcode the fact trans is always NULL. Resolves-coverity-id: 112806 Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: tree-checker: use %zu format string for size_tArnd Bergmann2018-01-221-1/+1
| | | | | | | | | | | | | | The return value of sizeof() is of type size_t, so we must print it using the %z format modifier rather than %l to avoid this warning on some architectures: fs/btrfs/tree-checker.c: In function 'check_dir_item': fs/btrfs/tree-checker.c:273:50: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Werror=format=] Fixes: 005887f2e3e0 ("btrfs: tree-checker: Add checker for dir item") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs: use struct completion in scrub_submit_raid56_bio_waitLiu Bo2018-01-221-17/+4
| | | | | | | | | | | | | This changes to use struct completion directly and removes 'struct scrub_bio_ret' along with the code using it. This struct is used to get the return value from bio, but the caller can access bio to get the return value directly and is holding a reference on it so it won't go away underneath us and can be removed safely. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs: remove unused variable wait in lock_stripe_addLiu Bo2018-01-221-1/+0
| | | | | | | | The defined wait is not used anywhere. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs: compress_file_range() change page dirty status onceTimofey Titovets2018-01-221-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to call extent_range_clear_dirty_for_io() on compression range to prevent application from changing page content, while pages compressing. extent_range_clear_dirty_for_io() runs on each loop iteration, "(end - start)" can be much (up to 1024 times) bigger then compression range (BTRFS_MAX_UNCOMPRESSED). The start pointer is advanced each time we manage to compress part of the range. The end pointer does not change so we could redirty the remaining parts repeatedly. Fix that behaviour by call extent_range_clear_dirty_for_io() only once, the first time it happens. This is the safest but probably not the best behaviour. Previous iterations of the patch tried to redirty only the range that we were not able to compress. This has been refused by David for safety reasons, the writeout callchain is complex and there could be some path that relies on redirtying the entire unwritten range. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> [ enhance changelog, the history and safety concerns, add comment ] Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs: compression heuristic: replace heap sort with radix sortTimofey Titovets2018-01-221-7/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Slowest part of heuristic for now is kernel heap sort() It's can take up to 55% of runtime on sorting bucket items. As sorting will always call on most data sets to get correctly byte_core_set_size, the only way to speed up heuristic, is to speed up sort on bucket. Add a general radix_sort function. Radix sort require 2 buffers, one full size of input array and one for store counters (jump addresses). That increase usage per heuristic workspace +1KiB 8KiB + 1KiB -> 8KiB + 2KiB That is LSD Radix, i use 4 bit as a base for calculating, to make counters array acceptable small (16 elements * 8 byte). That Radix sort implementation have several points to adjust, I added him to make radix sort general usable in kernel, like heap sort, if needed. Performance tested in userspace copy of heuristic code, throughput: - average <-> random data: ~3500 MiB/s - heap sort - average <-> random data: ~6000 MiB/s - radix sort Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> [ coding style fixes ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: cleanup device states define BTRFS_DEV_STATE_FLUSH_SENTAnand Jain2018-01-222-3/+4
| | | | | | | | | | Currently device state is being managed by each individual int variable such as struct btrfs_device::is_tgtdev_for_dev_replace. Instead of that declare btrfs_device::dev_state BTRFS_DEV_STATE_FLUSH_SENT and use the bit operations. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: cleanup device states define BTRFS_DEV_STATE_REPLACE_TGTAnand Jain2018-01-227-24/+31
| | | | | | | | | | | Currently device state is being managed by each individual int variable such as struct btrfs_device::is_tgtdev_for_dev_replace. Instead of that declare btrfs_device::dev_state BTRFS_DEV_STATE_MISSING and use the bit operations. Signed-off-by: Anand Jain <anand.jain@oracle.com> [ whitespace adjustments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: cleanup device states define BTRFS_DEV_STATE_MISSINGAnand Jain2018-01-226-21/+28
| | | | | | | | | | | | Currently device state is being managed by each individual int variable such as struct btrfs_device::missing. Instead of that declare btrfs_device::dev_state BTRFS_DEV_STATE_MISSING and use the bit operations. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by : Nikolay Borisov <nborisov@suse.com> [ whitespace adjustments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: cleanup device states define BTRFS_DEV_STATE_IN_FS_METADATAAnand Jain2018-01-225-20/+27
| | | | | | | | | | | | Currently device state is being managed by each individual int variable such as struct btrfs_device::in_fs_metadata. Instead of that declare device state BTRFS_DEV_STATE_IN_FS_METADATA and use the bit operations. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> [ whitespace adjustments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: cleanup device states define BTRFS_DEV_STATE_WRITEABLEAnand Jain2018-01-227-34/+49
| | | | | | | | | | | Currently device state is being managed by each individual int variable such as struct btrfs_device::writeable. Instead of that declare device state BTRFS_DEV_STATE_WRITEABLE and use the bit operations. Signed-off-by: Anand Jain <anand.jain@oracle.com> [ whitespace adjustments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: add helper for device path or missingAnand Jain2018-01-221-11/+14
| | | | | | | | | This patch creates a helper function to get either the rcu device path or missing. Signed-off-by: Anand Jain <anand.jain@oracle.com> [ rename to btrfs_dev_name, switch to if/else ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: drop btrfs_device::can_discard to query directlyAnand Jain2018-01-223-10/+4
| | | | | | | | | | We can query the bdev directly when needed at btrfs_discard_extent() so drop btrfs_device::can_discard. Signed-off-by: Anand Jain <anand.jain@oracle.com> Suggested-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: make function update_share_count staticColin Ian King2018-01-221-1/+2
| | | | | | | | | | | | | The function update_share_count is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: fs/btrfs/backref.c:219:6: warning: symbol 'update_share_count' was not declared. Should it be static? Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: Remove redundant FLAG_VACANCYNikolay Borisov2018-01-224-10/+1
| | | | | | | | | | | | | | Commit 9036c10208e1 ("Btrfs: update hole handling v2") added the FLAG_VACANCY to denote holes, however there was already a consistent way of flagging extents which represent hole - ->block_start = EXTENT_MAP_HOLE. And also the only place where this flag is checked is in the fiemap code, but the block_start value is also checked and every other place in the filesystem detects holes by using block_start value's. So remove the extra flag. This survived a full xfstest run. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: extent-tree: Make btrfs_inode_rsv_refill function staticQu Wenruo2018-01-221-2/+2
| | | | | | | | | This function is no longer used outside of extent-tree.c. Make it static. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: move some zstd work data from stack to workspaceDavid Sterba2018-01-221-65/+67
| | | | | | | | | | | | | | | | | * ZSTD_inBuffer in_buf * ZSTD_outBuffer out_buf are used in all functions to pass the compression parameters and the local variables consume some space. We can move them to the workspace and reduce the stack consumption: zstd.c:zstd_decompress -24 (136 -> 112) zstd.c:zstd_decompress_bio -24 (144 -> 120) zstd.c:zstd_compress_pages -24 (264 -> 240) Signed-off-by: David Sterba <dsterba@suse.com> Reviewed-by: Nick Terrell <terrelln@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: reorder btrfs_transaction members for better packingDavid Sterba2018-01-221-2/+2
| | | | | | | | | There are now 20 bytes of holes, we can reduce that to 4 by minor changes. Moving 'aborted' to the status and flags is also more logical, similar for num_dirty_bgs. The size goes from 432 to 416. Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: use narrower type for btrfs_transaction::num_dirty_bgsDavid Sterba2018-01-222-2/+2
| | | | | | | The u64 is an overkill here, we could not possibly create that many blockgroups in one transaction. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: reorder btrfs_trans_handle members for better packingDavid Sterba2018-01-221-2/+2
| | | | | | | Recent updates to the structure left some holes, reorder the types so the packing is tight. The size goes from 112 to 104 on 64bit. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: switch to refcount_t type for btrfs_trans_handle::use_countDavid Sterba2018-01-222-7/+7
| | | | | | | | | The use_count is a reference counter, we can use the refcount_t type, though we don't use the atomicity. This is not a performance critical code and we could catch the underflows. The type is changed from long, but the number of references will fit an int. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: remove unused member of btrfs_trans_handleDavid Sterba2018-01-221-1/+0
| | | | | | | | Last user was removed in a monster commit a22285a6a32390195235171 ("Btrfs: Integrate metadata reservation with start_transaction") in 2010. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: switch btrfs_trans_handle::adding_csums to boolDavid Sterba2018-01-222-3/+3
| | | | | | | | The semantics of adding_csums matches bool, 'short' was most likely used to save space in a698d0755adb6f2 ("Btrfs: add a type field for the transaction handle"). Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: remove dead code from btrfs_get_extentEdmund Nadolski2018-01-221-21/+1
| | | | | | | | | Due to new_inline logic, the create == 0 is always true at this point in the code, so the create != 0 branch can be removed. Signed-off-by: Edmund Nadolski <enadolski@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: btrfs_inode_log_parent should use defined inode_only values.Edmund Nadolski2018-01-221-4/+3
| | | | | | | | | Replace hardcoded numeric argument values for inode_only with the constants defined for that use. Signed-off-by: Edmund Nadolski <enadolski@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: switch to on-stack csum buffer in csum_tree_blockDavid Sterba2018-01-221-13/+3
| | | | | | | | The maximum size of a checksum buffer is known, BTRFS_CSUM_SIZE, and we don't have to allocate it dynamically. This code path is not used at all as we have only the crc32c and use an on-stack buffer already. Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs: set plug for fsyncLiu Bo2018-01-221-0/+9
| | | | | | | | | | | | | | | | | Setting plug can merge adjacent IOs before dispatching IOs to the disk driver. Without plug, it'd not be a problem for single disk usecases, but for multiple disks using raid profile, a large IO can be split to several IOs of stripe length, and plug can be helpful to bring them together for each disk so that we can save several disk access. Moreover, fsync issues synchronous writes, so plug can really take effect. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: factor __btrfs_open_devices() to create btrfs_open_one_device()Anand Jain2018-01-221-56/+65
| | | | | | | | | | No functional changes, create btrfs_open_one_device() from __btrfs_open_devices(). This is a preparatory work to add dynamic device scan. Signed-off-by: Anand Jain <anand.jain@oracle.com> [ minor whitespace fixes ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: move check for device generation to the lastAnand Jain2018-01-221-3/+5
| | | | | | | | No functional changes. This helps to move the entire section into a new function. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: set fs_devices->seed directlyAnand Jain2018-01-221-3/+1
| | | | | | | | | | This is in preparation to move a section of code in __btrfs_open_devices() into a new function so that it can be reused. As we set seeding if any of the device is having SB flag BTRFS_SUPER_FLAG_SEEDING, so do it in the device list loop itself. No functional changes. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: ref-verify: Remove unused parameter from walk_up_tree() to kill warningGeert Uytterhoeven2018-01-221-4/+2
| | | | | | | | | | | | | | | | With gcc-4.1.2: fs/btrfs/ref-verify.c: In function ‘btrfs_build_ref_tree’: fs/btrfs/ref-verify.c:1017: warning: ‘root’ is used uninitialized in this function The variable is indeed passed uninitialized, but it is never used by the callee. However, not all versions of gcc are smart enough to notice. Hence remove the unused parameter from walk_up_tree() to silence the compiler warning. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: sink get_extent parameter to read_extent_buffer_pagesDavid Sterba2018-01-224-8/+11
| | | | | | All callers pass btree_get_extent, which needs to be exported. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs: sink get_extent parameter to __do_contiguous_readpagesDavid Sterba2018-01-221-6/+4
| | | | | | All callers pass btrfs_get_extent. Signed-off-by: David Sterba <dsterba@suse.com>
OpenPOWER on IntegriCloud