* [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()
@ 2021-08-05 12:46 Yu Kuai
[not found] ` <20210805124645.543797-1-yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Yu Kuai @ 2021-08-05 12:46 UTC (permalink / raw)
To: tj-DgEjT+Ai2ygdnm+yROfE0A, axboe-tSWWG44O7X1aa/9Udqfwiw,
bo.liu-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-block-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
yukuai3-hv44wF8Li93QT0dZR+AlfA, yi.zhang-hv44wF8Li93QT0dZR+AlfA
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 <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <20210805124645.543797-1-yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() [not found] ` <20210805124645.543797-1-yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> @ 2021-08-05 17:17 ` Tejun Heo 2021-08-05 17:18 ` Jens Axboe 1 sibling, 0 replies; 3+ messages in thread From: Tejun Heo @ 2021-08-05 17:17 UTC (permalink / raw) To: Yu Kuai Cc: axboe-tSWWG44O7X1aa/9Udqfwiw, bo.liu-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-block-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, yi.zhang-hv44wF8Li93QT0dZR+AlfA 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 <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> Acked-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Thanks. -- tejun ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() [not found] ` <20210805124645.543797-1-yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> 2021-08-05 17:17 ` Tejun Heo @ 2021-08-05 17:18 ` Jens Axboe 1 sibling, 0 replies; 3+ messages in thread From: Jens Axboe @ 2021-08-05 17:18 UTC (permalink / raw) To: Yu Kuai, tj-DgEjT+Ai2ygdnm+yROfE0A, bo.liu-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-block-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, yi.zhang-hv44wF8Li93QT0dZR+AlfA 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-05 17:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-05 12:46 [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() Yu Kuai
[not found] ` <20210805124645.543797-1-yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2021-08-05 17:17 ` Tejun Heo
2021-08-05 17:18 ` Jens Axboe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox