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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
> ---
>  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.





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux