]> git.hungrycats.org Git - linux/commitdiff
btrfs: scrub: set error stats when tree block spanning stripes
authorZhao Lei <zhaolei@cn.fujitsu.com>
Tue, 25 Aug 2015 13:31:40 +0000 (21:31 +0800)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Thu, 12 Nov 2015 03:37:10 +0000 (22:37 -0500)
It is better to show error stats to user when we found tree block
spanning stripes.

On a btrfs created by old version of btrfs-convert:
Before patch:
  # btrfs scrub start -B /dev/vdh
  scrub done for 8b342d35-2904-41ab-b3cb-2f929709cf47
          scrub started at Tue Aug 25 21:19:09 2015 and finished after 00:00:00
          total bytes scrubbed: 53.54MiB with 0 errors
  # dmesg
  ...
  [  128.711434] BTRFS error (device vdh): scrub: tree block 27054080 spanning stripes, ignored. logical=27000832
  [  128.712744] BTRFS error (device vdh): scrub: tree block 27054080 spanning stripes, ignored. logical=27066368
  ...

After patch:
  # btrfs scrub start -B /dev/vdh
  scrub done for ff7f844b-7a4e-4b1a-88a9-8252ab25be1b
          scrub started at Tue Aug 25 21:42:29 2015 and finished after 00:00:00
          total bytes scrubbed: 53.60MiB with 2 errors
          error details:
          corrected errors: 0, uncorrectable errors: 2, unverified errors: 0
  ERROR: There are uncorrectable errors.
  # dmesg
  ...omit...
  #

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 9799d2c32bef6fba098fbef763002bc8d4851a2c)

Conflicts:
fs/btrfs/scrub.c

fs/btrfs/scrub.c

index c9721bd3413481f68e70b6a55e5e01b7195067e5..fd3ce9c30a7b7ec1eda63d07d6bb8c200a490346 100644 (file)
@@ -2881,11 +2881,15 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
                        flags = btrfs_extent_flags(l, extent);
                        generation = btrfs_extent_generation(l, extent);
 
-                       if (key.objectid < logic_start &&
-                           (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK)) {
-                               btrfs_err(fs_info,
-                                         "scrub: tree block %llu spanning stripes, ignored. logical=%llu",
-                                          key.objectid, logic_start);
+                       if ((flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) &&
+                           (key.objectid < logic_start ||
+                            key.objectid + bytes >
+                            logic_start + map->stripe_len)) {
+                               btrfs_err(fs_info, "scrub: tree block %llu spanning stripes, ignored. logical=%llu",
+                                         key.objectid, logic_start);
+                               spin_lock(&sctx->stat_lock);
+                               sctx->stat.uncorrectable_errors++;
+                               spin_unlock(&sctx->stat_lock);
                                goto next;
                        }
 again:
@@ -3218,6 +3222,9 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
                                           "scrub: tree block %llu spanning "
                                           "stripes, ignored. logical=%llu",
                                       key.objectid, logical);
+                               spin_lock(&sctx->stat_lock);
+                               sctx->stat.uncorrectable_errors++;
+                               spin_unlock(&sctx->stat_lock);
                                goto next;
                        }