From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <dsterba@suse.cz>, <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 1/2] btrfs-progs: Fix a bug in __btrfs_map_block() always maps wrong stripe for DUP/RAID1
Date: Fri, 22 May 2015 10:53:00 +0800 [thread overview]
Message-ID: <555E9A0C.3030205@cn.fujitsu.com> (raw)
In-Reply-To: <20150521160655.GZ23255@twin.jikos.cz>
-------- Original Message --------
Subject: Re: [PATCH 1/2] btrfs-progs: Fix a bug in __btrfs_map_block()
always maps wrong stripe for DUP/RAID1
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2015年05月22日 00:06
> On Mon, May 11, 2015 at 08:45:47AM +0800, Qu Wenruo wrote:
>> In __btrfs_map_block(), stripe_index is always wrong if mirror_num is
>> given.
>>
>> For DUP/RAID1 case, if mirror_num is given, e.g. 1, it should return the
>> second stripe.
>> But codes consider the mirror_num is start from 1 and always minus 1,
>> causing even mirror number is given as 1, __btrfs_map_block() will still
>> map the first stripe not the second.
>>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
>> ---
>> volumes.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/volumes.c b/volumes.c
>> index 16dbf64..c66c02a 100644
>> --- a/volumes.c
>> +++ b/volumes.c
>> @@ -1397,7 +1397,7 @@ again:
>> - stripe_index = mirror_num - 1;
>> + stripe_index = mirror_num;
>> @@ -1416,7 +1416,7 @@ again:
>> - stripe_index = mirror_num - 1;
>> + stripe_index = mirror_num;
>
> The original code is same in kernel, is the logic different in the
> userspace code? If yes I don't see it.
>
It seems that I was confused about mirror_num of btrfs_map_block function.
When mirror mirror_num 0, it will map all stripes and if larger than 0,
it will map the <mirror_num>th stripe.
So when mirror_num is given 1, it should return the first stripe.
And it's the correct behavior.
If I am wrong again, please correct me.
Please ignore the patch.
Thanks,
Qu
prev parent reply other threads:[~2015-05-22 2:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-11 0:45 [PATCH 1/2] btrfs-progs: Fix a bug in __btrfs_map_block() always maps wrong stripe for DUP/RAID1 Qu Wenruo
2015-05-11 0:45 ` [PATCH 2/2] btrfs-progs: Cleanup logic of btrfs_read_tree_block() Qu Wenruo
2015-05-21 16:06 ` [PATCH 1/2] btrfs-progs: Fix a bug in __btrfs_map_block() always maps wrong stripe for DUP/RAID1 David Sterba
2015-05-22 2:53 ` Qu Wenruo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555E9A0C.3030205@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).