diff options
author | Tomasz Majchrzak <tomasz.majchrzak@intel.com> | 2016-10-12 12:23:08 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-10-12 08:08:08 -0600 |
commit | 1fa9ce8d0e903449842943a77e8ba100169964be (patch) | |
tree | 41d80d976b3c37fb424d44f25239fbb5c3aa3198 /block/badblocks.c | |
parent | 24532f768121b07b16178ffb40442ece43365cbd (diff) | |
download | linux-1fa9ce8d0e903449842943a77e8ba100169964be.tar.bz2 |
badblocks: fix overlapping check for clearing
Current bad block clear implementation assumes the range to clear
overlaps with at least one bad block already stored. If given range to
clear precedes first bad block in a list, the first entry is incorrectly
updated.
Check not only if stored block end is past clear block end but also if
stored block start is before clear block end.
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Acked-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/badblocks.c')
-rw-r--r-- | block/badblocks.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/block/badblocks.c b/block/badblocks.c index 7be53cb1cc3c..6610e282a03e 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -354,7 +354,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors) * current range. Earlier ranges could also overlap, * but only this one can overlap the end of the range. */ - if (BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > target) { + if ((BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > target) && + (BB_OFFSET(p[lo]) < target)) { /* Partial overlap, leave the tail of this range */ int ack = BB_ACK(p[lo]); sector_t a = BB_OFFSET(p[lo]); @@ -377,7 +378,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors) lo--; } while (lo >= 0 && - BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > s) { + (BB_OFFSET(p[lo]) + BB_LEN(p[lo]) > s) && + (BB_OFFSET(p[lo]) < target)) { /* This range does overlap */ if (BB_OFFSET(p[lo]) < s) { /* Keep the early parts of this range. */ |