summaryrefslogtreecommitdiff
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2023-05-31 11:45:16 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2023-05-31 11:45:16 -0400
commit2ef23e4b537be3b417080bdade7ef48cf9f95266 (patch)
treede29a318b6a70b3c0a98801b15f33107d2e05bdd /drivers/scsi/scsi_lib.c
parent0e5e41ee3d73823d65b33463d557b8b6833b457d (diff)
parent078f4f4b34d6c2dadabb363d3fc6c84b32927dea (diff)
Merge patch series "ufs: Do not requeue while ungating the clock"
Bart Van Assche <bvanassche@acm.org> says: In the traces we recorded while testing zoned storage we noticed that UFS commands are requeued while the clock is being ungated. Command requeueing makes it harder than necessary to preserve the command order. Hence this patch series that modifies the SCSI core and also the UFS driver such that clock ungating does not trigger command requeueing. Link: https://lore.kernel.org/r/20230529202640.11883-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d1a0b15d4514..496bdfc19c95 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1984,6 +1984,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
tag_set->flags |=
BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
+ if (shost->queuecommand_may_block)
+ tag_set->flags |= BLK_MQ_F_BLOCKING;
tag_set->driver_data = shost;
if (shost->host_tagset)
tag_set->flags |= BLK_MQ_F_TAG_HCTX_SHARED;
@@ -2943,11 +2945,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
@@ -2959,20 +2970,14 @@ scsi_host_block(struct Scsi_Host *shost)
mutex_unlock(&sdev->state_mutex);
if (ret) {
scsi_device_put(sdev);
- break;
+ return ret;
}
}
- /*
- * SCSI never enables blk-mq's BLK_MQ_F_BLOCKING flag so
- * calling synchronize_rcu() once is enough.
- */
- WARN_ON_ONCE(shost->tag_set.flags & BLK_MQ_F_BLOCKING);
+ /* Wait for ongoing scsi_queue_rq() calls to finish. */
+ blk_mq_wait_quiesce_done(&shost->tag_set);
- if (!ret)
- synchronize_rcu();
-
- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(scsi_host_block);