Skip to contentSkip to conversation

Btrfs: remove unnecessary code of chunk_root assignment in btrfs_read_chunk_tree.

PATCH Zhao Lei 5 participants 15 messages Sep 5, 2016 – Sep 10, 2016 1 message not in the archive Btrfs file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Zhao Lei

author
#1 lore raw

Hi, Sean Fu

Quoted 9 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in btrfs_read_chunk_tree.

Quoted 5 lines

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Thanks
Zhaolei

Quoted 21 lines
---
 fs/btrfs/volumes.c | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/volumes.c +0 -3
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
 	int ret;
 	int slot;
 
-	root = root->fs_info->chunk_root;
-
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
--

2.6.2

#2 lore raw
Quoted 20 lines · Zhao Lei

Hi, Sean Fu

Quoted 9 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in btrfs_read_chunk_tree.

Quoted 5 lines

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Quoted 8 lines

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Thanks,
Qu

Quoted 34 lines

Thanks
Zhaolei

Quoted 19 lines
---
 fs/btrfs/volumes.c | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/volumes.c +0 -3
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
 	int ret;
 	int slot;
 
-	root = root->fs_info->chunk_root;
-
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
--
Quoted 2 lines

2.6.2

--
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

author
#3 lore raw

Hi, Qu Wenruo

Quoted 39 lines

From: Qu Wenruo [mailto:[email protected]]
Sent: Monday, September 05, 2016 3:57 PM
To: Zhao Lei <[email protected]>; 'Sean Fu' <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in btrfs_read_chunk_tree.

Quoted 9 lines · Zhao Lei

Hi, Sean Fu

Quoted 7 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment

in

Quoted 17 lines
Quoted 7 lines

btrfs_read_chunk_tree.

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

Quoted 6 lines
Quoted 2 lines

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Good idea.

Thanks
Zhaolei

Quoted 38 lines

Thanks,
Qu

Quoted 9 lines

Thanks
Zhaolei

Quoted 5 lines
---
 fs/btrfs/volumes.c | 2 --
 1 file changed, 2 deletions(-)
Quoted 5 lines

fs/btrfs/volumes.c int btrfs_read_chunk_tree(struct btrfs_root

Quoted 5 lines
fs/btrfs/volumes.c +0 -0
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root

*root)

Quoted 20 lines
Quoted 11 lines
fs/btrfs/volumes.c +0 -3
 	int ret;
 	int slot;
 
-	root = root->fs_info->chunk_root;
-
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
--

2.6.2

--
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

#4 lore raw
In reply to Qu Wenruo
Quoted 30 lines · Qu Wenruo
Quoted 27 lines · Zhao Lei

Hi, Sean Fu

Quoted 10 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in
btrfs_read_chunk_tree.

Quoted 5 lines

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

Quoted 5 lines
Quoted 2 lines

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

-Jeff

Quoted 44 lines

Thanks,
Qu

Quoted 34 lines

Thanks
Zhaolei

Quoted 21 lines
---
 fs/btrfs/volumes.c | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/volumes.c +0 -2
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
     int ret;
     int slot;
 
-    root = root->fs_info->chunk_root;
-
     path = btrfs_alloc_path();
     if (!path)
         return -ENOMEM;
Signature · 1 line
2.6.2
Signature · 3 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
Signature · 3 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
Signature · 2 lines
Jeff Mahoney
SUSE Labs
#5 lore raw
Quoted 31 lines · Jeff Mahoney
Quoted 30 lines · Qu Wenruo
Quoted 27 lines · Zhao Lei

Hi, Sean Fu

Quoted 10 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in
btrfs_read_chunk_tree.

Quoted 5 lines

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

-Jeff

Quoted 49 lines

-Jeff

Quoted 44 lines

Thanks,
Qu

Quoted 34 lines

Thanks
Zhaolei

Quoted 21 lines
---
 fs/btrfs/volumes.c | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/volumes.c +0 -2
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
     int ret;
     int slot;
 
-    root = root->fs_info->chunk_root;
-
     path = btrfs_alloc_path();
     if (!path)
         return -ENOMEM;
Signature · 1 line
2.6.2
Signature · 3 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
Signature · 3 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
Signature · 2 lines
Jeff Mahoney
SUSE Labs
#6 lore raw
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

#7 lore raw
Quoted 7 lines · David Sterba
Quoted 6 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Quoted 6 lines
Quoted 2 lines

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#8 lore raw
Quoted 11 lines · Jeff Mahoney
Quoted 10 lines · David Sterba
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Quoted 6 lines
Quoted 3 lines

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

