btrfstune fs_info cleanups
cover btrfstune fs_info cleanups
While inspecting btrfstune source code I came across 2 functions which needlessly take fs_info argument. This small series rectifies this. No functional changes.
Nikolay Borisov (2):
btrfstune: Remove fs_info arg from change_device_uuid
btrfstune: Rename change_header_uuid to change_buffer_header_uuid
btrfstune.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 btrfstune: Remove fs_info arg from change_device_uuid
This function already takes an extent buffer that contains a reference to the fs_info. Use that and reduce argument count. No functional changes.
--- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
btrfstune.c +3 -3
@@ -179,10 +179,10 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info)return ret; } -static int change_device_uuid (struct btrfs_fs_info *fs_info,struct extent_buffer *eb, -int slot) +static int change_device_uuid (struct extent_buffer *eb,int slot) {struct btrfs_dev_item *di; +struct btrfs_fs_info *fs_info = eb->fs_info;int ret =0 ; di = btrfs_item_ptr(eb, slot, struct btrfs_dev_item);
@@ -217,7 +217,7 @@ static int change_devices_uuid(struct btrfs_fs_info *fs_info)if (key.type !=BTRFS_DEV_ITEM_KEY || key.objectid !=BTRFS_DEV_ITEMS_OBJECTID ) goto next; - ret =change_device_uuid (fs_info, path.nodes[0 ], path.slots[0 ]); + ret =change_device_uuid (path.nodes[0 ], path.slots[0 ]);if (ret <0 ) goto out; next:
Signature · 1 line
2.7.4
PATCH 2/2 btrfstune: Rename change_header_uuid to change_buffer_header_uuid
In reply to Nikolay BorisovRename the function so its name falls in line with the rest of btrfs nomenclature. So when we change the uuid of the header it's in fact of the buffer header. Also remove the root argument since it's used solely to take a reference to fs_info which can be done via the mandatory eb argument. No functional changes.
--- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
btrfstune.c +3 -3
@@ -91,9 +91,9 @@ static int set_super_incompat_flags(struct btrfs_root *root, u64 flags)return ret; } -static int change_header_uuid (struct btrfs_root *root,struct extent_buffer *eb) +static int change_buffer_header_uuid (struct extent_buffer *eb) { -struct btrfs_fs_info *fs_info = root->fs_info; +struct btrfs_fs_info *fs_info = eb->fs_info;int same_fsid =1 ;int same_chunk_tree_uuid =1 ;int ret;
@@ -157,7 +157,7 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) ret =PTR_ERR (eb); goto out; } - ret =change_header_uuid (root, eb); + ret =change_buffer_header_uuid (eb);free_extent_buffer (eb);if (ret <0 ) { error("failed to change uuid of tree block: %llu",
Signature · 1 line
2.7.4
Re: [PATCH 1/2] btrfstune: Remove fs_info arg from change_device_uuid
In reply to Nikolay BorisovQuoted 5 lines · Nikolay Borisov
This function already takes an extent buffer that contains a reference to the
fs_info. Use that and reduce argument count. No functional changes.Signed-off-by Nikolay Borisov <[email protected]>
Thanks,
Qu
Quoted 31 lines
--- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)btrfstune.c +3
-3@@ -179,10 +179,10 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info)return ret; } -static int change_device_uuid (struct btrfs_fs_info *fs_info,struct extent_buffer *eb, -int slot) +static int change_device_uuid (struct extent_buffer *eb,int slot) {struct btrfs_dev_item *di; +struct btrfs_fs_info *fs_info = eb->fs_info;int ret =0 ; di = btrfs_item_ptr(eb, slot, struct btrfs_dev_item);@@ -217,7 +217,7 @@ static int change_devices_uuid(struct btrfs_fs_info *fs_info)if (key.type !=BTRFS_DEV_ITEM_KEY || key.objectid !=BTRFS_DEV_ITEMS_OBJECTID ) goto next; - ret =change_device_uuid (fs_info, path.nodes[0 ], path.slots[0 ]); + ret =change_device_uuid (path.nodes[0 ], path.slots[0 ]);if (ret <0 ) goto out; next:
Re: [PATCH 2/2] btrfstune: Rename change_header_uuid to change_buffer_header_uuid
In reply to Nikolay BorisovQuoted 3 lines · Nikolay Borisov
Rename the function so its name falls in line with the rest of btrfs nomenclature. So when we change the uuid of the header it's in fact of the buffer header.
We have setget functions like btrfs_header_nritems() or btrfs_header_bytenr(), IMHO both ways make sense.
Although I have no objection against current modification.
Quoted 4 lines
Also remove the root argument since it's used
solely to take a reference tofs_infowhich can be done via the mandatory eb argument. No functional changes.>Signed-off-by Nikolay Borisov <[email protected]>
Thanks,
Qu
Quoted 30 lines
--- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)btrfstune.c +3
-3@@ -91,9 +91,9 @@ static int set_super_incompat_flags(struct btrfs_root *root, u64 flags)return ret; } -static int change_header_uuid (struct btrfs_root *root,struct extent_buffer *eb) +static int change_buffer_header_uuid (struct extent_buffer *eb) { -struct btrfs_fs_info *fs_info = root->fs_info; +struct btrfs_fs_info *fs_info = eb->fs_info;int same_fsid =1 ;int same_chunk_tree_uuid =1 ;int ret;@@ -157,7 +157,7 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) ret =PTR_ERR (eb); goto out; } - ret =change_header_uuid (root, eb); + ret =change_buffer_header_uuid (eb);free_extent_buffer (eb);if (ret <0 ) { error("failed to change uuid of tree block: %llu",
Re: [PATCH 2/2] btrfstune: Rename change_header_uuid to change_buffer_header_uuid
Quoted 9 lines · Qu Wenruo
Quoted 3 lines · Nikolay Borisov
Rename the function so its name falls in line with the rest of btrfs nomenclature. So when we change the uuid of the header it's in fact of the buffer header.
We have setget functions like
btrfs_header_nritems()orbtrfs_header_bytenr(), IMHO both ways make sense.
Yes, however, we don't really have such functions for the two fields. Alternatively they could be introduced and will consist of only :write_extent_buffer() calls and the cheks for same_fsid/same_chunk_tree_uuid will still be retained in change_buffer_header_uuid.
Quoted 44 lines
Although I have no objection against current modification.
Quoted 4 lines
Also remove the root argument since it's used
solely to take a reference tofs_infowhich can be done via the mandatory eb argument. No functional changes.>Signed-off-by Nikolay Borisov <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 30 lines
--- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)btrfstune.c +3
-3@@ -91,9 +91,9 @@ static int set_super_incompat_flags(struct btrfs_root *root, u64 flags)return ret; } -static int change_header_uuid (struct btrfs_root *root,struct extent_buffer *eb) +static int change_buffer_header_uuid (struct extent_buffer *eb) { -struct btrfs_fs_info *fs_info = root->fs_info; +struct btrfs_fs_info *fs_info = eb->fs_info;int same_fsid =1 ;int same_chunk_tree_uuid =1 ;int ret;@@ -157,7 +157,7 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) ret =PTR_ERR (eb); goto out; } - ret =change_header_uuid (root, eb); + ret =change_buffer_header_uuid (eb);free_extent_buffer (eb);if (ret <0 ) { error("failed to change uuid of tree block: %llu",
David Sterba
AppliedQuoted 6 lines · Nikolay Borisov
While inspecting btrfstune source code I came across 2 functions which needlessly take
fs_infoargument. This small series rectifies this. No functional changes.Nikolay Borisov (2):
btrfstune: Removefs_infoarg fromchange_device_uuid
btrfstune: Renamechange_header_uuidtochange_buffer_header_uuid
Applied, thanks.