diff options
author | Ming Lei <ming.lei@redhat.com> | 2019-08-27 07:01:45 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-08-27 12:40:20 -0400 |
commit | c48dac137a62a5d6fa1ef3fa445cbd9c43655a76 (patch) | |
tree | 0cbc830e7a790655bb0d012ca555f24852765fb3 /block/elevator.c | |
parent | 9685b2270211628e27ea7880a02b52efd4524099 (diff) |
block: don't hold q->sysfs_lock in elevator_init_mq
The original comment says:
q->sysfs_lock must be held to provide mutual exclusion between
elevator_switch() and here.
Which is simply wrong. elevator_init_mq() is only called from
blk_mq_init_allocated_queue, which is always called before the request
queue is registered via blk_register_queue(), for dm-rq or normal rq
based driver. However, queue's kobject is only exposed and added to sysfs
in blk_register_queue(). So there isn't such race between elevator_switch()
and elevator_init_mq().
So avoid to hold q->sysfs_lock in elevator_init_mq().
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/elevator.c')
-rw-r--r-- | block/elevator.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/block/elevator.c b/block/elevator.c index 2f17d66d0e61..33c15fb54ed1 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -607,23 +607,19 @@ int elevator_init_mq(struct request_queue *q) | |||
607 | if (q->nr_hw_queues != 1) | 607 | if (q->nr_hw_queues != 1) |
608 | return 0; | 608 | return 0; |
609 | 609 | ||
610 | /* | 610 | WARN_ON_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags)); |
611 | * q->sysfs_lock must be held to provide mutual exclusion between | 611 | |
612 | * elevator_switch() and here. | ||
613 | */ | ||
614 | mutex_lock(&q->sysfs_lock); | ||
615 | if (unlikely(q->elevator)) | 612 | if (unlikely(q->elevator)) |
616 | goto out_unlock; | 613 | goto out; |
617 | 614 | ||
618 | e = elevator_get(q, "mq-deadline", false); | 615 | e = elevator_get(q, "mq-deadline", false); |
619 | if (!e) | 616 | if (!e) |
620 | goto out_unlock; | 617 | goto out; |
621 | 618 | ||
622 | err = blk_mq_init_sched(q, e); | 619 | err = blk_mq_init_sched(q, e); |
623 | if (err) | 620 | if (err) |
624 | elevator_put(e); | 621 | elevator_put(e); |
625 | out_unlock: | 622 | out: |
626 | mutex_unlock(&q->sysfs_lock); | ||
627 | return err; | 623 | return err; |
628 | } | 624 | } |
629 | 625 | ||