diff mbox series

[3/7] block: Remove sysfs lock from elevator_init_rq()

Message ID 20190823001528.5673-4-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series Elevator cleanups and improvements | expand

Commit Message

Damien Le Moal Aug. 23, 2019, 12:15 a.m. UTC
Since elevator_init_rq() is called before the device queue is registered
in sysfs, there is no possible conflict with elevator_switch(). Remove
the unnecessary locking of q->sysfs_lock mutex.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/elevator.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

Johannes Thumshirn Aug. 23, 2019, 9 a.m. UTC | #1
On 23/08/2019 02:15, Damien Le Moal wrote:
> Since elevator_init_rq() is called before the device queue is registered
elevator_init_mq() ~^ (and in Subject)

Otherwise:
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Bart Van Assche Aug. 23, 2019, 8:32 p.m. UTC | #2
On 8/22/19 5:15 PM, Damien Le Moal wrote:
> Since elevator_init_rq() is called before the device queue is registered
> in sysfs, there is no possible conflict with elevator_switch(). Remove
> the unnecessary locking of q->sysfs_lock mutex.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  block/elevator.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/block/elevator.c b/block/elevator.c
> index 7fff06751633..6208ddc334ef 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -617,17 +617,12 @@ void elevator_init_mq(struct request_queue *q)
>  	if (q->nr_hw_queues != 1)
>  		return;
>  
> -	/*
> -	 * q->sysfs_lock must be held to provide mutual exclusion between
> -	 * elevator_switch() and here.
> -	 */
> -	mutex_lock(&q->sysfs_lock);
>  	if (unlikely(q->elevator))
> -		goto out_unlock;
> +		return;
>  
>  	e = elevator_get(q, "mq-deadline", false);
>  	if (!e)
> -		goto out_unlock;
> +		return;
>  
>  	err = blk_mq_init_sched(q, e);
>  	if (err) {
> @@ -635,9 +630,6 @@ void elevator_init_mq(struct request_queue *q)
>  			"falling back to \"none\"\n", e->elevator_name);
>  		elevator_put(e);
>  	}
> -
> -out_unlock:
> -	mutex_unlock(&q->sysfs_lock);
>  }

Please consider to add a WARN_ON_ONCE() statement that triggers a
warning if this function is called for a request queue that has already
been registered.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/block/elevator.c b/block/elevator.c
index 7fff06751633..6208ddc334ef 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -617,17 +617,12 @@  void elevator_init_mq(struct request_queue *q)
 	if (q->nr_hw_queues != 1)
 		return;
 
-	/*
-	 * q->sysfs_lock must be held to provide mutual exclusion between
-	 * elevator_switch() and here.
-	 */
-	mutex_lock(&q->sysfs_lock);
 	if (unlikely(q->elevator))
-		goto out_unlock;
+		return;
 
 	e = elevator_get(q, "mq-deadline", false);
 	if (!e)
-		goto out_unlock;
+		return;
 
 	err = blk_mq_init_sched(q, e);
 	if (err) {
@@ -635,9 +630,6 @@  void elevator_init_mq(struct request_queue *q)
 			"falling back to \"none\"\n", e->elevator_name);
 		elevator_put(e);
 	}
-
-out_unlock:
-	mutex_unlock(&q->sysfs_lock);
 }