[PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()

Subsystems: block layer, control group - block io controller (blkio), the rest

STALE1861d LANDED

Landed in mainline as 8d75d0eff688 on 2021-08-05.

3 messages, 3 authors, 2021-08-05 · open the first message on its own page

[PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()

From: Yu Kuai <hidden>
Date: 2021-08-05 12:36:46

If queue is dying while iolatency_set_limit() is in progress,
blk_get_queue() won't increment the refcount of the queue. However,
blk_put_queue() will still decrement the refcount later, which will
cause the refcout to be unbalanced.

Thus error out in such case to fix the problem.

Fixes: 8c772a9bfc7c ("blk-iolatency: fix IO hang due to negative inflight counter")
Signed-off-by: Yu Kuai <redacted>
---
 block/blk-iolatency.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index 81be0096411d..d8b0d8bd132b 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -833,7 +833,11 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf,
 
 	enable = iolatency_set_min_lat_nsec(blkg, lat_val);
 	if (enable) {
-		WARN_ON_ONCE(!blk_get_queue(blkg->q));
+		if (!blk_get_queue(blkg->q)) {
+			ret = -ENODEV;
+			goto out;
+		}
+
 		blkg_get(blkg);
 	}
 
-- 
2.31.1

Re: [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()

From: Tejun Heo <tj@kernel.org>
Date: 2021-08-05 17:17:33

On Thu, Aug 05, 2021 at 08:46:45PM +0800, Yu Kuai wrote:
If queue is dying while iolatency_set_limit() is in progress,
blk_get_queue() won't increment the refcount of the queue. However,
blk_put_queue() will still decrement the refcount later, which will
cause the refcout to be unbalanced.

Thus error out in such case to fix the problem.

Fixes: 8c772a9bfc7c ("blk-iolatency: fix IO hang due to negative inflight counter")
Signed-off-by: Yu Kuai <redacted>
Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

Re: [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()

From: Jens Axboe <axboe@kernel.dk>
Date: 2021-08-05 17:18:36

On 8/5/21 6:46 AM, Yu Kuai wrote:
If queue is dying while iolatency_set_limit() is in progress,
blk_get_queue() won't increment the refcount of the queue. However,
blk_put_queue() will still decrement the refcount later, which will
cause the refcout to be unbalanced.

Thus error out in such case to fix the problem.
Applied, thanks.

-- 
Jens Axboe
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help