summaryrefslogtreecommitdiff
path: root/block/blk-iolatency.c
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2021-08-05 20:46:45 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-08-12 13:20:58 +0200
commit580c10a40cc76a206e18c424a114195160a69ddd (patch)
tree0f1331f1ed2c6f09df8e85fe86bdccaa9ba5aa61 /block/blk-iolatency.c
parented169b054b43ebf77dbba7c56931cb1e888e638d (diff)
blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit()
[ Upstream commit 8d75d0eff6887bcac7225e12b9c75595e523d92d ] 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@huawei.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20210805124645.543797-1-yukuai3@huawei.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block/blk-iolatency.c')
-rw-r--r--block/blk-iolatency.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index c128d50cb410..71a82528d4bf 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -832,7 +832,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);
}