public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] scsi/sd: release scan_mutex during sync_cache and start_stop
@ 2017-02-09  1:01 Song Liu
  2017-02-09  8:51 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Song Liu @ 2017-02-09  1:01 UTC (permalink / raw)
  To: linux-scsi; +Cc: bart.vanassche, hch, hch, Song Liu

When a device is deleted through sysfs handle "delete", the code
locks shost->scan_mutex. If multiple devices are deleted at the
same time, these deletes will be handled in series.

On the other hand, sd_shutdown() sometimes issues long latency
commands: sync cache and start_stop. It is not necessary for these
commands to run in series.

To reduce latency of parallel "delete" requests, this patch unlock
shost->scan_mutex before calling sd_shutdown(), relock the mutex
afterwards.

Fixed bug from previous version.

Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>
---
 drivers/scsi/sd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9e0783b..61ea308 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3211,9 +3211,13 @@ static int sd_probe(struct device *dev)
 static int sd_remove(struct device *dev)
 {
 	struct scsi_disk *sdkp;
+	struct scsi_device *sdev;
+	struct Scsi_Host *shost;
 	dev_t devt;
 
 	sdkp = dev_get_drvdata(dev);
+	sdev = sdkp->device;
+	shost = sdev->host;
 	devt = disk_devt(sdkp->disk);
 	scsi_autopm_get_device(sdkp->device);
 
@@ -3221,7 +3225,9 @@ static int sd_remove(struct device *dev)
 	async_synchronize_full_domain(&scsi_sd_probe_domain);
 	device_del(&sdkp->dev);
 	del_gendisk(sdkp->disk);
+	mutex_unlock(&shost->scan_mutex);
 	sd_shutdown(dev);
+	mutex_lock(&shost->scan_mutex);
 
 	sd_zbc_remove(sdkp);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-09 22:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09  1:01 [PATCH v4] scsi/sd: release scan_mutex during sync_cache and start_stop Song Liu
2017-02-09  8:51 ` Christoph Hellwig
2017-02-09 22:24   ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox