Skip to contentSkip to conversation

btrfs: Don't generate UUID for non-fs tree

PATCH In review Qu Wenruo 3 participants 6 messages Oct 31, 2017 – Jan 5, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: Don't generate UUID for non-fs tree

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.

---
 fs/btrfs/disk-io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +3 -2
index dfdab849037b..d85e04a675fe 100644
@@ -1403,7 +1403,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	struct btrfs_root *root;
 	struct btrfs_key key;
 	int ret = 0;
-	uuid_le uuid;
+	uuid_le uuid = { 0 };
 
 	root = btrfs_alloc_root(fs_info, GFP_KERNEL);
 	if (!root)
@@ -1444,7 +1444,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	btrfs_set_root_used(&root->root_item, leaf->len);
 	btrfs_set_root_last_snapshot(&root->root_item, 0);
 	btrfs_set_root_dirid(&root->root_item, 0);
-	uuid_le_gen(&uuid);
+	if (is_fstree(objectid))
+		uuid_le_gen(&uuid);
 	memcpy(root->root_item.uuid, uuid.b, BTRFS_UUID_SIZE);
 	root->root_item.drop_level = 0;
 
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Qu Wenruo

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.

Quoted 8 lines

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.

Can you please point me to the report?

Quoted 1 line
#2 lore raw
Quoted 9 lines · David Sterba
Quoted 8 lines · Qu Wenruo

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.

Quoted 6 lines
Quoted 4 lines

Leave the UUID as zero for non-fs tree, making btrfs-debug-tree output less confusing.

Can you please point me to the report?

Here it is:

https://marc.info/?l=linux-btrfs&m=150941856508074&w=2

Thanks,
Qu

Quoted 9 lines
Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Qu Wenruo
Quoted 22 lines · Qu Wenruo

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.

---
 fs/btrfs/disk-io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +0 -0
index dfdab849037b..d85e04a675fe 100644

fs/btrfs/disk-io.c struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, · line 1406

Quoted 5 lines
fs/btrfs/disk-io.c +1 -1
@@ -1403,7 +1403,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	struct btrfs_root *root;
 	struct btrfs_key key;
 	int ret = 0;
-	uuid_le uuid;
+	uuid_le uuid = { 0 };

I get a warning with gcc 4.8.5

fs/btrfs/disk-io.c:1236:2: warning: missing braces around initializer [-Wmissing-braces]

but no warning with gcc 7.2.1 (built as 'make ccflags-y=-Wmissing-braces and checking that the option is really there). I think we should use NULL_UUID_LE.

#4 lore raw
Quoted 31 lines · David Sterba
Quoted 22 lines · Qu Wenruo

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.

---
 fs/btrfs/disk-io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +0 -0
index dfdab849037b..d85e04a675fe 100644

fs/btrfs/disk-io.c struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, · line 1406

Quoted 5 lines
fs/btrfs/disk-io.c +1 -1
@@ -1403,7 +1403,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	struct btrfs_root *root;
 	struct btrfs_key key;
 	int ret = 0;
-	uuid_le uuid;
+	uuid_le uuid = { 0 };

I get a warning with gcc 4.8.5

Quoted 5 lines

fs/btrfs/disk-io.c:1236:2: warning: missing braces around initializer [-Wmissing-braces]

but no warning with gcc 7.2.1 (built as 'make ccflags-y=-Wmissing-braces and checking that the option is really there). I think we should use NULL_UUID_LE.

Do I need to resend the whole patch or a new delta patch?

Thanks,
Qu

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 5 lines · Qu Wenruo
Quoted 5 lines

fs/btrfs/disk-io.c struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, · line 1406

Quoted 2 lines
fs/btrfs/disk-io.c +1 -1
-	uuid_le uuid;
+	uuid_le uuid = { 0 };

I get a warning with gcc 4.8.5

Quoted 7 lines
Quoted 5 lines

fs/btrfs/disk-io.c:1236:2: warning: missing braces around initializer [-Wmissing-braces]

but no warning with gcc 7.2.1 (built as 'make ccflags-y=-Wmissing-braces and checking that the option is really there). I think we should use NULL_UUID_LE.

Do I need to resend the whole patch or a new delta patch?

Not needed, I've fixed in the patch,

uuid_le = NULL_UUID_LE;