btrfs-progs: fsck: Fix a false metadata extent warning
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 31 Mar 2016 02:19:34 +0000 (10:19 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 May 2016 12:40:05 +0000 (14:40 +0200)
At least 2 user from mail list reported btrfsck reported false alert of
"bad metadata [XXXX,YYYY) crossing stripe boundary".

While the reported number are all inside the same 64K boundary.
After some check, all the false alert have the same bytenr feature,
which can be divided by stripe size (64K).

The result seems to be initial 'max_size' can be 0, causing 'start' +
'max_size' - 1, to cross the stripe boundary.

Fix it by always update extent_record->cross_stripe when the
extent_record is updated, to avoid temporary false alert to be reported.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-check.c

index d157075..ef23ddb 100644 (file)
@@ -4579,9 +4579,9 @@ static int add_extent_rec(struct cache_tree *extent_cache,
                 * As now stripe_len is fixed to BTRFS_STRIPE_LEN, just check
                 * it.
                 */
-               if (metadata && check_crossing_stripes(rec->start,
-                                                      rec->max_size))
-                               rec->crossing_stripes = 1;
+               if (metadata)
+                       rec->crossing_stripes = check_crossing_stripes(
+                                       rec->start, rec->max_size);
                check_extent_type(rec);
                maybe_free_extent_rec(extent_cache, rec);
                return ret;
@@ -4641,8 +4641,8 @@ static int add_extent_rec(struct cache_tree *extent_cache,
        }
 
        if (metadata)
-               if (check_crossing_stripes(rec->start, rec->max_size))
-                       rec->crossing_stripes = 1;
+               rec->crossing_stripes = check_crossing_stripes(rec->start,
+                               rec->max_size);
        check_extent_type(rec);
        return ret;
 }