Sorry for late reply.
Many thanks to all of you.

Quoted 7 lines

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#9 lore raw
In reply to Jeff Mahoney
Quoted 11 lines · Jeff Mahoney
Quoted 10 lines · David Sterba
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Quoted 7 lines
Quoted 3 lines

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

Hi Jeff, Could you please share your patch? Where can i get it? I wanna have a look at it.

Thanks

Quoted 6 lines

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#10 lore raw
Quoted 16 lines · Sean Fu
Quoted 15 lines · Jeff Mahoney
Quoted 13 lines · David Sterba
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Quoted 5 lines
Quoted 3 lines

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

Hi Jeff, Could you please share your patch? Where can i get it? I wanna have a look at it.

Sure, it's the whole series that starts with this commit:
commit 160ceedfd40085cfb1e08305917fcc24cefdad93

Author: Jeff Mahoney <[email protected]>
Date:   Wed Aug 31 23:55:33 2016 -0400

btrfs: add dynamic debug support

... I still need to do clean up some commits that need merging.

https://git.kernel.org/cgit/linux/kernel/git/jeffm/linux-btrfs.git/log/?h=btrfs-testing/kdave/misc-4.9/root-fsinfo-cleanup

-Jeff

Quoted 15 lines

Thanks

Quoted 6 lines

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs

--
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

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#11 lore raw
Quoted 25 lines · Jeff Mahoney
Quoted 16 lines · Sean Fu
Quoted 15 lines · Jeff Mahoney
Quoted 13 lines · David Sterba
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Quoted 5 lines
Quoted 3 lines

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

Hi Jeff, Could you please share your patch? Where can i get it? I wanna have a look at it.

Sure, it's the whole series that starts with this commit:
commit 160ceedfd40085cfb1e08305917fcc24cefdad93

Quoted 9 lines
Author: Jeff Mahoney <[email protected]>
Date:   Wed Aug 31 23:55:33 2016 -0400

btrfs: add dynamic debug support

... I still need to do clean up some commits that need merging.

https://git.kernel.org/cgit/linux/kernel/git/jeffm/linux-btrfs.git/log/?h=btrfs-testing/kdave/misc-4.9/root-fsinfo-cleanup

Nice work.
Thanks

Quoted 24 lines

-Jeff

Quoted 15 lines

Thanks

Quoted 6 lines

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs

--
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

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#12 lore raw
In reply to Jeff Mahoney
Quoted 25 lines · Jeff Mahoney
Quoted 16 lines · Sean Fu
Quoted 15 lines · Jeff Mahoney
Quoted 13 lines · David Sterba
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Quoted 5 lines
Quoted 3 lines

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

Hi Jeff, Could you please share your patch? Where can i get it? I wanna have a look at it.

Sure, it's the whole series that starts with this commit:
commit 160ceedfd40085cfb1e08305917fcc24cefdad93

Quoted 9 lines
Author: Jeff Mahoney <[email protected]>
Date:   Wed Aug 31 23:55:33 2016 -0400

btrfs: add dynamic debug support

... I still need to do clean up some commits that need merging.

https://git.kernel.org/cgit/linux/kernel/git/jeffm/linux-btrfs.git/log/?h=btrfs-testing/kdave/misc-4.9/root-fsinfo-cleanup

Nice work. Thanks for your explaination.
I have one more question about it.
Although the total text size of this function is not changed, using fs_info should need one more instruction to get chunk_root field of fs_info than using chunk_root directly.
Does it cause any performance impact?

Sean

Quoted 24 lines

-Jeff

Quoted 15 lines

Thanks

Quoted 6 lines

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs

--
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

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#13 lore raw
Quoted 33 lines · Sean Fu
Quoted 32 lines · Jeff Mahoney
Quoted 16 lines · Sean Fu
Quoted 15 lines · Jeff Mahoney
Quoted 13 lines · David Sterba
Quoted 8 lines · Jeff Mahoney
Quoted 5 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Weird. Exactly this was a part of my fs_info patchset. I guess I need to go back and check what else is missing.

Actually, most of this didn't land. Pretty much anything that's a root ->fs_info conversion is in there.

Only half of the patchset has been merged so far because it did not pass testing, so I bisected to some point. I was about to let you know once most of 4.9 patches are prepared so there are less merge conflicts.

Quoted 5 lines
Quoted 3 lines

Ok, thanks. I was going to start the rebase today but I'll hold off until you're set for 4.9.

Hi Jeff, Could you please share your patch? Where can i get it? I wanna have a look at it.

