Re: [PATCH V4 11/24] block: move blk_queue_registered() check into elv_iosched_store()

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

 




On 4/30/25 10:05 AM, Ming Lei wrote:
> Move blk_queue_registered() check into elv_iosched_store() and prepare
> for using elevator_change() for covering any kind of elevator change in
> adding/deleting disk and updating nr_hw_queue.
> 
> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> ---
>  block/elevator.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/elevator.c b/block/elevator.c
> index df3e59107a2a..ac72c4f5a542 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -676,10 +676,6 @@ int elevator_switch(struct request_queue *q, const char *name)
>   */
>  static int elevator_change(struct request_queue *q, const char *elevator_name)
>  {
> -	/* Make sure queue is not in the middle of being removed */
> -	if (!blk_queue_registered(q))
> -		return -ENOENT;
> -
>  	if (q->elevator && elevator_match(q->elevator->type, elevator_name))
>  		return 0;
>  
> @@ -708,6 +704,10 @@ ssize_t elv_iosched_store(struct gendisk *disk, const char *buf,
>  	struct request_queue *q = disk->queue;
>  	struct blk_mq_tag_set *set = q->tag_set;
>  
> +	/* Make sure queue is not in the middle of being removed */
> +	if (!blk_queue_registered(q))
> +		return -ENOENT;
> +
>  	/*
>  	 * If the attribute needs to load a module, do it before freezing the
>  	 * queue to ensure that the module file can be read when the request

Shouldn't blk_queue_registered needs protection? For instance, I see here a race 
while queue is being removed from del_gendisk and at the same time elevator is
being updated from elv_iosched_store. BTW, I saw that your patch 19/24 adds that 
protection using disable_elv_switch before deleting disk (and so you may want to
fold this patch 11/24 into patch 19/24 ?) but with that also I foresee a thin race
window. I will comment on it while reviewing the patch 19/24.

Thanks,
--Nilay




[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