linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] scsi: wait sd probing in manual scan
@ 2017-04-28  7:48 Peng Tao
  2017-05-03 18:15 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Tao @ 2017-04-28  7:48 UTC (permalink / raw)
  To: linux-scsi
  Cc: linux-kernel, Peng Tao, James E.J. Bottomley, Martin K. Petersen

We have a guest init programe trying to mount a device after doing scsi host scan
at boot time. Occasionally it fails to find the device when mounting. After digging
a bit, it seems the root cause is sd async_schedule probing.

With async probing, there is no guarantee of device readiness when scsi host
scan finishes. However, users do expect to have a valid way to make sure device
is usable. Change scsi scan to wait sd probing in manual scan case so that we
don't leave user with random device state when scsi host scan returns.

Is this the right way to have such guarantee?

CC: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Peng Tao <bergwolf@gmail.com>
---
 drivers/scsi/scsi_scan.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 6f7128f..0208f40 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1077,6 +1077,11 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
 			SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
 				"scsi scan: device exists on %s\n",
 				dev_name(&sdev->sdev_gendev)));
+			/* sd probing uses async_schedule.  Wait until it finishes if this
+			 * is a user requested rescan.
+			 */
+			if (rescan == SCSI_SCAN_MANUAL && scsi_is_sdev_device(&sdev->sdev_gendev))
+				async_synchronize_full_domain(&scsi_sd_probe_domain);
 			if (sdevp)
 				*sdevp = sdev;
 			else
@@ -1176,6 +1181,12 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
 		}
 	}

+	/* sd probing uses async_schedule.  Wait until it finishes if this
+	 * is a user requested rescan.
+	 */
+	if (rescan == SCSI_SCAN_MANUAL && scsi_is_sdev_device(&sdev->sdev_gendev))
+		async_synchronize_full_domain(&scsi_sd_probe_domain);
+
  out_free_result:
 	kfree(result);
  out_free_sdev:
-- 
2.7.4

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

* Re: [PATCH RFC] scsi: wait sd probing in manual scan
  2017-04-28  7:48 [PATCH RFC] scsi: wait sd probing in manual scan Peng Tao
@ 2017-05-03 18:15 ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2017-05-03 18:15 UTC (permalink / raw)
  To: linux-scsi, bergwolf; +Cc: jejb, linux-kernel, martin.petersen

On Fri, 2017-04-28 at 15:48 +0800, Peng Tao wrote:
> We have a guest init programe trying to mount a device after doing scsi host scan
> at boot time. Occasionally it fails to find the device when mounting. After digging
> a bit, it seems the root cause is sd async_schedule probing.
> 
> With async probing, there is no guarantee of device readiness when scsi host
> scan finishes. However, users do expect to have a valid way to make sure device
> is usable. Change scsi scan to wait sd probing in manual scan case so that we
> don't leave user with random device state when scsi host scan returns.
> 
> Is this the right way to have such guarantee?

Hello Peng,

Please fix the guest init program such that it waits until the SCSI device
it needs is ready.

Thanks,

Bart.

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

end of thread, other threads:[~2017-05-03 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-28  7:48 [PATCH RFC] scsi: wait sd probing in manual scan Peng Tao
2017-05-03 18:15 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).