Skip to content

Commit e20fff8

Browse files
mwilckmartinkpetersen
authored andcommitted
scsi: core: Don't wait for quiesce in scsi_device_block()
scsi_device_block() is only called from scsi_target_block(), which calls it repeatedly for every child device. For targets with many devices, waiting for every queue to quiesce may cause a substantial delay (we measured more than 100s delay for blocking a FC rport with 2048 LUNs). Just call blk_mq_wait_quiesce_done() once from scsi_target_block() after stopping all queues. Signed-off-by: Martin Wilck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d7035b7 commit e20fff8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,8 +2771,9 @@ EXPORT_SYMBOL_GPL(scsi_internal_device_block_nowait);
27712771
* @sdev: device to block
27722772
* @data: dummy argument, ignored
27732773
*
2774-
* Pause SCSI command processing on the specified device and wait until all
2775-
* ongoing scsi_queue_rq() calls have finished. May sleep.
2774+
* Pause SCSI command processing on the specified device. Callers must wait
2775+
* until all ongoing scsi_queue_rq() calls have finished after this function
2776+
* returns.
27762777
*
27772778
* Note:
27782779
* This routine transitions the device to the SDEV_BLOCK state (which must be
@@ -2786,17 +2787,15 @@ static void scsi_device_block(struct scsi_device *sdev, void *data)
27862787

27872788
mutex_lock(&sdev->state_mutex);
27882789
err = __scsi_internal_device_block_nowait(sdev);
2789-
if (err == 0) {
2790+
if (err == 0)
27902791
/*
27912792
* scsi_stop_queue() must be called with the state_mutex
27922793
* held. Otherwise a simultaneous scsi_start_queue() call
27932794
* might unquiesce the queue before we quiesce it.
27942795
*/
27952796
scsi_stop_queue(sdev);
2796-
mutex_unlock(&sdev->state_mutex);
2797-
blk_mq_wait_quiesce_done(sdev->request_queue->tag_set);
2798-
} else
2799-
mutex_unlock(&sdev->state_mutex);
2797+
2798+
mutex_unlock(&sdev->state_mutex);
28002799

28012800
WARN_ONCE(err, "__scsi_internal_device_block_nowait(%s) failed: err = %d\n",
28022801
dev_name(&sdev->sdev_gendev), err);
@@ -2894,11 +2893,15 @@ target_block(struct device *dev, void *data)
28942893
void
28952894
scsi_target_block(struct device *dev)
28962895
{
2896+
struct Scsi_Host *shost = dev_to_shost(dev);
2897+
28972898
if (scsi_is_target_device(dev))
28982899
starget_for_each_device(to_scsi_target(dev), NULL,
28992900
scsi_device_block);
29002901
else
29012902
device_for_each_child(dev, NULL, target_block);
2903+
2904+
blk_mq_wait_quiesce_done(&shost->tag_set);
29022905
}
29032906
EXPORT_SYMBOL_GPL(scsi_target_block);
29042907

0 commit comments

Comments
 (0)