* [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit
@ 2019-09-25 22:23 Ming Lei
2019-09-25 23:31 ` Bart Van Assche
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ming Lei @ 2019-09-25 22:23 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Ming Lei, Bart Van Assche, Damien Le Moal,
syzbot+da3b7677bb913dc1b737
Commit c48dac137a62 ("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.
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Damien Le Moal <Damien.LeMoal@wdc.com>
Reported-by: syzbot+da3b7677bb913dc1b737@syzkaller.appspotmail.com
Fixed: c48dac137a62 ("block: don't hold q->sysfs_lock in elevator_init_mq")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-mq-sched.c | 2 --
block/blk.h | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index c9d183d6c499..ca22afd47b3d 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -555,8 +555,6 @@ void blk_mq_sched_free_requests(struct request_queue *q)
struct blk_mq_hw_ctx *hctx;
int i;
- lockdep_assert_held(&q->sysfs_lock);
-
queue_for_each_hw_ctx(q, hctx, i) {
if (hctx->sched_tags)
blk_mq_free_rqs(q->tag_set, hctx->sched_tags, i);
diff --git a/block/blk.h b/block/blk.h
index ed347f7a97b1..25773d668ec0 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -194,6 +194,8 @@ void elv_unregister_queue(struct request_queue *q);
static inline void elevator_exit(struct request_queue *q,
struct elevator_queue *e)
{
+ lockdep_assert_held(&q->sysfs_lock);
+
blk_mq_sched_free_requests(q);
__elevator_exit(q, e);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit
2019-09-25 22:23 [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit Ming Lei
@ 2019-09-25 23:31 ` Bart Van Assche
2019-09-25 23:38 ` Damien Le Moal
2019-09-26 6:45 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2019-09-25 23:31 UTC (permalink / raw)
To: Ming Lei, Jens Axboe
Cc: linux-block, Damien Le Moal, syzbot+da3b7677bb913dc1b737
On 9/25/19 3:23 PM, Ming Lei wrote:
> Commit c48dac137a62 ("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.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit
2019-09-25 22:23 [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit Ming Lei
2019-09-25 23:31 ` Bart Van Assche
@ 2019-09-25 23:38 ` Damien Le Moal
2019-09-26 6:45 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2019-09-25 23:38 UTC (permalink / raw)
To: Ming Lei, Jens Axboe
Cc: linux-block, Bart Van Assche, syzbot+da3b7677bb913dc1b737
On 2019/09/25 15:24, Ming Lei wrote:
> Commit c48dac137a62 ("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.
>
> Cc: Bart Van Assche <bvanassche@acm.org>
> Cc: Damien Le Moal <Damien.LeMoal@wdc.com>
> Reported-by: syzbot+da3b7677bb913dc1b737@syzkaller.appspotmail.com
> Fixed: c48dac137a62 ("block: don't hold q->sysfs_lock in elevator_init_mq")
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> block/blk-mq-sched.c | 2 --
> block/blk.h | 2 ++
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> index c9d183d6c499..ca22afd47b3d 100644
> --- a/block/blk-mq-sched.c
> +++ b/block/blk-mq-sched.c
> @@ -555,8 +555,6 @@ void blk_mq_sched_free_requests(struct request_queue *q)
> struct blk_mq_hw_ctx *hctx;
> int i;
>
> - lockdep_assert_held(&q->sysfs_lock);
> -
> queue_for_each_hw_ctx(q, hctx, i) {
> if (hctx->sched_tags)
> blk_mq_free_rqs(q->tag_set, hctx->sched_tags, i);
> diff --git a/block/blk.h b/block/blk.h
> index ed347f7a97b1..25773d668ec0 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -194,6 +194,8 @@ void elv_unregister_queue(struct request_queue *q);
> static inline void elevator_exit(struct request_queue *q,
> struct elevator_queue *e)
> {
> + lockdep_assert_held(&q->sysfs_lock);
> +
> blk_mq_sched_free_requests(q);
> __elevator_exit(q, e);
> }
>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit
2019-09-25 22:23 [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit Ming Lei
2019-09-25 23:31 ` Bart Van Assche
2019-09-25 23:38 ` Damien Le Moal
@ 2019-09-26 6:45 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-09-26 6:45 UTC (permalink / raw)
To: Ming Lei
Cc: linux-block, Bart Van Assche, Damien Le Moal,
syzbot+da3b7677bb913dc1b737
On 9/26/19 12:23 AM, Ming Lei wrote:
> Commit c48dac137a62 ("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.
Applied, thanks Ming.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-26 6:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 22:23 [PATCH] blk-mq: move lockdep_assert_held() into elevator_exit Ming Lei
2019-09-25 23:31 ` Bart Van Assche
2019-09-25 23:38 ` Damien Le Moal
2019-09-26 6:45 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).