aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2014-12-16 16:21:43 -0500
committerChristoph Hellwig <hch@lst.de>2015-01-09 09:44:26 -0500
commit34a716bc345ba06c34aa33d09536fcb607523818 (patch)
treedef7a933326d96cb3415c0de1f7b75edeeeba4fe
parent2a09ed3d97ff8b5b377f86da9b9afd9ebd97b362 (diff)
storvsc: force discovery of LUNs that may have been removed.
The host asks the guest to scan when a LUN is removed or added. The only way a guest can identify the removed LUN is when an I/O is attempted on a removed LUN - the SRB status code indicates that the LUN is invalid. We currently handle this SRB status and remove the device. Rather than waiting for an I/O to remove the device, force the discovery of LUNs that may have been removed prior to discovering LUNs that may have been added. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Reviewed-by: Long Li <longli@microsoft.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/storvsc_drv.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index ab0bb98239b0..ae8293a38855 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -414,10 +414,36 @@ static void storvsc_host_scan(struct work_struct *work)
414{ 414{
415 struct storvsc_scan_work *wrk; 415 struct storvsc_scan_work *wrk;
416 struct Scsi_Host *host; 416 struct Scsi_Host *host;
417 struct scsi_device *sdev;
418 unsigned long flags;
417 419
418 wrk = container_of(work, struct storvsc_scan_work, work); 420 wrk = container_of(work, struct storvsc_scan_work, work);
419 host = wrk->host; 421 host = wrk->host;
420 422
423 /*
424 * Before scanning the host, first check to see if any of the
425 * currrently known devices have been hot removed. We issue a
426 * "unit ready" command against all currently known devices.
427 * This I/O will result in an error for devices that have been
428 * removed. As part of handling the I/O error, we remove the device.
429 *
430 * When a LUN is added or removed, the host sends us a signal to
431 * scan the host. Thus we are forced to discover the LUNs that
432 * may have been removed this way.
433 */
434 mutex_lock(&host->scan_mutex);
435 spin_lock_irqsave(host->host_lock, flags);
436 list_for_each_entry(sdev, &host->__devices, siblings) {
437 spin_unlock_irqrestore(host->host_lock, flags);
438 scsi_test_unit_ready(sdev, 1, 1, NULL);
439 spin_lock_irqsave(host->host_lock, flags);
440 continue;
441 }
442 spin_unlock_irqrestore(host->host_lock, flags);
443 mutex_unlock(&host->scan_mutex);
444 /*
445 * Now scan the host to discover LUNs that may have been added.
446 */
421 scsi_scan_host(host); 447 scsi_scan_host(host);
422 448
423 kfree(wrk); 449 kfree(wrk);