diff options
author | Li Nan <linan122@huawei.com> | 2025-02-27 15:54:58 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-10 14:44:06 +0200 |
commit | 4048fdec7ae21c5518aa6e05b5e82b6da2f4b603 (patch) | |
tree | 7f0c6ee639dd6ffad3d01ad36a2ae25af62c935a | |
parent | ebd06a54fd717cedf4f482c2368a46eb41a59418 (diff) | |
download | linux-4048fdec7ae21c5518aa6e05b5e82b6da2f4b603.tar.gz linux-4048fdec7ae21c5518aa6e05b5e82b6da2f4b603.tar.bz2 linux-4048fdec7ae21c5518aa6e05b5e82b6da2f4b603.zip |
badblocks: attempt to merge adjacent badblocks during ack_all_badblocks
[ Upstream commit 32e9ad4d11f69949ff331e35a417871ee0d31d99 ]
If ack and unack badblocks are adjacent, they will not be merged and will
remain as two separate badblocks. Even after the bad blocks are written
to disk and both become ack, they will still remain as two independent
bad blocks. This is not ideal as it wastes the limited space for
badblocks. Therefore, during ack_all_badblocks(), attempt to merge
badblocks if they are adjacent.
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>
Acked-by: Coly Li <colyli@kernel.org>
Link: https://lore.kernel.org/r/20250227075507.151331-4-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 | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/block/badblocks.c b/block/badblocks.c index f069c93e986d..ad8652fbe1c8 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -1491,6 +1491,11 @@ void ack_all_badblocks(struct badblocks *bb) p[i] = BB_MAKE(start, len, 1); } } + + for (i = 0; i < bb->count ; i++) + while (try_adjacent_combine(bb, i)) + ; + bb->unacked_exist = 0; } write_sequnlock_irq(&bb->lock); |