提交 1fa9ce8d 编写于 作者: T Tomasz Majchrzak 提交者: Jens Axboe

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: NTomasz Majchrzak <tomasz.majchrzak@intel.com>
Acked-by: NNeilBrown <neilb@suse.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 24532f76
...@@ -354,7 +354,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors) ...@@ -354,7 +354,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
* current range. Earlier ranges could also overlap, * current range. Earlier ranges could also overlap,
* but only this one can overlap the end of the range. * 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 */ /* Partial overlap, leave the tail of this range */
int ack = BB_ACK(p[lo]); int ack = BB_ACK(p[lo]);
sector_t a = BB_OFFSET(p[lo]); sector_t a = BB_OFFSET(p[lo]);
...@@ -377,7 +378,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors) ...@@ -377,7 +378,8 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
lo--; lo--;
} }
while (lo >= 0 && 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 */ /* This range does overlap */
if (BB_OFFSET(p[lo]) < s) { if (BB_OFFSET(p[lo]) < s) {
/* Keep the early parts of this range. */ /* Keep the early parts of this range. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册