lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1493365699-25566-1-git-send-email-bergwolf@gmail.com>
Date:   Fri, 28 Apr 2017 15:48:19 +0800
From:   Peng Tao <bergwolf@...il.com>
To:     linux-scsi@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, Peng Tao <bergwolf@...il.com>,
        "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>
Subject: [PATCH RFC] scsi: wait sd probing in manual scan

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@...ux.vnet.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@...cle.com>
Signed-off-by: Peng Tao <bergwolf@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