@@ -24,6 +24,7 @@
#include "accessors.h"
#include "file-item.h"
#include "scrub.h"
+#include "raid-stripe-tree.h"
/*
* This is only the first step towards a full-features scrub. It reads all
@@ -2719,6 +2720,21 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
int ret;
u8 csum[BTRFS_CSUM_SIZE];
u32 blocksize;
+ struct btrfs_io_stripe stripe;
+ const bool stripe_update =
+ btrfs_need_stripe_tree_update(sctx->fs_info, map->type);
+
+ if (stripe_update) {
+ stripe.dev = src_dev;
+ ret = btrfs_get_raid_extent_offset(sctx->fs_info, logical,
+ (u64 *)&len,
+ map->type, mirror_num,
+ &stripe);
+ if (ret)
+ return ret;
+
+ src_physical = stripe.physical;
+ }
if (flags & BTRFS_EXTENT_FLAG_DATA) {
if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
@@ -2772,8 +2788,21 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
return ret;
len -= l;
logical += l;
- physical += l;
- src_physical += l;
+ if (stripe_update && len) {
+
+ ret = btrfs_get_raid_extent_offset(sctx->fs_info,
+ logical, (u64 *)&len,
+ map->type, mirror_num,
+ &stripe);
+ if (ret)
+ return ret;
+
+ src_physical = stripe.physical;
+ physical = stripe.physical;
+ } else {
+ physical += l;
+ src_physical += l;
+ }
}
return 0;
}
When scrubbing a filesystem which uses the raid-stripe-tree for logical to physical address translation, consult the RST to perform the address translation instead of relying on fixed block group offsets. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/btrfs/scrub.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)