public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: mwilck@suse.com
To: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@lst.de>, Ming Lei <ming.lei@redhat.com>,
	Bart Van Assche <Bart.VanAssche@sandisk.com>
Cc: James Bottomley <jejb@linux.vnet.ibm.com>,
	linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
	Hannes Reinecke <hare@suse.de>, Martin Wilck <mwilck@suse.com>
Subject: [PATCH v3 5/8] scsi: don't wait for quiesce in scsi_stop_queue()
Date: Wed,  7 Jun 2023 20:22:46 +0200	[thread overview]
Message-ID: <20230607182249.22623-6-mwilck@suse.com> (raw)
In-Reply-To: <20230607182249.22623-1-mwilck@suse.com>

From: Martin Wilck <mwilck@suse.com>

scsi_stop_queue() has just two callers, one with and one without
"nowait". As blk_mq_quiesce_queue() comes down to
blk_mq_quiesce_queue_nowait() followed by blk_mq_wait_quiesce_done(),
we might as well open-code this in scsi_device_block().

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 drivers/scsi/scsi_lib.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 26e7ce25fa05..657d10c57205 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2726,24 +2726,16 @@ void scsi_start_queue(struct scsi_device *sdev)
 		blk_mq_unquiesce_queue(sdev->request_queue);
 }
 
-static void scsi_stop_queue(struct scsi_device *sdev, bool nowait)
+static void scsi_stop_queue(struct scsi_device *sdev)
 {
 	/*
 	 * The atomic variable of ->queue_stopped covers that
 	 * blk_mq_quiesce_queue* is balanced with blk_mq_unquiesce_queue.
 	 *
-	 * However, we still need to wait until quiesce is done
-	 * in case that queue has been stopped.
+	 * After return, we still need to wait until quiesce is done.
 	 */
-	if (!cmpxchg(&sdev->queue_stopped, 0, 1)) {
-		if (nowait)
-			blk_mq_quiesce_queue_nowait(sdev->request_queue);
-		else
-			blk_mq_quiesce_queue(sdev->request_queue);
-	} else {
-		if (!nowait)
-			blk_mq_wait_quiesce_done(sdev->request_queue->tag_set);
-	}
+	if (!cmpxchg(&sdev->queue_stopped, 0, 1))
+		blk_mq_quiesce_queue_nowait(sdev->request_queue);
 }
 
 /**
@@ -2770,7 +2762,7 @@ int scsi_internal_device_block_nowait(struct scsi_device *sdev)
 	 * request queue.
 	 */
 	if (!ret)
-		scsi_stop_queue(sdev, true);
+		scsi_stop_queue(sdev);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(scsi_internal_device_block_nowait);
@@ -2796,8 +2788,10 @@ static void scsi_device_block(struct scsi_device *sdev, void *data)
 	mutex_lock(&sdev->state_mutex);
 	err = __scsi_internal_device_block_nowait(sdev);
 	mutex_unlock(&sdev->state_mutex);
-	if (err == 0)
-		scsi_stop_queue(sdev, false);
+	if (err == 0) {
+		scsi_stop_queue(sdev);
+		blk_mq_wait_quiesce_done(sdev->request_queue->tag_set);
+	}
 
 	WARN_ONCE(err, "__scsi_internal_device_block_nowait(%s) failed: err = %d\n",
 		  dev_name(&sdev->sdev_gendev), err);
-- 
2.40.1


  parent reply	other threads:[~2023-06-07 18:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 18:22 [PATCH v3 0/8] scsi: fixes for targets with many LUNs, and scsi_target_block rework mwilck
2023-06-07 18:22 ` [PATCH v3 1/8] bsg: increase number of devices mwilck
2023-06-07 18:22 ` [PATCH v3 2/8] scsi: sg: " mwilck
2023-06-07 18:22 ` [PATCH v3 3/8] scsi: merge scsi_internal_device_block() and device_block() mwilck
2023-06-07 19:10   ` Bart Van Assche
2023-06-08  5:42   ` Christoph Hellwig
2023-06-07 18:22 ` [PATCH v3 4/8] scsi: call scsi_stop_queue() without state_mutex held mwilck
2023-06-07 19:16   ` Bart Van Assche
2023-06-07 19:37     ` Martin Wilck
2023-06-07 20:07       ` Martin Wilck
2023-06-08  5:44         ` Christoph Hellwig
2023-06-08 14:12           ` Bart Van Assche
2023-06-08 18:54             ` Mike Christie
2023-06-12 11:15               ` Martin Wilck
2023-06-12 13:41                 ` Bart Van Assche
2023-06-07 18:22 ` mwilck [this message]
2023-06-08  5:46   ` [PATCH v3 5/8] scsi: don't wait for quiesce in scsi_stop_queue() Christoph Hellwig
2023-06-07 18:22 ` [PATCH v3 6/8] scsi: don't wait for quiesce in scsi_device_block() mwilck
2023-06-07 18:22 ` [PATCH v3 7/8] scsi: have scsi_target_block() expect a scsi_target parent argument mwilck
2023-06-08  5:48   ` Christoph Hellwig
2023-06-07 18:22 ` [PATCH v3 8/8] scsi: add Scsi_Host argument to scsi_target_block() mwilck

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=20230607182249.22623-6-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.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