All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status
@ 2016-09-07  2:54 Qu Wenruo
  2016-09-29 17:19 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2016-09-07  2:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Mark Fasheh

Commit 93dabf211d74daf6e3de642bdd887a90a00f7b49
Author: Mark Fasheh <mfasheh@suse.de>
Date:   Fri Jun 17 13:37:48 2016 -0700

    btrfs-progs: check: verify qgroups above level 0

This commit introduced a new regression which corrupts
read_qgroup_status, since it iterate leaf with manually specified slot,
not correct path->slot[0].

This leads to wrong slot[0] and read_qgroup_status() will read out wrong
flags, leading to regression.

Fix read_qgroup_status() by using eb and slot instread of wrong path
strucutre.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 qgroup-verify.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/qgroup-verify.c b/qgroup-verify.c
index 66eb870..f6df12d 100644
--- a/qgroup-verify.c
+++ b/qgroup-verify.c
@@ -874,15 +874,14 @@ static int add_qgroup_relation(u64 memberid, u64 parentid)
 	return 0;
 }
 
-static void read_qgroup_status(struct btrfs_path *path,
+static void read_qgroup_status(struct extent_buffer *eb, int slot,
 			      struct counts_tree *counts)
 {
 	struct btrfs_qgroup_status_item *status_item;
 	u64 flags;
 
-	status_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
-				     struct btrfs_qgroup_status_item);
-	flags = btrfs_qgroup_status_flags(path->nodes[0], status_item);
+	status_item = btrfs_item_ptr(eb, slot, struct btrfs_qgroup_status_item);
+	flags = btrfs_qgroup_status_flags(eb, status_item);
 	/*
 	 * Since qgroup_inconsist/rescan_running is just one bit,
 	 * assign value directly won't work.
@@ -946,7 +945,7 @@ loop:
 			}
 
 			if (key.type == BTRFS_QGROUP_STATUS_KEY) {
-				read_qgroup_status(&path, &counts);
+				read_qgroup_status(leaf, i, &counts);
 				continue;
 			}
 
-- 
2.9.3




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

* Re: [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status
  2016-09-07  2:54 [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status Qu Wenruo
@ 2016-09-29 17:19 ` David Sterba
  2016-09-30  0:44   ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2016-09-29 17:19 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs, Mark Fasheh

On Wed, Sep 07, 2016 at 10:54:19AM +0800, Qu Wenruo wrote:
> Commit 93dabf211d74daf6e3de642bdd887a90a00f7b49
> Author: Mark Fasheh <mfasheh@suse.de>
> Date:   Fri Jun 17 13:37:48 2016 -0700
> 
>     btrfs-progs: check: verify qgroups above level 0
> 
> This commit introduced a new regression which corrupts
> read_qgroup_status, since it iterate leaf with manually specified slot,
> not correct path->slot[0].
> 
> This leads to wrong slot[0] and read_qgroup_status() will read out wrong
> flags, leading to regression.
> 
> Fix read_qgroup_status() by using eb and slot instread of wrong path
> strucutre.
> 
> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> Cc: Mark Fasheh <mfasheh@suse.de>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>

I'm adding this patch to devel.  Do you have a test for the regression please?

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

* Re: [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status
  2016-09-29 17:19 ` David Sterba
@ 2016-09-30  0:44   ` Qu Wenruo
  2016-09-30  9:53     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2016-09-30  0:44 UTC (permalink / raw)
  To: dsterba, linux-btrfs, Mark Fasheh



At 09/30/2016 01:19 AM, David Sterba wrote:
> On Wed, Sep 07, 2016 at 10:54:19AM +0800, Qu Wenruo wrote:
>> Commit 93dabf211d74daf6e3de642bdd887a90a00f7b49
>> Author: Mark Fasheh <mfasheh@suse.de>
>> Date:   Fri Jun 17 13:37:48 2016 -0700
>>
>>     btrfs-progs: check: verify qgroups above level 0
>>
>> This commit introduced a new regression which corrupts
>> read_qgroup_status, since it iterate leaf with manually specified slot,
>> not correct path->slot[0].
>>
>> This leads to wrong slot[0] and read_qgroup_status() will read out wrong
>> flags, leading to regression.
>>
>> Fix read_qgroup_status() by using eb and slot instread of wrong path
>> strucutre.
>>
>> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
>> Cc: Mark Fasheh <mfasheh@suse.de>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
>
> I'm adding this patch to devel.  Do you have a test for the regression please?
>
>
Xfstests btrfs/114 can produce it.

If you mean to add btrfs-progs test case, then I can try to create a 
minimal image to reproduce it.

Thanks,
Qu



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

* Re: [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status
  2016-09-30  0:44   ` Qu Wenruo
@ 2016-09-30  9:53     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2016-09-30  9:53 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs, Mark Fasheh

On Fri, Sep 30, 2016 at 08:44:58AM +0800, Qu Wenruo wrote:
> 
> 
> At 09/30/2016 01:19 AM, David Sterba wrote:
> > On Wed, Sep 07, 2016 at 10:54:19AM +0800, Qu Wenruo wrote:
> >> Commit 93dabf211d74daf6e3de642bdd887a90a00f7b49
> >> Author: Mark Fasheh <mfasheh@suse.de>
> >> Date:   Fri Jun 17 13:37:48 2016 -0700
> >>
> >>     btrfs-progs: check: verify qgroups above level 0
> >>
> >> This commit introduced a new regression which corrupts
> >> read_qgroup_status, since it iterate leaf with manually specified slot,
> >> not correct path->slot[0].
> >>
> >> This leads to wrong slot[0] and read_qgroup_status() will read out wrong
> >> flags, leading to regression.
> >>
> >> Fix read_qgroup_status() by using eb and slot instread of wrong path
> >> strucutre.
> >>
> >> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> >> Cc: Mark Fasheh <mfasheh@suse.de>
> >> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> >
> > I'm adding this patch to devel.  Do you have a test for the regression please?
> >
> >
> Xfstests btrfs/114 can produce it.

Good.

> If you mean to add btrfs-progs test case, then I can try to create a 
> minimal image to reproduce it.

Yes please.

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

end of thread, other threads:[~2016-09-30  9:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07  2:54 [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status Qu Wenruo
2016-09-29 17:19 ` David Sterba
2016-09-30  0:44   ` Qu Wenruo
2016-09-30  9:53     ` 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.