[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230428085020.2283981-6-linan666@huaweicloud.com>
Date: Fri, 28 Apr 2023 16:50:15 +0800
From: linan666@...weicloud.com
To: axboe@...nel.dk, vishal.l.verma@...el.com, dan.j.williams@...el.com
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
linan122@...wei.com, yukuai3@...wei.com, yi.zhang@...wei.com,
houtao1@...wei.com, yangerkun@...wei.com
Subject: [PATCH 05/10] block/badblocks: fix ack set fail in badblocks_set
From: Li Nan <linan122@...wei.com>
If we try to set ack for a BB_MAX_LEN badblocks, it will return
0(success) but did not set ack at all in badblocks_set(). Check ack
before setting to fix it, and do not set badblocks already exist.
Fixes: 9e0e252a048b ("badblocks: Add core badblock management code")
Signed-off-by: Li Nan <linan122@...wei.com>
---
block/badblocks.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/badblocks.c b/block/badblocks.c
index 11e3a3ae2c72..c11eb869f2f3 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -219,18 +219,18 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
if (e < s + sectors)
e = s + sectors;
if (e - a <= BB_MAX_LEN) {
- p[lo] = BB_MAKE(a, e-a, ack);
s = e;
} else {
/* does not all fit in one range,
* make p[lo] maximal
*/
- if (BB_LEN(p[lo]) != BB_MAX_LEN)
- p[lo] = BB_MAKE(a, BB_MAX_LEN, ack);
s = a + BB_MAX_LEN;
}
+ if (s - a != BB_LEN(p[lo]) || ack != BB_ACK(p[lo])) {
+ p[lo] = BB_MAKE(a, s - a, ack);
+ changed = true;
+ }
sectors = e - s;
- changed = true;
}
}
if (sectors && hi < bb->count) {
--
2.31.1
Powered by blists - more mailing lists