From ceb9b8c360ff6331912617e79e6273bff42a73dc Mon Sep 17 00:00:00 2001 From: Jiufei Xue Date: Tue, 25 Aug 2020 20:03:31 +0800 Subject: [PATCH] iocost: fix a deadlock in ioc_rqos_throttle() hulk inclusion category: feature bugzilla: 38688 CVE: NA --------------------------- ioc_rqos_throttle() may called inside queue_lock, the lock should be unlocked before sleep. Signed-off-by: Jiufei Xue Reviewed-by: Joseph Qi Conflict: block/blk-iocost.c Signed-off-by: Yu Kuai Reviewed-by: Hou Tao Signed-off-by: Yang Yingliang --- block/blk-iocost.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index b8d258e82073..8aa5a79a8fa0 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -1678,6 +1678,8 @@ static u64 calc_vtime_cost(struct bio *bio, struct ioc_gq *iocg, bool is_merge) static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio, spinlock_t *lock) + __releases(lock) + __acquires(lock) { struct ioc *ioc = rqos_to_ioc(rqos); struct request_queue *q = rqos->q; @@ -1814,7 +1816,14 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio, set_current_state(TASK_UNINTERRUPTIBLE); if (wait.committed) break; - io_schedule(); + + if (lock) { + spin_unlock_irq(lock); + io_schedule(); + spin_lock_irq(lock); + } else { + io_schedule(); + } } /* waker already committed us, proceed */ -- GitLab