public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Wenchao Hao <haowenchao2@huawei.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	louhongxiang@huawei.com
Subject: Re: [PATCH v3 1/2] scsi: core: cleanup scsi_dev_queue_ready()
Date: Wed, 18 Oct 2023 11:07:03 -0700	[thread overview]
Message-ID: <d62c3e97-bddf-4fd4-9099-2ff6954938b3@acm.org> (raw)
In-Reply-To: <20231018113746.1940197-2-haowenchao2@huawei.com>

On 10/18/23 04:37, Wenchao Hao wrote:
> This is just a cleanup for scsi_dev_queue_ready() to avoid
> redundant goto and if statement, it did not change the origin
> logic.
> 
> Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
> ---
>   drivers/scsi/scsi_lib.c | 32 +++++++++++++++-----------------
>   1 file changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index aca57c3ab626..cf3864f72093 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1251,28 +1251,26 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
>   	int token;
>   
>   	token = sbitmap_get(&sdev->budget_map);
> -	if (atomic_read(&sdev->device_blocked)) {
> -		if (token < 0)
> -			goto out;
> +	if (token < 0)
> +		return -1;
>   
> -		if (scsi_device_busy(sdev) > 1)
> -			goto out_dec;
> +	if (!atomic_read(&sdev->device_blocked))
> +		return token;
>   
> -		/*
> -		 * unblock after device_blocked iterates to zero
> -		 */
> -		if (atomic_dec_return(&sdev->device_blocked) > 0)
> -			goto out_dec;
> -		SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev,
> -				   "unblocking device at zero depth\n"));
> +	/*
> +	 * Only unblock if no other commands are pending and
> +	 * if device_blocked has decreased to zero
> +	 */
> +	if (scsi_device_busy(sdev) > 1 ||
> +	    atomic_dec_return(&sdev->device_blocked) > 0) {
> +		sbitmap_put(&sdev->budget_map, token);
> +		return -1;
>   	}
>   
> +	SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev,
> +			 "unblocking device at zero depth\n"));
> +
>   	return token;
> -out_dec:
> -	if (token >= 0)
> -		sbitmap_put(&sdev->budget_map, token);
> -out:
> -	return -1;
>   }
>   
>   /*

Thanks for having made this function easier to read.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

  reply	other threads:[~2023-10-18 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 11:37 [PATCH v3 0/2] cleanup patch Wenchao Hao
2023-10-18 11:37 ` [PATCH v3 1/2] scsi: core: cleanup scsi_dev_queue_ready() Wenchao Hao
2023-10-18 18:07   ` Bart Van Assche [this message]
2023-10-18 11:37 ` [PATCH v3 2/2] scsi: Add comment of target_destroy in scsi_host_template Wenchao Hao
2023-10-18 18:03   ` Bart Van Assche
2023-10-25  2:31 ` [PATCH v3 0/2] cleanup patch Martin K. Petersen
2023-10-30 15:34 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d62c3e97-bddf-4fd4-9099-2ff6954938b3@acm.org \
    --to=bvanassche@acm.org \
    --cc=haowenchao2@huawei.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=louhongxiang@huawei.com \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox