diff options
author | Li Nan <linan122@huawei.com> | 2025-02-27 15:55:03 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-10 14:44:06 +0200 |
commit | c58df052cf56edf3cd7a01536017cd6b31498aed (patch) | |
tree | 7da29ad1120b72c11cc95597caa1c886dd101fb6 | |
parent | a517d3dac67c735d8644ac2ee6c2c5a6f1f60a10 (diff) | |
download | linux-c58df052cf56edf3cd7a01536017cd6b31498aed.tar.gz linux-c58df052cf56edf3cd7a01536017cd6b31498aed.tar.bz2 linux-c58df052cf56edf3cd7a01536017cd6b31498aed.zip |
badblocks: fix merge issue when new badblocks align with pre+1
[ Upstream commit 9ec65dec634a752ab0a1203510ee190356e4cf1a ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | block/badblocks.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/badblocks.c b/block/badblocks.c index 43430bd3efa7..52206a42191d 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -892,7 +892,7 @@ re_insert: len = insert_at(bb, 0, &bad); bb->count++; added++; - hint = 0; + hint = ++prev; goto update_sectors; } @@ -951,7 +951,7 @@ re_insert: len = insert_at(bb, prev + 1, &bad); bb->count++; added++; - hint = prev + 1; + hint = ++prev; update_sectors: s += len; |