Commit 996a09b6 authored by Jan Kara's avatar Jan Kara Committed by Yang Yingliang
Browse files

bfq: Remove merged request already in bfq_requests_merged()



mainline inclusion
from mainline-v5.14-rc1
commit  a921c655
category: bugfix
bugzilla: 185777, 185811
CVE: NA

Currently, bfq does very little in bfq_requests_merged() and handles all
the request cleanup in bfq_finish_requeue_request() called from
blk_mq_free_request(). That is currently safe only because
blk_mq_free_request() is called shortly after bfq_requests_merged()
while bfqd->lock is still held. However to fix a lock inversion between
bfqd->lock and ioc->lock, we need to call blk_mq_free_request() after
dropping bfqd->lock. That would mean that already merged request could
be seen by other processes inside bfq queues and possibly dispatched to
the device which is wrong. So move cleanup of the request from
bfq_finish_requeue_request() to bfq_requests_merged().

Acked-by: default avatarPaolo Valente <paolo.valente@linaro.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20210623093634.27879-2-jack@suse.cz


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>

conflict: in bfq_finish_requeue_request, 4.19 not have
bfq_update_inject_limit branch;
Signed-off-by: default avatarzhangwensheng <zhangwensheng5@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 2263df72
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment