if (sctx->is_dev_replace) {
/*
* For dev-replace, if we know there is something wrong with
- * metadata, we should immediately abort.
+ * metadata, we should immediately abort. Count every
+ * uncorrectable sector of the batch first, those of an
+ * aborting batch included.
*/
for (int i = 0; i < nr_stripes; i++) {
- if (unlikely(stripe_has_metadata_error(&sctx->stripes[i]))) {
+ unsigned long has_extent;
+ unsigned long error;
+
+ stripe = &sctx->stripes[i];
+ has_extent = scrub_bitmap_read_has_extent(stripe);
+ error = scrub_bitmap_read_error(stripe);
+ bitmap_and(&error, &error, &has_extent, stripe->nr_sectors);
+ if (!bitmap_empty(&error, stripe->nr_sectors))
+ atomic64_add(bitmap_weight(&error, stripe->nr_sectors),
+ &fs_info->dev_replace.num_uncorrectable_read_errors);
+ if (unlikely(stripe_has_metadata_error(stripe)))
ret = -EIO;
- goto out;
- }
}
+ if (ret)
+ goto out;
for (int i = 0; i < nr_stripes; i++) {
unsigned long good;
unsigned long has_extent;
has_extent = scrub_bitmap_read_has_extent(stripe);
error = scrub_bitmap_read_error(stripe);
+ bitmap_and(&error, &error, &has_extent, stripe->nr_sectors);
bitmap_andnot(&good, &has_extent, &error, stripe->nr_sectors);
scrub_write_sectors(sctx, stripe, good, true);
}