@@ -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
@@ -2821,6 +2822,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)
@@ -2872,8 +2888,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;
}