From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Mike Christie <michael.christie@oracle.com>,
Ming Lei <ming.lei@redhat.com>, Ye Bin <yebin10@huawei.com>,
Hannes Reinecke <hare@suse.de>,
"James E.J. Bottomley" <jejb@linux.ibm.com>
Subject: [PATCH v3 1/4] scsi: core: Rework scsi_host_block()
Date: Fri, 26 May 2023 10:29:46 -0700 [thread overview]
Message-ID: <20230526173007.1627017-2-bvanassche@acm.org> (raw)
In-Reply-To: <20230526173007.1627017-1-bvanassche@acm.org>
Make scsi_host_block() easier to read by converting it to the widely used
early-return style. See also commit f983622ae605 ("scsi: core: Avoid
calling synchronize_rcu() for each device in scsi_host_block()").
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Cc: Ye Bin <yebin10@huawei.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_lib.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 25489fbd94c6..5f29faa0560f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2940,11 +2940,20 @@ scsi_target_unblock(struct device *dev, enum scsi_device_state new_state)
}
EXPORT_SYMBOL_GPL(scsi_target_unblock);
+/**
+ * scsi_host_block - Try to transition all logical units to the SDEV_BLOCK state
+ * @shost: device to block
+ *
+ * Pause SCSI command processing for all logical units associated with the SCSI
+ * host and wait until pending scsi_queue_rq() calls have finished.
+ *
+ * Returns zero if successful or a negative error code upon failure.
+ */
int
scsi_host_block(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
- int ret = 0;
+ int ret;
/*
* Call scsi_internal_device_block_nowait so we can avoid
@@ -2956,7 +2965,7 @@ scsi_host_block(struct Scsi_Host *shost)
mutex_unlock(&sdev->state_mutex);
if (ret) {
scsi_device_put(sdev);
- break;
+ return ret;
}
}
@@ -2966,10 +2975,9 @@ scsi_host_block(struct Scsi_Host *shost)
*/
WARN_ON_ONCE(shost->tag_set.flags & BLK_MQ_F_BLOCKING);
- if (!ret)
- synchronize_rcu();
+ synchronize_rcu();
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(scsi_host_block);
next prev parent reply other threads:[~2023-05-26 17:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 17:29 [PATCH v3 0/4] ufs: Do not requeue while ungating the clock Bart Van Assche
2023-05-26 17:29 ` Bart Van Assche [this message]
2023-05-26 17:29 ` [PATCH v3 2/4] scsi: core: Support setting BLK_MQ_F_BLOCKING Bart Van Assche
2023-05-26 17:29 ` [PATCH v3 3/4] scsi: ufs: Conditionally enable the BLK_MQ_F_BLOCKING flag Bart Van Assche
2023-05-29 6:51 ` Adrian Hunter
2023-05-26 17:29 ` [PATCH v3 4/4] scsi: ufs: Ungate the clock synchronously Bart Van Assche
2023-05-29 7:29 ` Adrian Hunter
2023-05-29 19:58 ` Bart Van Assche
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=20230526173007.1627017-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=adrian.hunter@intel.com \
--cc=hare@suse.de \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=ming.lei@redhat.com \
--cc=yebin10@huawei.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