Skip to contentSkip to conversation

btrfstune fs_info cleanups

PATCH Applied Nikolay Borisov 3 participants 7 messages Aug 20, 2018 – Oct 25, 2018 Btrfs file system

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 889b931c55d8..723317a00f3a 100644
@@ -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
#3 lore raw

PATCH 2/2 btrfstune: Rename change_header_uuid to change_buffer_header_uuid

In reply to 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. 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
index 723317a00f3a..3745a00c46ae 100644
@@ -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
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] btrfstune: Remove fs_info arg from change_device_uuid

In reply to Nikolay Borisov
Quoted 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.

Thanks,
Qu

Quoted 31 lines
---
 btrfstune.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
btrfstune.c +3 -3
index 889b931c55d8..723317a00f3a 100644
@@ -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:
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] btrfstune: Rename change_header_uuid to change_buffer_header_uuid

In reply to Nikolay Borisov
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() 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 to fs_info which can be done via the mandatory eb argument. No functional changes.>

Thanks,
Qu

Quoted 30 lines
---
 btrfstune.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
btrfstune.c +3 -3
index 723317a00f3a..3745a00c46ae 100644
@@ -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",
#5 lore raw

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() or btrfs_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 to fs_info which can be done via the mandatory eb argument. No functional changes.>

Thanks,
Qu

Quoted 30 lines
---
 btrfstune.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
btrfstune.c +3 -3
index 723317a00f3a..3745a00c46ae 100644
@@ -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",
Applied
#6 lore raw
In reply to Nikolay Borisov
Quoted 6 lines · Nikolay Borisov

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

Applied, thanks.