md: bad block list should default to disabled.
authorNeilBrown <neilb@suse.de>
Wed, 24 Apr 2013 01:42:44 +0000 (11:42 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 30 Apr 2013 04:49:32 +0000 (14:49 +1000)
Maintenance of a bad-block-list currently defaults to 'enabled'
and is then disabled when it cannot be supported.
This is backwards and causes problem for dm-raid which didn't know
to disable it.

So fix the defaults, and only enabled for v1.x metadata which
explicitly has bad blocks enabled.

The problem with dm-raid has been present since badblock support was
added in v3.1, so this patch is suitable for any -stable from 3.1
onwards.

Cc: stable@vger.kernel.org (3.1+)
Reported-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/md.c

index 0df1b9a3d48e9b17c80c6049c224579ea0c31725..4c74424c78b049068c0f118de398640781796c1b 100644 (file)
@@ -1567,8 +1567,8 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
                                             sector, count, 1) == 0)
                                return -EINVAL;
                }
-       } else if (sb->bblog_offset == 0)
-               rdev->badblocks.shift = -1;
+       } else if (sb->bblog_offset != 0)
+               rdev->badblocks.shift = 0;
 
        if (!refdev) {
                ret = 1;
@@ -3227,7 +3227,7 @@ int md_rdev_init(struct md_rdev *rdev)
         * be used - I wonder if that matters
         */
        rdev->badblocks.count = 0;
-       rdev->badblocks.shift = 0;
+       rdev->badblocks.shift = -1; /* disabled until explicitly enabled */
        rdev->badblocks.page = kmalloc(PAGE_SIZE, GFP_KERNEL);
        seqlock_init(&rdev->badblocks.lock);
        if (rdev->badblocks.page == NULL)
@@ -3299,9 +3299,6 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
                        goto abort_free;
                }
        }
-       if (super_format == -1)
-               /* hot-add for 0.90, or non-persistent: so no badblocks */
-               rdev->badblocks.shift = -1;
 
        return rdev;