aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-09-12 06:44:02 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:39:00 -0400
commit28e1cc7d1baf8038ae4ad4681c8f3dc94fcd7c00 (patch)
tree0d823d67ce5cb6eb1a12ab9aff5a49a7abde079d /fs/btrfs/volumes.c
parent1203b6813ee84add8b4baa6d75e50ba85517e99c (diff)
Btrfs: Set real mirror number for read operation on RAID0/5/6
We need real mirror number for RAID0/5/6 when reading data, or if read error happens, we would pass 0 as the number of the mirror on which the io error happens. It is wrong and would cause the filesystem read the data from the corrupted mirror again. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 77d7fbc0fa47..63e632746d8a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5073,6 +5073,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
5073 num_stripes = min_t(u64, map->num_stripes, 5073 num_stripes = min_t(u64, map->num_stripes,
5074 stripe_nr_end - stripe_nr_orig); 5074 stripe_nr_end - stripe_nr_orig);
5075 stripe_index = do_div(stripe_nr, map->num_stripes); 5075 stripe_index = do_div(stripe_nr, map->num_stripes);
5076 if (!(rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS)))
5077 mirror_num = 1;
5076 } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) { 5078 } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) {
5077 if (rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS)) 5079 if (rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS))
5078 num_stripes = map->num_stripes; 5080 num_stripes = map->num_stripes;
@@ -5176,6 +5178,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
5176 /* We distribute the parity blocks across stripes */ 5178 /* We distribute the parity blocks across stripes */
5177 tmp = stripe_nr + stripe_index; 5179 tmp = stripe_nr + stripe_index;
5178 stripe_index = do_div(tmp, map->num_stripes); 5180 stripe_index = do_div(tmp, map->num_stripes);
5181 if (!(rw & (REQ_WRITE | REQ_DISCARD |
5182 REQ_GET_READ_MIRRORS)) && mirror_num <= 1)
5183 mirror_num = 1;
5179 } 5184 }
5180 } else { 5185 } else {
5181 /* 5186 /*