summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-01-22btrfs: cleanup device states define BTRFS_DEV_STATE_MISSINGAnand Jain6-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>
2018-01-22btrfs: cleanup device states define BTRFS_DEV_STATE_IN_FS_METADATAAnand Jain5-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>
2018-01-22btrfs: cleanup device states define BTRFS_DEV_STATE_WRITEABLEAnand Jain7-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>
2018-01-22btrfs: add helper for device path or missingAnand Jain1-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>
2018-01-22btrfs: drop btrfs_device::can_discard to query directlyAnand Jain3-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>
2018-01-22btrfs: make function update_share_count staticColin Ian King1-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>
2018-01-22btrfs: Remove redundant FLAG_VACANCYNikolay Borisov5-11/+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>
2018-01-22btrfs: extent-tree: Make btrfs_inode_rsv_refill function staticQu Wenruo1-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>
2018-01-22btrfs: move some zstd work data from stack to workspaceDavid Sterba1-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>
2018-01-22btrfs: reorder btrfs_transaction members for better packingDavid Sterba1-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>
2018-01-22btrfs: use narrower type for btrfs_transaction::num_dirty_bgsDavid Sterba2-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>
2018-01-22btrfs: reorder btrfs_trans_handle members for better packingDavid Sterba1-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>
2018-01-22btrfs: switch to refcount_t type for btrfs_trans_handle::use_countDavid Sterba2-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>
2018-01-22btrfs: remove unused member of btrfs_trans_handleDavid Sterba1-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>
2018-01-22btrfs: switch btrfs_trans_handle::adding_csums to boolDavid Sterba2-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>
2018-01-22btrfs: remove dead code from btrfs_get_extentEdmund Nadolski1-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>
2018-01-22btrfs: btrfs_inode_log_parent should use defined inode_only values.Edmund Nadolski1-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>
2018-01-22btrfs: switch to on-stack csum buffer in csum_tree_blockDavid Sterba1-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>
2018-01-22Btrfs: set plug for fsyncLiu Bo1-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>
2018-01-22btrfs: factor __btrfs_open_devices() to create btrfs_open_one_device()Anand Jain1-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>
2018-01-22btrfs: move check for device generation to the lastAnand Jain1-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>
2018-01-22btrfs: set fs_devices->seed directlyAnand Jain1-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>
2018-01-22btrfs: ref-verify: Remove unused parameter from walk_up_tree() to kill warningGeert Uytterhoeven1-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>
2018-01-22btrfs: sink get_extent parameter to read_extent_buffer_pagesDavid Sterba4-8/+11
All callers pass btree_get_extent, which needs to be exported. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to __do_contiguous_readpagesDavid Sterba1-6/+4
All callers pass btrfs_get_extent. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to __extent_readpagesDavid Sterba1-7/+8
All callers pass btrfs_get_extent. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to extent_readpagesDavid Sterba3-10/+7
There's only one caller that passes btrfs_get_extent. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to get_extent_skip_holesDavid Sterba1-8/+5
All callers pass btrfs_get_extent_fiemap and get_extent_skip_holes itself is used only as a fiemap helper. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to extent_fiemapDavid Sterba3-5/+5
All callers pass btrfs_get_extent_fiemap and we don't expect anything else in the context of extent_fiemap. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: drop get_extent from extent_page_dataDavid Sterba1-6/+1
Previous patches cleaned up all places where extent_page_data::get_extent was set and it was btrfs_get_extent all the time, so we can simply call that instead. This also reduces size of extent_page_data by 8 bytes which has positive effect on stack consumption on various functions on the write out path. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to extent_write_full_pageDavid Sterba3-4/+2
There's only one caller. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to extent_write_locked_rangeDavid Sterba3-6/+3
There's only one caller. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink get_extent parameter to extent_writepagesDavid Sterba3-4/+2
There's only one caller. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: Cleanup existing name_len checksQu Wenruo9-186/+9
Since tree-checker has verified leaf when reading from disk, we don't need the existing verify_dir_item() or btrfs_is_name_len_valid() checks. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: tree-checker: Add checker for dir itemQu Wenruo1-0/+141
Add checker for dir item, for key types DIR_ITEM, DIR_INDEX and XATTR_ITEM. This checker does comprehensive checks for: 1) dir_item header and its data size Against item boundary and maximum name/xattr length. This part is mostly the same as old verify_dir_item(). 2) dir_type Against maximum file types, and against key type. Since XATTR key should only have FT_XATTR dir item, and normal dir item type should not have XATTR key. The check between key->type and dir_type is newly introduced by this patch. 3) name hash For XATTR and DIR_ITEM key, key->offset is name hash (crc32c). Check the hash of the name against the key to ensure it's correct. The name hash check is only found in btrfs-progs before this patch. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: use GFP_KERNEL in btrfs_alloc_inodeDavid Sterba1-1/+1
This callback is called directly from VFS, no locks are held at the allocation time. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink gfp parameter to clear_extent_uptodateDavid Sterba2-3/+3
There's only one callsite with GFP_NOFS. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: sink gfp parameter to clear_extent_bitDavid Sterba9-42/+30
All callers use GFP_NOFS, we don't have to pass it as an argument. The built-in tests pass GFP_KERNEL, but they run only at module load time and NOFS works there as well. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: prepare to drop gfp mask parameter from clear_extent_bitDavid Sterba2-7/+11
Use __clear_extent_bit directly in case we want to pass unknown gfp flags. Otherwise all clear_extent_bit callers use GFP_NOFS, so we can sink them to the function and reduce argument count, at the cost that __clear_extent_bit has to be exported. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: use non-RCU list traversal in write_all_supers calleesDavid Sterba1-4/+5
We take the fs_devices::device_list_mutex mutex in write_all_supers which will prevent any add/del changes to the device list. Therefore we don't need to use the RCU variant list_for_each_entry_rcu in any of the called functions. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: switch to RCU for device traversal in btrfs_ioctl_fs_infoDavid Sterba1-4/+4
We don't need to use the mutex as we do not modify the devices nor the list itself and just read information about device counts. Move copying fsid out of the protected section, not applicable to RCU same as the rest of the retrieved information. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: switch to RCU for device traversal in btrfs_ioctl_dev_infoDavid Sterba1-5/+2
We don't need to use the mutex as we do not modify the devices nor the list itself and just read some information: does not change during device lifetime: - devid - uuid - name (ie. the path) may change in parallel to the ioctl call, but can lead only to reporting inacurracy: - bytes_used - total_bytes Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: simplify btrfs_close_bdevDavid Sterba1-3/+5
Split the conditions a bit. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: document device lockingDavid Sterba1-0/+65
Overview of the main locks protecting various device-related structures. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: simplify exit paths in btrfs_init_new_deviceDavid Sterba1-4/+3
Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: use free_device where opencodedDavid Sterba1-28/+11
Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: introduce free_device helperDavid Sterba1-2/+14
A helper to free a device and all it's dynamically allocated members, like the rcu_string name or flush_bio. This is going to replace all open coded places. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: rename device free rcu helper to free_device_rcuDavid Sterba1-5/+5
Make it clear that it is an RCU helper, we want to use the name free_device for a wrapper freeing all device members. Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22Btrfs: document rules about bio async submitLiu Bo1-1/+16
These rules have been hidden in several if-else and are not straightforward to follow, for example, dio submit hook's nocsum case has a bug , i.e. doing async submit instead of sync submit, which has been fixed recently. This is documenting the rules for reference. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-22btrfs: Reduce scope of delayed_rsv->lock in may_commit_transNikolay Borisov1-2/+2
After commit 996478ca9c460886ac1 ("btrfs: change how we decide to commit transactions during flushing") there is no need to hold the delayed_rsv during the percpu_counter_compare call since we get the byte's snapshot earlier. So hold the lock only while reading delayed_rsv. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>