Skip to content

Commit

Permalink
blk-iolatency: error out if blk_get_queue() failed in iolatency_set_l…
Browse files Browse the repository at this point in the history
…imit()

[ Upstream commit 8d75d0e ]

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: 8c772a9 ("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>
  • Loading branch information
Yu Kuai authored and gregkh committed Aug 12, 2021
1 parent fc443de commit 5c4139e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion block/blk-iolatency.c
Expand Up @@ -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);
}

Expand Down

0 comments on commit 5c4139e

Please sign in to comment.