diff options
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index c3a98931980f..19781e924443 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -1256,19 +1256,16 @@ out: | |||
1256 | 1256 | ||
1257 | static inline int scrub_nr_raid_mirrors(struct btrfs_bio *bbio) | 1257 | static inline int scrub_nr_raid_mirrors(struct btrfs_bio *bbio) |
1258 | { | 1258 | { |
1259 | if (bbio->raid_map) { | 1259 | if (bbio->map_type & BTRFS_BLOCK_GROUP_RAID5) |
1260 | int real_stripes = bbio->num_stripes - bbio->num_tgtdevs; | 1260 | return 2; |
1261 | 1261 | else if (bbio->map_type & BTRFS_BLOCK_GROUP_RAID6) | |
1262 | if (bbio->raid_map[real_stripes - 1] == RAID6_Q_STRIPE) | 1262 | return 3; |
1263 | return 3; | 1263 | else |
1264 | else | ||
1265 | return 2; | ||
1266 | } else { | ||
1267 | return (int)bbio->num_stripes; | 1264 | return (int)bbio->num_stripes; |
1268 | } | ||
1269 | } | 1265 | } |
1270 | 1266 | ||
1271 | static inline void scrub_stripe_index_and_offset(u64 logical, u64 *raid_map, | 1267 | static inline void scrub_stripe_index_and_offset(u64 logical, u64 map_type, |
1268 | u64 *raid_map, | ||
1272 | u64 mapped_length, | 1269 | u64 mapped_length, |
1273 | int nstripes, int mirror, | 1270 | int nstripes, int mirror, |
1274 | int *stripe_index, | 1271 | int *stripe_index, |
@@ -1276,7 +1273,7 @@ static inline void scrub_stripe_index_and_offset(u64 logical, u64 *raid_map, | |||
1276 | { | 1273 | { |
1277 | int i; | 1274 | int i; |
1278 | 1275 | ||
1279 | if (raid_map) { | 1276 | if (map_type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) { |
1280 | /* RAID5/6 */ | 1277 | /* RAID5/6 */ |
1281 | for (i = 0; i < nstripes; i++) { | 1278 | for (i = 0; i < nstripes; i++) { |
1282 | if (raid_map[i] == RAID6_Q_STRIPE || | 1279 | if (raid_map[i] == RAID6_Q_STRIPE || |
@@ -1350,6 +1347,7 @@ static int scrub_setup_recheck_block(struct scrub_block *original_sblock, | |||
1350 | BUG_ON(page_index >= SCRUB_PAGES_PER_RD_BIO); | 1347 | BUG_ON(page_index >= SCRUB_PAGES_PER_RD_BIO); |
1351 | 1348 | ||
1352 | nmirrors = min(scrub_nr_raid_mirrors(bbio), BTRFS_MAX_MIRRORS); | 1349 | nmirrors = min(scrub_nr_raid_mirrors(bbio), BTRFS_MAX_MIRRORS); |
1350 | |||
1353 | for (mirror_index = 0; mirror_index < nmirrors; | 1351 | for (mirror_index = 0; mirror_index < nmirrors; |
1354 | mirror_index++) { | 1352 | mirror_index++) { |
1355 | struct scrub_block *sblock; | 1353 | struct scrub_block *sblock; |
@@ -1370,7 +1368,9 @@ leave_nomem: | |||
1370 | sblock->pagev[page_index] = page; | 1368 | sblock->pagev[page_index] = page; |
1371 | page->logical = logical; | 1369 | page->logical = logical; |
1372 | 1370 | ||
1373 | scrub_stripe_index_and_offset(logical, bbio->raid_map, | 1371 | scrub_stripe_index_and_offset(logical, |
1372 | bbio->map_type, | ||
1373 | bbio->raid_map, | ||
1374 | mapped_length, | 1374 | mapped_length, |
1375 | bbio->num_stripes - | 1375 | bbio->num_stripes - |
1376 | bbio->num_tgtdevs, | 1376 | bbio->num_tgtdevs, |
@@ -1419,7 +1419,9 @@ static void scrub_bio_wait_endio(struct bio *bio, int error) | |||
1419 | 1419 | ||
1420 | static inline int scrub_is_page_on_raid56(struct scrub_page *page) | 1420 | static inline int scrub_is_page_on_raid56(struct scrub_page *page) |
1421 | { | 1421 | { |
1422 | return page->recover && page->recover->bbio->raid_map; | 1422 | return page->recover && |
1423 | (page->recover->bbio->map_type & (BTRFS_BLOCK_GROUP_RAID5 | | ||
1424 | BTRFS_BLOCK_GROUP_RAID6)); | ||
1423 | } | 1425 | } |
1424 | 1426 | ||
1425 | static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info, | 1427 | static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info, |