aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]>
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> [ minor whitespace fixes ] Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]>
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 <[email protected]>
2018-01-22btrfs: sink get_extent parameter to __extent_readpagesDavid Sterba1-7/+8
All callers pass btrfs_get_extent. Signed-off-by: David Sterba <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
2018-01-22btrfs: sink get_extent parameter to extent_writepagesDavid Sterba3-4/+2
There's only one caller. Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Su Yue <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
2018-01-22btrfs: simplify btrfs_close_bdevDavid Sterba1-3/+5
Split the conditions a bit. Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: document device lockingDavid Sterba1-0/+65
Overview of the main locks protecting various device-related structures. Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: simplify exit paths in btrfs_init_new_deviceDavid Sterba1-4/+3
Reviewed-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: use free_device where opencodedDavid Sterba1-28/+11
Reviewed-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22Btrfs: add __init macro to btrfs init functionsLiu Bo8-11/+11
Adding __init macro gives kernel a hint that this function is only used during the initialization phase and its memory resources can be freed up after. Signed-off-by: Liu Bo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: rename btrfs_add_device to btrfs_add_dev_itemAnand Jain1-2/+2
Function btrfs_add_device() is adding the device item so rename to reflect that in the function. Similarly we have btrfs_rm_dev_item(). Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Don't generate UUID for non-fs treeQu Wenruo1-2/+3
btrfs_create_tree() will unconditionally generate UUID for any root. So for quota tree and data reloc tree created by kernel, they will have unique UUIDs. However UUID in root item is only referred by UUID tree, which only records UUID for fs trees. This makes unique UUIDs for quota/data reloc tree meaningless. Leave the UUID as zero for non-fs tree, making btrfs-debug-tree output less confusing. Reported-by: Misono Tomohiro <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: move volume_mutex into the btrfs_rm_device()Anand Jain2-4/+2
A cleanup patch no functional change, we hold volume_mutex before calling btrfs_rm_device, so move it into the function itself. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Use locked_end rather than open coding itNikolay Borisov1-2/+2
Right before we go into this loop locked_end is set to alloc_end - 1 and is being used in nearby functions, no need to have exceptions. This just makes the code consistent, no functional changes. Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Move loop termination condition in while()Nikolay Borisov1-3/+1
Fallocating a file in btrfs goes through several stages. The one before actually inserting the fallocated extents is to create a qgroup reservation, covering the desired range. To this end there is a loop in btrfs_fallocate which checks to see if there are holes in the fallocated range or !PREALLOC extents past EOF and if so create qgroup reservations for them. Unfortunately, the main condition of the loop is burried right at the end of its body rather than in the actual while statement which makes it non-obvious. Fix this by moving the condition in the while statement where it belongs. No functional changes. Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22Btrfs: remove rcu_barrier in btrfs_close_devicesLiu Bo1-6/+0
It was introduced because btrfs used to do blkdev_put in a deferred work, now that btrfs has blkdev_put in place, this rcu_barrier can be removed. modprobe -r btrfs will do btrfs_cleanup_fs_uuids(), where it cleanup every %fs_devices on the list, but when we do btrfs_close_devices(), we have replaced the devices on the list with dummy ones which only have the same name and uuid, so modprobe -r btrfs will free those instead of what we were using, this change won't cause a problem for it. Signed-off-by: Liu Bo <[email protected]> Reviewed-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> [ copied 2nd paragraph from mailinglist discussion ] Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Move checks from btrfs_wq_run_delayed_node to btrfs_balance_delayed_itemsNikolay Borisov1-5/+2
btrfs_balance_delayed_items is the sole caller of btrfs_wq_run_delayed_node and already includes one of the checks whether the delayed inodes should be run. On the other hand btrfs_wq_run_delayed_node duplicates that check and performs an additional one for wq congestion. Let's remove the duplicate check and move the congestion one in btrfs_balance_delayed_items, leaving btrfs_wq_run_delayed_node to only care about setting up the wq run. No functional changes. Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Make btrfs_async_run_delayed_root use a loop rather than multiple labelsNikolay Borisov1-25/+27
Currently btrfs_async_run_delayed_root's implementation uses 3 goto labels to mimic the functionality of a simple do {} while loop. Refactor the function to use a do {} while construct, making intention clear and code easier to follow. No functional changes. Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Remove redundant mirror_num argNikolay Borisov1-9/+7
The following callpath is always invoked with mirror_num set to 0, so let's remove it as an argument and directly pass 0 to __do_redpage. No functional change. extent_readpages __extent_readpages __do_contiguous_readpages __do_readpage Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
2018-01-22btrfs: Remove unused functionNikolay Borisov1-5/+0
It's sole callsite was removed in a previous patch so just nuke it for good. Signed-off-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]>