linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: support specify probe type of build-in driver
@ 2023-06-06  5:12 Jianlin Lv
  2023-06-06 17:38 ` Bart Van Assche
  2023-06-07 14:10 ` Christoph Hellwig
  0 siblings, 2 replies; 9+ messages in thread
From: Jianlin Lv @ 2023-06-06  5:12 UTC (permalink / raw)
  To: jejb, martin.petersen, paulmck, bp, peterz, will, rdunlap,
	kim.phillips, rostedt, wyes.karny
  Cc: iecedge, jianlv, linux-kernel, linux-doc, linux-scsi

When SCSI disks are located on different SCSI hosts within a system,
asynchronous detection can lead to non-deterministic SCSI disk names.

This patch introduces the 'sd_probe_type=' kernel boot parameter.

In scenarios where SCSI disk name sensitivity is crucial, the probe type
of the build-in sd driver can be set to synchronous. As a result,
the scsi disk names are deterministic.

Signed-off-by: Jianlin Lv <iecedge@gmail.com>
---
 .../admin-guide/kernel-parameters.txt         |  9 ++++++++
 drivers/scsi/sd.c                             | 23 +++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 9e5bab29685f..083f741d63bb 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5611,6 +5611,15 @@
 			non-zero "wait" parameter.  See weight_single
 			and weight_many.
 
+	sd_probe_type=	[HW,SCSI] Manual setup probe type of built-in scsi disk driver
+			Format: <int>
+			Default: 1
+			<int> -- device driver probe type to try
+				0 - PROBE_DEFAULT_STRATEGY
+				1 - PROBE_PREFER_ASYNCHRONOUS
+				2 - PROBE_FORCE_SYNCHRONOUS
+			Example: sd_probe_type=1
+
 	skew_tick=	[KNL] Offset the periodic timer tick per cpu to mitigate
 			xtime_lock contention on larger systems, and/or RCU lock
 			contention on all systems with CONFIG_MAXSMP set.
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1624d528aa1f..78b80b9e5618 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -121,6 +121,9 @@ static void scsi_disk_release(struct device *cdev);
 
 static DEFINE_IDA(sd_index_ida);
 
+/* Probe type of SCSI Disk Driver */
+static int sd_probe_type = PROBE_PREFER_ASYNCHRONOUS;
+
 static mempool_t *sd_page_pool;
 static struct lock_class_key sd_bio_compl_lkclass;
 
@@ -3826,6 +3829,25 @@ static int sd_resume_runtime(struct device *dev)
 	return sd_resume(dev);
 }
 
+#ifndef MODULE
+
+/* Set the boot options to sd driver.
+ * Syntax is defined in Documentation/admin-guide/kernel-parameters.txt.
+ */
+static int __init sd_probe_setup(char *str)
+{
+	int probe_type = -1;
+
+	if (get_option(&str, &probe_type) && probe_type >= 0 && probe_type < 3)
+		sd_probe_type = probe_type;
+
+	return 1;
+}
+
+__setup("sd_probe_type=", sd_probe_setup);
+
+#endif
+
 /**
  *	init_sd - entry point for this driver (both when built in or when
  *	a module).
@@ -3858,6 +3880,7 @@ static int __init init_sd(void)
 		goto err_out_class;
 	}
 
+	sd_template.gendrv.probe_type = sd_probe_type;
 	err = scsi_register_driver(&sd_template.gendrv);
 	if (err)
 		goto err_out_driver;
-- 
2.25.1


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

end of thread, other threads:[~2023-06-24 11:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06  5:12 [PATCH] scsi: sd: support specify probe type of build-in driver Jianlin Lv
2023-06-06 17:38 ` Bart Van Assche
2023-06-07 15:55   ` Jianlin Lv
2023-06-07 17:07     ` Bart Van Assche
2023-06-08  2:51       ` Jianlin Lv
2023-06-08 16:23         ` Bart Van Assche
2023-06-24 11:45           ` Jianlin Lv
2023-06-07 14:10 ` Christoph Hellwig
2023-06-08  3:10   ` Jianlin Lv

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).