]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
badblocks: fix wrong return value in badblocks_set if badblocks are disabled
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 3 Nov 2017 17:24:44 +0000 (11:24 -0600)
committerShaohua Li <shli@fb.com>
Fri, 3 Nov 2017 18:29:50 +0000 (11:29 -0700)
MD's rdev_set_badblocks() expects that badblocks_set() returns 1 if
badblocks are disabled, otherwise, rdev_set_badblocks() will record
superblock changes and return success in that case and md will fail to
report an IO error which it should.

This bug has existed since badblocks were introduced in commit
9e0e252a048b ("badblocks: Add core badblock management code").

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Acked-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
block/badblocks.c

index 43c71166e1e2a644b0c59fecdd178524de5e6b4a..91f7bcf979d374537f6dcaf30e2ee0c54947fed4 100644 (file)
@@ -178,7 +178,7 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
 
        if (bb->shift < 0)
                /* badblocks are disabled */
-               return 0;
+               return 1;
 
        if (bb->shift) {
                /* round the start down, and the end up */