All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: check: Fix wrong root parameter of btrfs_next_leaf call
@ 2018-06-18 11:10 Nikolay Borisov
  2018-06-19  1:23 ` Su Yue
  2018-07-02 22:19 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Borisov @ 2018-06-18 11:10 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

The first thing that check_chunks_and_extents does is to iterate all
the root items in the root tree and link them to either the "normal_list"
or "dropping_trees" list. If a leaf has to be crossed during this
operation btrfs_next_leaf is called to do that. However, currently it's
called with a wrong argument for its 'root' parameter. Since we are
iterating the root tree the passed root should be fs_info->tree_rot,
whereas right now we are passing the local variable 'root' which is
assigned to the fs_tree. As it stands, this bug is actually benign since
the passed root is only passed to reada_for_search, where it's used to
reference the fs_info. Nevertheless the code is wrong and at the very least
misleading, so fix it by passing the correct root.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check/main.c b/check/main.c
index 68da994f7ae0..a4d6855dccbf 100644
--- a/check/main.c
+++ b/check/main.c
@@ -8157,7 +8157,7 @@ static int check_chunks_and_extents(struct btrfs_fs_info *fs_info)
 		leaf = path.nodes[0];
 		slot = path.slots[0];
 		if (slot >= btrfs_header_nritems(path.nodes[0])) {
-			ret = btrfs_next_leaf(root, &path);
+			ret = btrfs_next_leaf(fs_info->tree_root, &path);
 			if (ret != 0)
 				break;
 			leaf = path.nodes[0];
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs-progs: check: Fix wrong root parameter of btrfs_next_leaf call
  2018-06-18 11:10 [PATCH] btrfs-progs: check: Fix wrong root parameter of btrfs_next_leaf call Nikolay Borisov
@ 2018-06-19  1:23 ` Su Yue
  2018-07-02 22:19 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Su Yue @ 2018-06-19  1:23 UTC (permalink / raw)
  To: Nikolay Borisov, linux-btrfs



On 06/18/2018 07:10 PM, Nikolay Borisov wrote:
> The first thing that check_chunks_and_extents does is to iterate all
> the root items in the root tree and link them to either the "normal_list"
> or "dropping_trees" list. If a leaf has to be crossed during this
> operation btrfs_next_leaf is called to do that. However, currently it's
> called with a wrong argument for its 'root' parameter. Since we are
> iterating the root tree the passed root should be fs_info->tree_rot,
> whereas right now we are passing the local variable 'root' which is
> assigned to the fs_tree. As it stands, this bug is actually benign since
> the passed root is only passed to reada_for_search, where it's used to
> reference the fs_info. Nevertheless the code is wrong and at the very least
> misleading, so fix it by passing the correct root.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>

> ---
>   check/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/check/main.c b/check/main.c
> index 68da994f7ae0..a4d6855dccbf 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -8157,7 +8157,7 @@ static int check_chunks_and_extents(struct btrfs_fs_info *fs_info)
>   		leaf = path.nodes[0];
>   		slot = path.slots[0];
>   		if (slot >= btrfs_header_nritems(path.nodes[0])) {
> -			ret = btrfs_next_leaf(root, &path);
> +			ret = btrfs_next_leaf(fs_info->tree_root, &path);
>   			if (ret != 0)
>   				break;
>   			leaf = path.nodes[0];
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs-progs: check: Fix wrong root parameter of btrfs_next_leaf call
  2018-06-18 11:10 [PATCH] btrfs-progs: check: Fix wrong root parameter of btrfs_next_leaf call Nikolay Borisov
  2018-06-19  1:23 ` Su Yue
@ 2018-07-02 22:19 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2018-07-02 22:19 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Mon, Jun 18, 2018 at 02:10:39PM +0300, Nikolay Borisov wrote:
> The first thing that check_chunks_and_extents does is to iterate all
> the root items in the root tree and link them to either the "normal_list"
> or "dropping_trees" list. If a leaf has to be crossed during this
> operation btrfs_next_leaf is called to do that. However, currently it's
> called with a wrong argument for its 'root' parameter. Since we are
> iterating the root tree the passed root should be fs_info->tree_rot,
> whereas right now we are passing the local variable 'root' which is
> assigned to the fs_tree. As it stands, this bug is actually benign since
> the passed root is only passed to reada_for_search, where it's used to
> reference the fs_info. Nevertheless the code is wrong and at the very least
> misleading, so fix it by passing the correct root.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-02 22:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 11:10 [PATCH] btrfs-progs: check: Fix wrong root parameter of btrfs_next_leaf call Nikolay Borisov
2018-06-19  1:23 ` Su Yue
2018-07-02 22:19 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.