]> www.infradead.org Git - users/hch/misc.git/commit
badblocks: fix merge issue when new badblocks align with pre+1
authorLi Nan <linan122@huawei.com>
Thu, 27 Feb 2025 07:55:03 +0000 (15:55 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Mar 2025 15:03:28 +0000 (08:03 -0700)
commit9ec65dec634a752ab0a1203510ee190356e4cf1a
tree4dcd618ef294671cb8feb56de64150db7a941c8c
parent3a23d05f9c1abf8238fe48167ab5574062d1606e
badblocks: fix merge issue when new badblocks align with pre+1

There is a merge issue when adding badblocks as follow:
  echo 0 10 > bad_blocks
  echo 30 10 > bad_blocks
  echo 20 10 > bad_blocks
  cat bad_blocks
  0 10
  20 10    //should be merged with (30 10)
  30 10

In this case, if new badblocks does not intersect with prev, it is added
by insert_at(). If there is an intersection with prev+1, the merge will
be processed in the next re_insert loop.

However, when the end of the new badblocks is exactly equal to the offset
of prev+1, no further re_insert loop occurs, and the two badblocks are not
merge.

Fix it by inc prev, badblocks can be merged during the subsequent code.

Fixes: aa511ff8218b ("badblocks: switch to the improved badblock handling code")
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20250227075507.151331-9-zhengqixing@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/badblocks.c