Sure, it's the whole series that starts with this commit:
commit 160ceedfd40085cfb1e08305917fcc24cefdad93

Author: Jeff Mahoney <[email protected]>
Date:   Wed Aug 31 23:55:33 2016 -0400

btrfs: add dynamic debug support

... I still need to do clean up some commits that need merging.

Quoted 8 lines
Quoted 2 lines

https://git.kernel.org/cgit/linux/kernel/git/jeffm/linux-btrfs.git/log/?h=btrfs-testing/kdave/misc-4.9/root-fsinfo-cleanup

Nice work. Thanks for your explaination.
I have one more question about it.
Although the total text size of this function is not changed, using fs_info should need one more instruction to get chunk_root field of fs_info than using chunk_root directly.
Does it cause any performance impact?

I doubt it. The caller had to do the dereference before.

-Jeff

Quoted 29 lines

Sean

Quoted 24 lines

-Jeff

Quoted 15 lines

Thanks

Quoted 6 lines

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs

--
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

Signature · 2 lines
Jeff Mahoney
SUSE Labs
Signature · 2 lines
Jeff Mahoney
SUSE Labs
#14 lore raw
In reply to Qu Wenruo
Quoted 29 lines · Qu Wenruo
Quoted 26 lines · Zhao Lei

Hi, Sean Fu

Quoted 9 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in btrfs_read_chunk_tree.

Quoted 5 lines

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

Quoted 5 lines
Quoted 2 lines

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Sorry for late reply.
chunk_root is processed in btrfs_read_chunk_tree. Why should we pass fs_info directly to btrfs_read_chunk_tree? Could you give me more detail?

Many thanks

Quoted 40 lines

Thanks,
Qu

Quoted 34 lines

Thanks
Zhaolei

Quoted 19 lines

---
fs/btrfs/volumes.c | 2 --

1 file changed, 2 deletions(-)
fs/btrfs/volumes.c +0 -3
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
 	int ret;
 	int slot;
 
-	root = root->fs_info->chunk_root;
-
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
--
Quoted 2 lines

2.6.2

--
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

#15 lore raw
Quoted 33 lines · Sean Fu
Quoted 32 lines · Qu Wenruo
Quoted 28 lines · Zhao Lei

Hi, Sean Fu

Quoted 9 lines

From: Sean Fu [mailto:[email protected]]
Sent: Sunday, September 04, 2016 7:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sean Fu <[email protected]>
Subject: [PATCH] Btrfs: remove unnecessary code of chunk_root assignment in btrfs_read_chunk_tree.

Quoted 5 lines

The input argument root is already set with "fs_info->chunk_root". "chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info)" in caller "open_ctree".
“root->fs_info = fs_info” in "btrfs_alloc_root".

The root argument of this function means "any root". And the function is designed getting chunk root from "any root" in head.

Since there is only one caller of this function, and the caller always send chunk_root as root argument in current code, we can remove above conversion,
and I suggest renaming root to chunk_root to make it clear, something like:

- btrfs_read_chunk_tree(struct btrfs_root *root)
+ btrfs_read_chunk_tree(struct btrfs_root *chunk_root)

Quoted 8 lines
Quoted 2 lines

Since root is only used to get fs_info->chunk_root, why not use fs_info directly?

Sorry for late reply.
chunk_root is processed in btrfs_read_chunk_tree. Why should we pass fs_info directly to btrfs_read_chunk_tree? Could you give me more detail?

Many thanks

Normally we should only pass btrfs_root as parameter if it's a file/log/relocation tree which can't be grabbed directly from fs_info.

For system wide trees, which are already in fs_info, like fs_info->extent_root/chunk_root/..., we should pass fs_info.

Which is much much safer than passing a btrfs_root. Careless caller can pass wrong tree and cause undefined behavior.

And such behavior makes caller more aware of what they really want to do. Cases like just to grab sectorsize/nodesize shouldn't need a full btrfs_root. (Jeff's patchset has already done such things quite well)

Thanks,
Qu

Quoted 46 lines
Quoted 40 lines

Thanks,
Qu

Quoted 34 lines

Thanks
Zhaolei

Quoted 19 lines

---
fs/btrfs/volumes.c | 2 --

1 file changed, 2 deletions(-)
fs/btrfs/volumes.c +0 -3
index 366b335..384a6d2 100644
@@ -6600,8 +6600,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
 	int ret;
 	int slot;
 
-	root = root->fs_info->chunk_root;
-
 	path = btrfs_alloc_path();
 	if (!path)
 		return -ENOMEM;
--
Quoted 2 lines

2.6.2

--
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

--
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