Minor UUID cleanup
cover Minor UUID cleanup
Here is a short series that removes one indirect call in btrfs_uuid_tree_iterate and making uuid rescan functions private to disk-io.c since they are used only during mount.
Nikolay Borisov (3):
btrfs: Call btrfs_check_uuid_tree_entry directly in
btrfs_uuid_tree_iterate
btrfs: export btrfs_uuid_scan_kthread
btrfs: Make btrfs_check_uuid_tree private to disk-io.c
fs/btrfs/ctree.h | 4 +-- fs/btrfs/disk-io.c | 35 +++++++++++++++++++ fs/btrfs/uuid-tree.c | 50 ++++++++++++++++++++++++--- fs/btrfs/volumes.c | 82 +------------------------------------------- fs/btrfs/volumes.h | 2 +- 5 files changed, 84 insertions(+), 89 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 btrfs: Call btrfs_check_uuid_tree_entry directly in btrfs_uuid_tree_iterate
btrfs_uuid_tree_iterate is called from only once place and its 2nd argument is always btrfs_check_uuid_tree_entry. Simplify btrfs_uuid_tree_iterate's signature by removing its 2nd argument and directly calling btrfs_check_uuid_tree_entry. Also move the latter into uuid-tree.h. No functional changes.
--- fs/btrfs/ctree.h | 4 +--- fs/btrfs/uuid-tree.c | 50 ++++++++++++++++++++++++++++++++++++++++---- fs/btrfs/volumes.c | 47 +---------------------------------------- 3 files changed, 48 insertions(+), 53 deletions(-)
fs/btrfs/ctree.h +1 -3
@@ -2738,9 +2738,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type, u64 subid);int btrfs_uuid_tree_remove (struct btrfs_trans_handle *trans,u8 *uuid,u8 type,u64 subid); -int btrfs_uuid_tree_iterate (struct btrfs_fs_info *fs_info, -int (*check_func)(struct btrfs_fs_info *,u8 *,u8 , -u64 )); +int btrfs_uuid_tree_iterate (struct btrfs_fs_info *fs_info);/* dir-item.c */ int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
fs/btrfs/uuid-tree.c +46 -4
63 lines not on this page · raw message
fs/btrfs/volumes.c +1 -46
59 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 1/3] btrfs: Call btrfs_check_uuid_tree_entry directly in btrfs_uuid_tree_iterate
Looks good,
Re: [PATCH 1/3] btrfs: Call btrfs_check_uuid_tree_entry directly in btrfs_uuid_tree_iterate
In reply to Nikolay BorisovQuoted 5 lines · Nikolay Borisov
btrfs_uuid_tree_iterateis called from only once place and its 2nd argument is alwaysbtrfs_check_uuid_tree_entry. Simplify btrfs_uuid_tree_iterate's signature by removing its 2nd argument and directly callingbtrfs_check_uuid_tree_entry. Also move the latter intouuid-tree.h. No functional changes.
You forgot your signed-off-by
Thanks,
Josef
PATCH 2/3 btrfs: export btrfs_uuid_scan_kthread
In reply to Nikolay BorisovThis is preparation for the next patch that will move the rescan uuid kthread into disk-io.c. No functional changes.
--- fs/btrfs/volumes.c | 2 +- fs/btrfs/volumes.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
@@ -4274,7 +4274,7 @@ int btrfs_cancel_balance(struct btrfs_fs_info *fs_info)return 0 ; } -static int btrfs_uuid_scan_kthread (void *data) +int btrfs_uuid_scan_kthread (void *data) {struct btrfs_fs_info *fs_info = data;struct btrfs_root *root = fs_info->tree_root;
fs/btrfs/volumes.h +1 -0
@@ -462,6 +462,7 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info);int btrfs_cancel_balance (struct btrfs_fs_info *fs_info);int btrfs_create_uuid_tree (struct btrfs_fs_info *fs_info);int btrfs_check_uuid_tree (struct btrfs_fs_info *fs_info); +int btrfs_uuid_scan_kthread (void *data);int btrfs_chunk_readonly (struct btrfs_fs_info *fs_info,u64 chunk_offset);int find_free_dev_extent (struct btrfs_device *device,u64 num_bytes,u64 *start,u64 *max_avail);
Signature · 1 line
2.17.1
Re: [PATCH 2/3] btrfs: export btrfs_uuid_scan_kthread
I'd squash this into the next patch
PATCH 3/3 btrfs: Make btrfs_check_uuid_tree private to disk-io.c
In reply to Nikolay BorisovIt's used only during fs mount as such it can be made private to disk-io.c file. Also use the occassion to move btrfs_uuid_rescan_kthread as btrfs_check_uuid_tree is its sole caller. No functional changes.
--- fs/btrfs/disk-io.c | 35 +++++++++++++++++++++++++++++++++++ fs/btrfs/volumes.c | 35 ----------------------------------- fs/btrfs/volumes.h | 1 - 3 files changed, 35 insertions(+), 36 deletions(-)
fs/btrfs/disk-io.c +35 -0
@@ -2836,6 +2836,41 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_blockreturn ret; } +static int btrfs_uuid_rescan_kthread (void *data) +{ +struct btrfs_fs_info *fs_info = (struct btrfs_fs_info *)data; +int ret; + +/* +* 1st step is to iterate through the existing UUID tree and +* to delete all entries that contain outdated data. +* 2nd step is to add all missing entries to the UUID tree. +*/ + ret =btrfs_uuid_tree_iterate (fs_info); +if (ret <0 ) { +btrfs_warn (fs_info,"iterating uuid_tree failed %d" , ret); +up (&fs_info->uuid_tree_rescan_sem); +return ret; + } +return btrfs_uuid_scan_kthread (data); +} + +static int btrfs_check_uuid_tree (struct btrfs_fs_info *fs_info) +{ +struct task_struct *task; + +down (&fs_info->uuid_tree_rescan_sem); + task =kthread_run (btrfs_uuid_rescan_kthread, fs_info,"btrfs-uuid" ); +if (IS_ERR (task)) { +/* fs_info->update_uuid_tree_gen remains 0 in all error case */ +btrfs_warn (fs_info,"failed to start uuid_rescan task" ); +up (&fs_info->uuid_tree_rescan_sem); +return PTR_ERR (task); + } + +return 0 ; +} +int __cold open_ctree (struct super_block *sb,struct btrfs_fs_devices *fs_devices,char *options) {
fs/btrfs/volumes.c +0 -35
@@ -4403,25 +4403,6 @@ int btrfs_uuid_scan_kthread(void *data)return 0 ; } -static int btrfs_uuid_rescan_kthread (void *data) -{ -struct btrfs_fs_info *fs_info = (struct btrfs_fs_info *)data; -int ret; - -/* -* 1st step is to iterate through the existing UUID tree and -* to delete all entries that contain outdated data. -* 2nd step is to add all missing entries to the UUID tree. -*/ - ret =btrfs_uuid_tree_iterate (fs_info); -if (ret <0 ) { -btrfs_warn (fs_info,"iterating uuid_tree failed %d" , ret); -up (&fs_info->uuid_tree_rescan_sem); -return ret; - } -return btrfs_uuid_scan_kthread (data); -} -int btrfs_create_uuid_tree (struct btrfs_fs_info *fs_info) {struct btrfs_trans_handle *trans;
@@ -4464,22 +4445,6 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)return 0 ; } -int btrfs_check_uuid_tree (struct btrfs_fs_info *fs_info) -{ -struct task_struct *task; - -down (&fs_info->uuid_tree_rescan_sem); - task =kthread_run (btrfs_uuid_rescan_kthread, fs_info,"btrfs-uuid" ); -if (IS_ERR (task)) { -/* fs_info->update_uuid_tree_gen remains 0 in all error case */ -btrfs_warn (fs_info,"failed to start uuid_rescan task" ); -up (&fs_info->uuid_tree_rescan_sem); -return PTR_ERR (task); - } - -return 0 ; -} -/* * shrinking a device means finding all of the device extents past * the new size, and then following the back refs to the chunks.
fs/btrfs/volumes.h +0 -1
@@ -461,7 +461,6 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info);int btrfs_pause_balance (struct btrfs_fs_info *fs_info);int btrfs_cancel_balance (struct btrfs_fs_info *fs_info);int btrfs_create_uuid_tree (struct btrfs_fs_info *fs_info); -int btrfs_check_uuid_tree (struct btrfs_fs_info *fs_info);int btrfs_uuid_scan_kthread (void *data);int btrfs_chunk_readonly (struct btrfs_fs_info *fs_info,u64 chunk_offset); int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
Signature · 1 line
2.17.1
Re: [PATCH 3/3] btrfs: Make btrfs_check_uuid_tree private to disk-io.c
Quoted 4 lines · Nikolay Borisov
It's used only during fs mount as such it can be made private to
disk-io.cfile. Also use the occassion to movebtrfs_uuid_rescan_kthreadasbtrfs_check_uuid_treeis its sole caller. No functional changes.
---
Forgot your signed-off-by here as well. And it's "occasion".
Thanks,
Josef
Quoted 9 lines · Nikolay Borisov
Here is a short series that removes one indirect call in
btrfs_uuid_tree_iterateand making uuid rescan functions private todisk-io.csince they are used only during mount.Nikolay Borisov (3):
btrfs: Callbtrfs_check_uuid_tree_entrydirectly in
btrfs_uuid_tree_iterate
btrfs: exportbtrfs_uuid_scan_kthread
btrfs: Makebtrfs_check_uuid_treeprivate todisk-io.c
With the fixups applied, added to misc-next. Thanks.