Skip to content

Commit 50adc22

Browse files
Ming Leigregkh
Ming Lei
authored andcommitted
blk-mq: move lockdep_assert_held() into elevator_exit
[ Upstream commit 284b94b ] Commit c48dac1 ("block: don't hold q->sysfs_lock in elevator_init_mq") removes q->sysfs_lock from elevator_init_mq(), but forgot to deal with lockdep_assert_held() called in blk_mq_sched_free_requests() which is run in failure path of elevator_init_mq(). blk_mq_sched_free_requests() is called in the following 3 functions: elevator_init_mq() elevator_exit() blk_cleanup_queue() In blk_cleanup_queue(), blk_mq_sched_free_requests() is followed exactly by 'mutex_lock(&q->sysfs_lock)'. So moving the lockdep_assert_held() from blk_mq_sched_free_requests() into elevator_exit() for fixing the report by syzbot. Reported-by: [email protected] Fixed: c48dac1 ("block: don't hold q->sysfs_lock in elevator_init_mq") Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a367806 commit 50adc22

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

block/blk-mq-sched.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,6 @@ void blk_mq_sched_free_requests(struct request_queue *q)
555555
struct blk_mq_hw_ctx *hctx;
556556
int i;
557557

558-
lockdep_assert_held(&q->sysfs_lock);
559-
560558
queue_for_each_hw_ctx(q, hctx, i) {
561559
if (hctx->sched_tags)
562560
blk_mq_free_rqs(q->tag_set, hctx->sched_tags, i);

block/blk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ void elv_unregister_queue(struct request_queue *q);
201201
static inline void elevator_exit(struct request_queue *q,
202202
struct elevator_queue *e)
203203
{
204+
lockdep_assert_held(&q->sysfs_lock);
205+
204206
blk_mq_sched_free_requests(q);
205207
__elevator_exit(q, e);
206208
}

0 commit comments

Comments
 (0)