linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: Fix a bug in __btrfs_map_block() always maps wrong stripe for DUP/RAID1
@ 2015-05-11  0:45 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
  0 siblings, 2 replies; 4+ messages in thread
From: Qu Wenruo @ 2015-05-11  0:45 UTC (permalink / raw)
  To: linux-btrfs

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:
 		if (rw == WRITE)
 			multi->num_stripes = map->num_stripes;
 		else if (mirror_num)
-			stripe_index = mirror_num - 1;
+			stripe_index = mirror_num;
 		else
 			stripe_index = stripe_nr % map->num_stripes;
 	} else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
@@ -1416,7 +1416,7 @@ again:
 		if (rw == WRITE)
 			multi->num_stripes = map->num_stripes;
 		else if (mirror_num)
-			stripe_index = mirror_num - 1;
+			stripe_index = mirror_num;
 	} else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
 				BTRFS_BLOCK_GROUP_RAID6)) {
 
-- 
2.4.0


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

end of thread, other threads:[~2015-05-22  2:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).