btrfs-progs: Fix a bug in chunk item extra check and allow degraded chunk.
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Fri, 15 May 2015 05:11:14 +0000 (13:11 +0800)
committerDavid Sterba <dsterba@suse.cz>
Wed, 20 May 2015 12:24:26 +0000 (14:24 +0200)
For DUP profile, the num_stripes should be 2 not 1.
This causes btrfs offline tool fails on valid image.

Also, num_stripes check is too restrict for btrfsck self test,
as there is some image in degraded mode, so modify it to allow degraded
chunk.

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

index 77cc305..14ce33e 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -1649,12 +1649,11 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
        /*
         * Device number check against profile
         */
-       if ((map->type & BTRFS_BLOCK_GROUP_RAID10 && num_stripes < 4 &&
-            map->sub_stripes < 2) ||
-           (map->type & BTRFS_BLOCK_GROUP_RAID1 && num_stripes < 2) ||
-           (map->type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes < 3) ||
-           (map->type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 4) ||
-           (map->type & BTRFS_BLOCK_GROUP_DUP && num_stripes != 1) ||
+       if ((map->type & BTRFS_BLOCK_GROUP_RAID10 && map->sub_stripes == 0) ||
+           (map->type & BTRFS_BLOCK_GROUP_RAID1 && num_stripes < 1) ||
+           (map->type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes < 2) ||
+           (map->type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 3) ||
+           (map->type & BTRFS_BLOCK_GROUP_DUP && num_stripes > 2) ||
            ((map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 &&
             num_stripes != 1)) {
                fprintf(stderr,