Skip to contentSkip to conversation

scsi: disable automatic target scan

PATCH Applied Hannes Reinecke 6 participants 14 messages Mar 17, 2016 – Apr 5, 2016

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 scsi: disable automatic target scan

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

---
 drivers/infiniband/ulp/srp/ib_srp.c |  2 +-
 drivers/message/fusion/mptspi.c     |  2 +-
 drivers/s390/scsi/zfcp_unit.c       |  3 ++-
 drivers/scsi/scsi_priv.h            |  2 +-
 drivers/scsi/scsi_proc.c            |  3 ++-
 drivers/scsi/scsi_scan.c            | 44 +++++++++++++++++++++++++------------
 drivers/scsi/scsi_sysfs.c           |  3 ++-
 drivers/scsi/scsi_transport_fc.c    |  6 +++--
 drivers/scsi/scsi_transport_iscsi.c |  5 ++++-
 drivers/scsi/scsi_transport_sas.c   |  7 +++---
 drivers/scsi/snic/snic_disc.c       |  2 +-
 include/scsi/scsi_device.h          |  9 +++++++-
 12 files changed, 60 insertions(+), 28 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -1
index 03022f6..1f97381 100644
@@ -2851,7 +2851,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
 	spin_unlock(&host->target_lock);
 
 	scsi_scan_target(&target->scsi_host->shost_gendev,
-			 0, target->scsi_id, SCAN_WILD_CARD, 0);
+			 0, target->scsi_id, SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
 
 	if (srp_connected_ch(target) < target->ch_count ||
 	    target->qp_in_error) {
drivers/message/fusion/mptspi.c +1 -1
index 613231c..031e088 100644
@@ -1150,7 +1150,7 @@ static void mpt_work_wrapper(struct work_struct *work)
 	}
 	shost_printk(KERN_INFO, shost, MYIOC_s_FMT
 	    "Integrated RAID detects new device %d\n", ioc->name, disk);
-	scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1);
+	scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, SCSI_SCAN_RESCAN);
 }
 
 
drivers/s390/scsi/zfcp_unit.c +2 -1
index 157d3d2..08bba7c 100644
@@ -26,7 +26,8 @@ void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
 	lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
 
 	if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
-		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun, 1);
+		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun,
+				 SCSI_SCAN_RESCAN);
 }
 
 static void zfcp_unit_scsi_scan_work(struct work_struct *work)
drivers/scsi/scsi_priv.h +1 -1
index 27b4d0a..57a4b99 100644
@@ -116,7 +116,7 @@ extern void scsi_exit_procfs(void);
 extern char scsi_scan_type[];
 extern int scsi_complete_async_scans(void);
 extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
-				   unsigned int, u64, int);
+				   unsigned int, u64, enum scsi_scan_mode);
 extern void scsi_forget_host(struct Scsi_Host *);
 extern void scsi_rescan_device(struct device *);
 
drivers/scsi/scsi_proc.c +2 -1
index 251598e..7a74b82 100644
@@ -251,7 +251,8 @@ static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
 	if (shost->transportt->user_scan)
 		error = shost->transportt->user_scan(shost, channel, id, lun);
 	else
-		error = scsi_scan_host_selected(shost, channel, id, lun, 1);
+		error = scsi_scan_host_selected(shost, channel, id, lun,
+						SCSI_SCAN_MANUAL);
 	scsi_host_put(shost);
 	return error;
 }
drivers/scsi/scsi_scan.c +30 -14

123 lines not on this page · raw message

drivers/scsi/scsi_sysfs.c +2 -1
index 92ffd24..3b2045f 100644
@@ -143,7 +143,8 @@ static int scsi_scan(struct Scsi_Host *shost, const char *str)
 	if (shost->transportt->user_scan)
 		res = shost->transportt->user_scan(shost, channel, id, lun);
 	else
-		res = scsi_scan_host_selected(shost, channel, id, lun, 1);
+		res = scsi_scan_host_selected(shost, channel, id, lun,
+					      SCSI_SCAN_MANUAL);
 	return res;
 }
 
drivers/scsi/scsi_transport_fc.c +4 -2
index 8a88226..bf28c68 100644
@@ -2110,7 +2110,8 @@ fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, uint id, u64 lun)
 		if ((channel == rport->channel) &&
 		    (id == rport->scsi_target_id)) {
 			spin_unlock_irqrestore(shost->host_lock, flags);
-			scsi_scan_target(&rport->dev, channel, id, lun, 1);
+			scsi_scan_target(&rport->dev, channel, id, lun,
+					 SCSI_SCAN_MANUAL);
 			return;
 		}
 	}
@@ -3277,7 +3278,8 @@ fc_scsi_scan_rport(struct work_struct *work)
 	    (rport->roles & FC_PORT_ROLE_FCP_TARGET) &&
 	    !(i->f->disable_target_scan)) {
 		scsi_scan_target(&rport->dev, rport->channel,
-			rport->scsi_target_id, SCAN_WILD_CARD, 1);
+				 rport->scsi_target_id, SCAN_WILD_CARD,
+				 SCSI_SCAN_RESCAN);
 	}
 
 	spin_lock_irqsave(shost->host_lock, flags);
drivers/scsi/scsi_transport_iscsi.c +4 -1
index 4414816..7a759a9 100644
@@ -1783,6 +1783,7 @@ struct iscsi_scan_data {
 	unsigned int channel;
 	unsigned int id;
 	u64 lun;
+	enum scsi_scan_mode rescan;
 };
 
 static int iscsi_user_scan_session(struct device *dev, void *data)
@@ -1819,7 +1820,7 @@ static int iscsi_user_scan_session(struct device *dev, void *data)
 		    (scan_data->id == SCAN_WILD_CARD ||
 		     scan_data->id == id))
 			scsi_scan_target(&session->dev, 0, id,
-					 scan_data->lun, 1);
+					 scan_data->lun, scan_data->rescan);
 	}
 
 user_scan_exit:
@@ -1836,6 +1837,7 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
 	scan_data.channel = channel;
 	scan_data.id = id;
 	scan_data.lun = lun;
+	scan_data.rescan = SCSI_SCAN_MANUAL;
 
 	return device_for_each_child(&shost->shost_gendev, &scan_data,
 				     iscsi_user_scan_session);
@@ -1852,6 +1854,7 @@ static void iscsi_scan_session(struct work_struct *work)
 	scan_data.channel = 0;
 	scan_data.id = SCAN_WILD_CARD;
 	scan_data.lun = SCAN_WILD_CARD;
+	scan_data.rescan = SCSI_SCAN_RESCAN;
 
 	iscsi_user_scan_session(&session->dev, &scan_data);
 	atomic_dec(&ihost->nr_scans);
drivers/scsi/scsi_transport_sas.c +4 -3
index b6f958193..3f0ff07 100644
@@ -1614,7 +1614,8 @@ int sas_rphy_add(struct sas_rphy *rphy)
 		else
 			lun = 0;
 
-		scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun, 0);
+		scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun,
+				 SCSI_SCAN_INITIAL);
 	}
 
 	return 0;
@@ -1739,8 +1740,8 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel,
 
 		if ((channel == SCAN_WILD_CARD || channel == 0) &&
 		    (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
-			scsi_scan_target(&rphy->dev, 0,
-					 rphy->scsi_target_id, lun, 1);
+			scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
+					 lun, SCSI_SCAN_MANUAL);
 		}
 	}
 	mutex_unlock(&sas_host->lock);
drivers/scsi/snic/snic_disc.c +1 -1
index 5f63217..5f48795 100644
@@ -171,7 +171,7 @@ snic_scsi_scan_tgt(struct work_struct *work)
 			 tgt->channel,
 			 tgt->scsi_tgt_id,
 			 SCAN_WILD_CARD,
-			 1);
+			 SCSI_SCAN_RESCAN);
 
 	spin_lock_irqsave(shost->host_lock, flags);
 	tgt->flags &= ~SNIC_TGT_SCAN_PENDING;
include/scsi/scsi_device.h +8 -1
index c067019..61341d3 100644
@@ -50,6 +50,12 @@ enum scsi_device_state {
 	SDEV_CREATED_BLOCK,	/* same as above but for created devices */
 };
 
+enum scsi_scan_mode {
+	SCSI_SCAN_INITIAL = 0,
+	SCSI_SCAN_RESCAN,
+	SCSI_SCAN_MANUAL,
+};
+
 enum scsi_device_event {
 	SDEV_EVT_MEDIA_CHANGE	= 1,	/* media has changed */
 	SDEV_EVT_INQUIRY_CHANGE_REPORTED,		/* 3F 03  UA reported */
@@ -391,7 +397,8 @@ extern void scsi_device_resume(struct scsi_device *sdev);
 extern void scsi_target_quiesce(struct scsi_target *);
 extern void scsi_target_resume(struct scsi_target *);
 extern void scsi_scan_target(struct device *parent, unsigned int channel,
-			     unsigned int id, u64 lun, int rescan);
+			     unsigned int id, u64 lun,
+			     enum scsi_scan_mode rescan);
 extern void scsi_target_reap(struct scsi_target *);
 extern void scsi_target_block(struct device *);
 extern void scsi_target_unblock(struct device *, enum scsi_device_state);
Signature · 1 line
1.8.5.6
Reviewed-by on v3 1/1
#1 lore raw
Quoted 363 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

---
 drivers/infiniband/ulp/srp/ib_srp.c |  2 +-
 drivers/message/fusion/mptspi.c     |  2 +-
 drivers/s390/scsi/zfcp_unit.c       |  3 ++-
 drivers/scsi/scsi_priv.h            |  2 +-
 drivers/scsi/scsi_proc.c            |  3 ++-
 drivers/scsi/scsi_scan.c            | 44 +++++++++++++++++++++++++------------
 drivers/scsi/scsi_sysfs.c           |  3 ++-
 drivers/scsi/scsi_transport_fc.c    |  6 +++--
 drivers/scsi/scsi_transport_iscsi.c |  5 ++++-
 drivers/scsi/scsi_transport_sas.c   |  7 +++---
 drivers/scsi/snic/snic_disc.c       |  2 +-
 include/scsi/scsi_device.h          |  9 +++++++-
 12 files changed, 60 insertions(+), 28 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -1
index 03022f6..1f97381 100644
@@ -2851,7 +2851,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
 	spin_unlock(&host->target_lock);
 
 	scsi_scan_target(&target->scsi_host->shost_gendev,
-			 0, target->scsi_id, SCAN_WILD_CARD, 0);
+			 0, target->scsi_id, SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
 
 	if (srp_connected_ch(target) < target->ch_count ||
 	    target->qp_in_error) {
drivers/message/fusion/mptspi.c +1 -1
index 613231c..031e088 100644
@@ -1150,7 +1150,7 @@ static void mpt_work_wrapper(struct work_struct *work)
 	}
 	shost_printk(KERN_INFO, shost, MYIOC_s_FMT
 	    "Integrated RAID detects new device %d\n", ioc->name, disk);
-	scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, 1);
+	scsi_scan_target(&ioc->sh->shost_gendev, 1, disk, 0, SCSI_SCAN_RESCAN);
 }
 
 
drivers/s390/scsi/zfcp_unit.c +2 -1
index 157d3d2..08bba7c 100644
@@ -26,7 +26,8 @@ void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
 	lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
 
 	if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
-		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun, 1);
+		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun,
+				 SCSI_SCAN_RESCAN);
 }
 
 static void zfcp_unit_scsi_scan_work(struct work_struct *work)
drivers/scsi/scsi_priv.h +1 -1
index 27b4d0a..57a4b99 100644
@@ -116,7 +116,7 @@ extern void scsi_exit_procfs(void);
 extern char scsi_scan_type[];
 extern int scsi_complete_async_scans(void);
 extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
-				   unsigned int, u64, int);
+				   unsigned int, u64, enum scsi_scan_mode);
 extern void scsi_forget_host(struct Scsi_Host *);
 extern void scsi_rescan_device(struct device *);
 
drivers/scsi/scsi_proc.c +2 -1
index 251598e..7a74b82 100644
@@ -251,7 +251,8 @@ static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
 	if (shost->transportt->user_scan)
 		error = shost->transportt->user_scan(shost, channel, id, lun);
 	else
-		error = scsi_scan_host_selected(shost, channel, id, lun, 1);
+		error = scsi_scan_host_selected(shost, channel, id, lun,
+						SCSI_SCAN_MANUAL);
 	scsi_host_put(shost);
 	return error;
 }
drivers/scsi/scsi_scan.c +30 -14
index 97074c9..6c8ad36 100644
@@ -96,10 +96,13 @@ MODULE_PARM_DESC(max_luns,
 #define SCSI_SCAN_TYPE_DEFAULT "sync"
 #endif
 
-char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT;
+char scsi_scan_type[7] = SCSI_SCAN_TYPE_DEFAULT;
 
-module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO);
-MODULE_PARM_DESC(scan, "sync, async or none");
+module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type),
+		    S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(scan, "sync, async, manual, or none. "
+		 "Setting to 'manual' disables automatic scanning, but allows "
+		 "for manual device scan via the 'scan' sysfs attribute.");
 
 static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ + 18;
 
@@ -1040,7 +1043,8 @@ static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq,
  * @lun:	LUN of target device
  * @bflagsp:	store bflags here if not NULL
  * @sdevp:	probe the LUN corresponding to this scsi_device
- * @rescan:     if nonzero skip some code only needed on first scan
+ * @rescan:     if not equal to SCSI_SCAN_INITIAL skip some code only
+ *              needed on first scan
  * @hostdata:	passed to scsi_alloc_sdev()
  *
  * Description:
@@ -1055,7 +1059,8 @@ static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq,
  **/
 static int scsi_probe_and_add_lun(struct scsi_target *starget,
 				  u64 lun, int *bflagsp,
-				  struct scsi_device **sdevp, int rescan,
+				  struct scsi_device **sdevp,
+				  enum scsi_scan_mode rescan,
 				  void *hostdata)
 {
 	struct scsi_device *sdev;
@@ -1069,7 +1074,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
 	 */
 	sdev = scsi_device_lookup_by_target(starget, lun);
 	if (sdev) {
-		if (rescan || !scsi_device_created(sdev)) {
+		if (rescan != SCSI_SCAN_INITIAL || !scsi_device_created(sdev)) {
 			SCSI_LOG_SCAN_BUS(3, sdev_printk(KERN_INFO, sdev,
 				"scsi scan: device exists on %s\n",
 				dev_name(&sdev->sdev_gendev)));
@@ -1205,7 +1210,8 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
  *     Modifies sdevscan->lun.
  **/
 static void scsi_sequential_lun_scan(struct scsi_target *starget,
-				     int bflags, int scsi_level, int rescan)
+				     int bflags, int scsi_level,
+				     enum scsi_scan_mode rescan)
 {
 	uint max_dev_lun;
 	u64 sparse_lun, lun;
@@ -1300,7 +1306,7 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
  *     1: could not scan with REPORT LUN
  **/
 static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
-				int rescan)
+				enum scsi_scan_mode rescan)
 {
 	char devname[64];
 	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
@@ -1546,7 +1552,7 @@ void scsi_rescan_device(struct device *dev)
 EXPORT_SYMBOL(scsi_rescan_device);
 
 static void __scsi_scan_target(struct device *parent, unsigned int channel,
-		unsigned int id, u64 lun, int rescan)
+		unsigned int id, u64 lun, enum scsi_scan_mode rescan)
 {
 	struct Scsi_Host *shost = dev_to_shost(parent);
 	int bflags = 0;
@@ -1604,7 +1610,10 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
  * @channel:	channel to scan
  * @id:		target id to scan
  * @lun:	Specific LUN to scan or SCAN_WILD_CARD
- * @rescan:	passed to LUN scanning routines
+ * @rescan:	passed to LUN scanning routines; SCSI_SCAN_INITIAL for
+ *              no rescan, SCSI_SCAN_RESCAN to rescan existing LUNs,
+ *              and SCSI_SCAN_MANUAL to force scanning even if
+ *              'scan=manual' is set.
  *
  * Description:
  *     Scan the target id on @parent, @channel, and @id. Scan at least LUN 0,
@@ -1614,13 +1623,17 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
  *     sequential scan of LUNs on the target id.
  **/
 void scsi_scan_target(struct device *parent, unsigned int channel,
-		      unsigned int id, u64 lun, int rescan)
+		      unsigned int id, u64 lun, enum scsi_scan_mode rescan)
 {
 	struct Scsi_Host *shost = dev_to_shost(parent);
 
 	if (strncmp(scsi_scan_type, "none", 4) == 0)
 		return;
 
+	if (rescan != SCSI_SCAN_MANUAL &&
+	    strncmp(scsi_scan_type, "manual", 6) == 0)
+		return;
+
 	mutex_lock(&shost->scan_mutex);
 	if (!shost->async_scan)
 		scsi_complete_async_scans();
@@ -1634,7 +1647,8 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
 EXPORT_SYMBOL(scsi_scan_target);
 
 static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
-			      unsigned int id, u64 lun, int rescan)
+			      unsigned int id, u64 lun,
+			      enum scsi_scan_mode rescan)
 {
 	uint order_id;
 
@@ -1665,7 +1679,8 @@ static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
 }
 
 int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
-			    unsigned int id, u64 lun, int rescan)
+			    unsigned int id, u64 lun,
+			    enum scsi_scan_mode rescan)
 {
 	SCSI_LOG_SCAN_BUS(3, shost_printk (KERN_INFO, shost,
 		"%s: <%u:%u:%llu>\n",
@@ -1844,7 +1859,8 @@ void scsi_scan_host(struct Scsi_Host *shost)
 {
 	struct async_scan_data *data;
 
-	if (strncmp(scsi_scan_type, "none", 4) == 0)
+	if (strncmp(scsi_scan_type, "none", 4) == 0 ||
+	    strncmp(scsi_scan_type, "manual", 6) == 0)
 		return;
 	if (scsi_autopm_get_host(shost) < 0)
 		return;
drivers/scsi/scsi_sysfs.c +2 -1
index 92ffd24..3b2045f 100644
@@ -143,7 +143,8 @@ static int scsi_scan(struct Scsi_Host *shost, const char *str)
 	if (shost->transportt->user_scan)
 		res = shost->transportt->user_scan(shost, channel, id, lun);
 	else
-		res = scsi_scan_host_selected(shost, channel, id, lun, 1);
+		res = scsi_scan_host_selected(shost, channel, id, lun,
+					      SCSI_SCAN_MANUAL);
 	return res;
 }
 
drivers/scsi/scsi_transport_fc.c +4 -2
index 8a88226..bf28c68 100644
@@ -2110,7 +2110,8 @@ fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, uint id, u64 lun)
 		if ((channel == rport->channel) &&
 		    (id == rport->scsi_target_id)) {
 			spin_unlock_irqrestore(shost->host_lock, flags);
-			scsi_scan_target(&rport->dev, channel, id, lun, 1);
+			scsi_scan_target(&rport->dev, channel, id, lun,
+					 SCSI_SCAN_MANUAL);
 			return;
 		}
 	}
@@ -3277,7 +3278,8 @@ fc_scsi_scan_rport(struct work_struct *work)
 	    (rport->roles & FC_PORT_ROLE_FCP_TARGET) &&
 	    !(i->f->disable_target_scan)) {
 		scsi_scan_target(&rport->dev, rport->channel,
-			rport->scsi_target_id, SCAN_WILD_CARD, 1);
+				 rport->scsi_target_id, SCAN_WILD_CARD,
+				 SCSI_SCAN_RESCAN);
 	}
 
 	spin_lock_irqsave(shost->host_lock, flags);
drivers/scsi/scsi_transport_iscsi.c +4 -1
index 4414816..7a759a9 100644
@@ -1783,6 +1783,7 @@ struct iscsi_scan_data {
 	unsigned int channel;
 	unsigned int id;
 	u64 lun;
+	enum scsi_scan_mode rescan;
 };
 
 static int iscsi_user_scan_session(struct device *dev, void *data)
@@ -1819,7 +1820,7 @@ static int iscsi_user_scan_session(struct device *dev, void *data)
 		    (scan_data->id == SCAN_WILD_CARD ||
 		     scan_data->id == id))
 			scsi_scan_target(&session->dev, 0, id,
-					 scan_data->lun, 1);
+					 scan_data->lun, scan_data->rescan);
 	}
 
 user_scan_exit:
@@ -1836,6 +1837,7 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
 	scan_data.channel = channel;
 	scan_data.id = id;
 	scan_data.lun = lun;
+	scan_data.rescan = SCSI_SCAN_MANUAL;
 
 	return device_for_each_child(&shost->shost_gendev, &scan_data,
 				     iscsi_user_scan_session);
@@ -1852,6 +1854,7 @@ static void iscsi_scan_session(struct work_struct *work)
 	scan_data.channel = 0;
 	scan_data.id = SCAN_WILD_CARD;
 	scan_data.lun = SCAN_WILD_CARD;
+	scan_data.rescan = SCSI_SCAN_RESCAN;
 
 	iscsi_user_scan_session(&session->dev, &scan_data);
 	atomic_dec(&ihost->nr_scans);
drivers/scsi/scsi_transport_sas.c +4 -3
index b6f958193..3f0ff07 100644
@@ -1614,7 +1614,8 @@ int sas_rphy_add(struct sas_rphy *rphy)
 		else
 			lun = 0;
 
-		scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun, 0);
+		scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun,
+				 SCSI_SCAN_INITIAL);
 	}
 
 	return 0;
@@ -1739,8 +1740,8 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel,
 
 		if ((channel == SCAN_WILD_CARD || channel == 0) &&
 		    (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
-			scsi_scan_target(&rphy->dev, 0,
-					 rphy->scsi_target_id, lun, 1);
+			scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
+					 lun, SCSI_SCAN_MANUAL);
 		}
 	}
 	mutex_unlock(&sas_host->lock);
drivers/scsi/snic/snic_disc.c +1 -1
index 5f63217..5f48795 100644
@@ -171,7 +171,7 @@ snic_scsi_scan_tgt(struct work_struct *work)
 			 tgt->channel,
 			 tgt->scsi_tgt_id,
 			 SCAN_WILD_CARD,
-			 1);
+			 SCSI_SCAN_RESCAN);
 
 	spin_lock_irqsave(shost->host_lock, flags);
 	tgt->flags &= ~SNIC_TGT_SCAN_PENDING;
include/scsi/scsi_device.h +6 -0
index c067019..61341d3 100644
@@ -50,6 +50,12 @@ enum scsi_device_state {
 	SDEV_CREATED_BLOCK,	/* same as above but for created devices */
 };
 
+enum scsi_scan_mode {
+	SCSI_SCAN_INITIAL = 0,
+	SCSI_SCAN_RESCAN,
+	SCSI_SCAN_MANUAL,
+};
+
 enum scsi_device_event {
 	SDEV_EVT_MEDIA_CHANGE	= 1,	/* media has changed */
 	SDEV_EVT_INQUIRY_CHANGE_REPORTED,		/* 3F 03  UA reported */

include/scsi/scsi_device.h extern void scsi_device_resume(struct scsi_device *sdev); · line 404

Quoted 9 lines
include/scsi/scsi_device.h +2 -1
@@ -391,7 +397,8 @@ extern void scsi_device_resume(struct scsi_device *sdev);
 extern void scsi_target_quiesce(struct scsi_target *);
 extern void scsi_target_resume(struct scsi_target *);
 extern void scsi_scan_target(struct device *parent, unsigned int channel,
-			     unsigned int id, u64 lun, int rescan);
+			     unsigned int id, u64 lun,
+			     enum scsi_scan_mode rescan);
 extern void scsi_target_reap(struct scsi_target *);
 extern void scsi_target_block(struct device *);
 extern void scsi_target_unblock(struct device *, enum scsi_device_state);
#2 lore raw
In reply to Hannes Reinecke
Quoted 9 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a SCSI disk? If not, are there alternatives to this approach? Would it be a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

Thanks,

Bart.

#3 lore raw
Quoted 11 lines · Bart Van Assche
Quoted 9 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Quoted 7 lines

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a SCSI disk? If not, are there alternatives to this approach? Would it be a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

I have a patch for dracut, which will generate udev rules for all devices required for mounting the root fs.
Once the system is booted properly I've got another patch for systemd which switches back to 'normal' scanning (ie by writing 'sync' into /sys/modules/scsi_mod/parameters/scan) and rescan all scsi hosts.

With that there's no need to have any arbitrary limits; only the necessary devices are enabled during boot.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Hi Hannes,

Please share those dracut patches because I want to test this patch series. Which kernel is the diff against for the scan patches.

Thanks

Laurence Oberman
Principal Software Maintenance Engineer
Red Hat Global Support Services

----- Original Message -----
From: "Hannes Reinecke" <[email protected]>
To: "Bart Van Assche" <[email protected]>, "Martin K. Petersen" <[email protected]>
Cc: "Christoph Hellwig" <[email protected]>, "James Bottomley" <[email protected]>, [email protected]
Sent: Saturday, March 19, 2016 11:18:09 AM
Subject: Re: [PATCHv3] scsi: disable automatic target scan

Quoted 11 lines · Bart Van Assche
Quoted 9 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Quoted 7 lines

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a SCSI disk? If not, are there alternatives to this approach? Would it be a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

I have a patch for dracut, which will generate udev rules for all devices required for mounting the root fs.
Once the system is booted properly I've got another patch for systemd which switches back to 'normal' scanning (ie by writing 'sync' into /sys/modules/scsi_mod/parameters/scan) and rescan all scsi hosts.

With that there's no need to have any arbitrary limits; only the necessary devices are enabled during boot.

Cheers,

Hannes

Signature · 12 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
In reply to Hannes Reinecke
Quoted 19 lines · Hannes Reinecke
Quoted 11 lines · Bart Van Assche
Quoted 9 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Quoted 7 lines

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a SCSI disk? If not, are there alternatives to this approach? Would it be a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

Quoted 8 lines

I have a patch for dracut, which will generate udev rules for all devices required for mounting the root fs.
Once the system is booted properly I've got another patch for systemd which switches back to 'normal' scanning (ie by writing 'sync' into /sys/modules/scsi_mod/parameters/scan) and rescan all scsi hosts.

With that there's no need to have any arbitrary limits; only the necessary devices are enabled during boot.

Hello Hannes,

That sounds like a really interesting approach. Will this approach also work if the SCSI host and/or LUN numbers change during a reboot?

Thanks,

Bart.

#6 lore raw
Quoted 29 lines · Bart Van Assche
Quoted 28 lines · Hannes Reinecke
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan'
value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Quoted 9 lines

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a
SCSI disk? If not, are there alternatives to this approach? Would it be
a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

I have a patch for dracut, which will generate udev rules for all devices required for mounting the root fs.
Once the system is booted properly I've got another patch for systemd which switches back to 'normal' scanning (ie by writing 'sync' into /sys/modules/scsi_mod/parameters/scan) and rescan all scsi hosts.

Quoted 8 lines
Quoted 2 lines

With that there's no need to have any arbitrary limits; only the necessary devices are enabled during boot.

Hello Hannes,

That sounds like a really interesting approach. Will this approach also work if the SCSI host and/or LUN numbers change during a reboot?

It's independent on the SCSI host as it just looks for the rport ID (FC WWPN, SAS ID, or iSCSI target name). The LUN number, however, is fixed; the whole point of this exercise is that you want to blank out individual LUNs behind a given target.
Hence you need to able to address the LUNs in the first place.

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

Hello Hannes

Please share latest scripts and an example of how you are using them.
I have some scripts from last November, that you posted but I am sure they have changed. If not then I will modify them as appropriate, just let me know.

I have added the patches and booted the system set to async, so before I boot with scsi_mod.scan=manual want to prepare my test system. This feature may be a very useful feature we would want to include in RHEL as we struggle with large LUN boot configurations all the time. When you have time and thanks

Laurence Oberman
Principal Software Maintenance Engineer
Red Hat Global Support Services

----- Original Message -----
From: "Hannes Reinecke" <[email protected]>
To: "Bart Van Assche" <[email protected]>, "Martin K. Petersen" <[email protected]>
Cc: "Christoph Hellwig" <[email protected]>, "James Bottomley" <[email protected]>, [email protected]
Sent: Monday, March 21, 2016 3:15:10 AM
Subject: Re: [PATCHv3] scsi: disable automatic target scan

Quoted 29 lines · Bart Van Assche
Quoted 28 lines · Hannes Reinecke
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan'
value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Quoted 9 lines

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a
SCSI disk? If not, are there alternatives to this approach? Would it be
a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

I have a patch for dracut, which will generate udev rules for all devices required for mounting the root fs.
Once the system is booted properly I've got another patch for systemd which switches back to 'normal' scanning (ie by writing 'sync' into /sys/modules/scsi_mod/parameters/scan) and rescan all scsi hosts.

Quoted 8 lines
Quoted 2 lines

With that there's no need to have any arbitrary limits; only the necessary devices are enabled during boot.

Hello Hannes,

That sounds like a really interesting approach. Will this approach also work if the SCSI host and/or LUN numbers change during a reboot?

It's independent on the SCSI host as it just looks for the rport ID (FC WWPN, SAS ID, or iSCSI target name). The LUN number, however, is fixed; the whole point of this exercise is that you want to blank out individual LUNs behind a given target.
Hence you need to able to address the LUNs in the first place.

Cheers,

Hannes

Signature · 13 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw
Quoted 10 lines · Laurence Oberman

Hello Hannes

Please share latest scripts and an example of how you are using them.
I have some scripts from last November, that you posted but I am sure they have changed. If not then I will modify them as appropriate, just let me know.

I have added the patches and booted the system set to async, so before I boot with scsi_mod.scan=manual want to prepare my test system.
This feature may be a very useful feature we would want to include in RHEL as we struggle with large LUN boot configurations all the time.

Oh, really? Hardly a surprise.
In fact, I'm constantly surprised that RHEL ships with systemd enabled, apparently without any issues.
Especially in large machines.
As we found to our dismay; I spent about a year to get things running smoothly.
Or, to be precise, running at all.

Anyway.

Attached is the original patch to dracut; please check if it's the correct version (I've changed the 'disabled' to 'manual' for upstream submission).

I haven't included the systemd service; that's actually quite
trivial: reset the scan mode (as it's now writeable) and call rescan-scsi-bus.sh or equivalent.

But please add a 'Tested-by' or equivalent to the upstream patch, to add a bit more urgency to it.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

From 1d427bcf3527ba96828a4bd5231409967ff096b4 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Wed, 11 Nov 2015 12:20:33 +0100
Subject: [PATCH] 95lunmask: Add module to handle LUN masking

Using the module option 'scsi_mod.scan=disabled' this implements LUN masking by selectively enable only those devices required for booting.

References: bsc#954600

---
 modules.d/95lunmask/fc_transport_scan_lun.sh  | 26 ++++++++++
 modules.d/95lunmask/module-setup.sh           | 70 +++++++++++++++++++++++++++
 modules.d/95lunmask/parse-lunmask.sh          | 40 +++++++++++++++
 modules.d/95lunmask/sas_transport_scan_lun.sh | 26 ++++++++++
 4 files changed, 162 insertions(+)
 create mode 100755 modules.d/95lunmask/fc_transport_scan_lun.sh
 create mode 100755 modules.d/95lunmask/module-setup.sh
 create mode 100755 modules.d/95lunmask/parse-lunmask.sh
 create mode 100755 modules.d/95lunmask/sas_transport_scan_lun.sh
modules.d/95lunmask/fc_transport_scan_lun.sh new file +26 -0
new file mode 100755
index 0000000..d9f84a3
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# fc_transport_lun_scan
+#
+# Selectively enable individual LUNs behind an FC remote port
+#
+# ACTION=="add", SUBSYSTEM=="fc_transport", ATTR{port_name}=="wwpn", \
+#    PROGRAM="fc_transport_lun_scan lun"
+#
+
+[ -z $DEVPATH ] && exit 1
+
+if [ -n "$1" ] ; then
+    LUN=$1
+else
+    LUN=-
+fi
+ID=${DEVPATH##*/rport-}
+HOST=${ID%%:*}
+CHANNEL=${ID%%-*}
+CHANNEL=${CHANNEL#*:}
+if [ -f /sys$DEVPATH/scsi_target_id ] ; then
+    TARGET=$(cat /sys$DEVPATH/scsi_target_id)
+fi
+[ -z "$TARGET" ] && exit 1
+echo $CHANNEL $TARGET $LUN > /sys/class/scsi_host/host$HOST/scan
modules.d/95lunmask/module-setup.sh new file +70 -0

70 lines not on this page · raw message

modules.d/95lunmask/parse-lunmask.sh new file +40 -0
new file mode 100755
index 0000000..81dc412
@@ -0,0 +1,40 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+create_udev_rule() {
+    local transport=$1
+    local tgtid=$2
+    local lun=$3
+    local _rule=/etc/udev/rules.d/51-${transport}-lunmask-${tgtid}.rules
+    local _cu_type _dev_type
+
+    [ -e ${_rule} ] && return 0
+
+    if [ ! -f "$_rule" ] ; then
+        if [ "$transport" = "fc" ] ; then
+            cat > $_rule <<EOF
+ACTION=="add", SUBSYSTEM=="fc_remote_ports", ATTR{port_name}=="$tgtid", PROGRAM="fc_transport_scan_lun.sh $lun"
+EOF
+        elif [ "$transport" = "sas" ] ; then
+            cat > $_rule <<EOF
+ACTION=="add", SUBSYSTEM=="sas_device", ATTR{sas_address}=="$tgtid", PROGRAM="sas_transport_scan_lun.sh $lun"
+EOF
+        fi
+    fi
+}
+
+for lunmask_arg in $(getargs rd.lunmask); do
+    (
+        local OLDIFS="$IFS"
+        local IFS=","
+        set $lunmask_arg
+        IFS="$OLDIFS"
+        if [ -d /sys/module/scsi_mod ] ; then
+            echo -n "disabled" > /sys/module/scsi_mod/parameters/scan
+        elif [ ! -f /etc/modprobe.d/95lunmask.conf ] ; then
+            echo "options scsi_mod scan=disabled" > /etc/modprobe.d/95lunmask.conf
+        fi
+        create_udev_rule $1 $2 $3
+    )
+done
modules.d/95lunmask/sas_transport_scan_lun.sh new file +26 -0
new file mode 100755
index 0000000..f7702f8
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# sas_transport_lun_scan
+#
+# Selectively enable individual LUNs behind a SAS end device
+#
+# ACTION=="add", SUBSYSTEM=="sas_transport", ATTR{sas_address}=="sas_addr", \
+#    PROGRAM="sas_transport_lun_scan lun"
+#
+
+[ -z $DEVPATH ] && exit 1
+
+if [ -n "$1" ] ; then
+    LUN=$1
+else
+    LUN=-
+fi
+ID=${DEVPATH##*/end_device-}
+HOST=${ID%%:*}
+CHANNEL=${ID%%-*}
+CHANNEL=${CHANNEL#*:}
+if [ -f /sys$DEVPATH/scsi_target_id ] ; then
+    TARGET=$(cat /sys$DEVPATH/scsi_target_id)
+fi
+[ -z "$TARGET" ] && exit 1
+echo 0 $TARGET $LUN > /sys/class/scsi_host/host$HOST/scan
Signature · 1 line
2.6.2
#9 lore raw
In reply to Laurence Oberman

Hello

Tested Hannes's scan disable patch (subject above) with hpsa module patch below.
Because of the way the hpsa works I created a module that will force the scan when all scans are manual.
I also tested Hannes's patch with boot-from-san via F/C and validated the patch in subject using Hannes's original dracut lunmask patch.

For Hannes's scan disable patch

linux16 /vmlinuz-4.4.5scan root=/dev/mapper/rhel-root ro crashkernel=512M@64M rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap console=ttyS0,115200n8 scsi_mod.scan=manual rd.hpsa=0 rdloaddriver=hpsa

Additional HPSA module for dracut, needs to be cleaned up and reviewed internally here at Red Hat for a separate submission later. Included for others who want to test this.
We need this for hpsa as this is by far the most popular boot controller we face.

06hpsa/hpsa.sh +6 -0
diff -Nurp modules.d.orig/06hpsa/hpsa.sh modules.d/06hpsa/hpsa.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+### hpsa.sh: Called by the parse-hpsa.sh script to create the scan script ###
+### Laurence Oberman [email protected]
+. /lib/dracut-lib.sh
+### The actual script that scans the hpsa for LUNS 
+/bin/sh /sbin/hpsa_scan.sh
06hpsa/module-setup.sh +14 -0
diff -Nurp modules.d.orig/06hpsa/module-setup.sh modules.d/06hpsa/module-setup.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+#### Test the hpsa driver load with scan #####
+#### Laurence Oberman [email protected] 
+### module-setup.sh - Required for every module
+### Standard script invocations required
+check() {
+	return 0
+}
+
+### Install the hpsa.sh in the module directory
+install() {
+	inst_hook cmdline 20 "$moddir/parse-hpsa.sh"
+	inst_simple "$moddir/hpsa.sh" /sbin/hpsa.sh
+}
06hpsa/parse-hpsa.sh +18 -0
diff -Nurp modules.d.orig/06hpsa/parse-hpsa.sh modules.d/06hpsa/parse-hpsa.sh
@@ -0,0 +1,18 @@
+#!/bin.bash
+### Laurence Oberman [email protected]
+### parse-hpsa.sh 
+### Parses the rd.hpsa=x tp get the host number
+### Using rdloaddriver=hpsa will enforce hpsa becoming scsi0
+
+for p in $(getargs rd.hpsa=); do
+(
+     echo "echo 1 > /sys/class/scsi_host/host$p/rescan" > /sbin/hpsa_scan.sh
+    _do_hpsa=1
+)
+done
+
+### Standard way to call the script from udev
+/sbin/initqueue --settled --unique --onetime /bin/sh /sbin/hpsa.sh
+#/bin/sh /sbin/hpsa.sh
+unset _do_hpsa
+

Test log
--------

[    5.591817] HP HPSA Driver (v 3.4.14-0)
[    5.593799] hpsa 0000:05:00.0: can't disable ASPM; OS doesn't have ASPM control
[    5.597423] hpsa 0000:05:00.0: MSI-X capable controller
[    5.600181] hpsa 0000:05:00.0: only 16 MSI-X vectors available
[    5.602995] hpsa 0000:05:00.0: Logical aborts not supported
[    5.606011] hpsa 0000:05:00.0: HP SSD Smart Path aborts not supported
[    5.631300] scsi host0: hpsa

[ OK ] Started dracut pre-udev hook.
Starting udev Kernel Device Manager...
[ OK ] Started udev Kernel Device Manager.
Starting udev Coldplug all Devices...

[    5.676569] clocksource: Switched to clocksource tsc
         Mounting Configuration File System...
[  OK  ] Mounted Configuration File System.
[  OK  ] Started udev Coldplug all Devices.
         Starting dracut initqueue hook...
         Starting Show Plymouth Boot Screen...
[  OK  ] Reached target System Initialization.
[    5.708890] bnx2: QLogic bnx2 Gigabit Ethernet Driver v2.2.6 (January 29, 2014)
[  OK  ] Started Show Plymouth Boot Screen.
[    5.749275] bnx2 0000:03:00.0 eth0: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f4000000, IRQ 16, node addr e4:11:5b:b8:ea:6a
[  OK  ] Reached target Paths.
[  OK  ] Reached target Basic System.
[    5.828145] bnx2 0000:03:00.1 eth1: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f2000000, IRQ 17, node addr e4:11:5b:b8:ea:6c
[    5.905874] bnx2 0000:04:00.0 eth2: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f8000000, IRQ 18, node addr e4:11:5b:b8:ea:6e
[    5.906632] bnx2 0000:04:00.1 eth3: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f6000000, IRQ 19, node addr e4:11:5b:b8:ea:70
[    6.061847] bnx2 0000:04:00.1 enp4s0f1: renamed from eth3
[    6.098914] mlx5_core 0000:08:00.0: firmware version: 12.14.2036
[    6.147046] Emulex LightPulse Fibre Channel SCSI driver 11.0.0.0.
[    6.147054] [drm] Initialized drm 1.1.0 20060810
[    6.147148] qla2xxx [0000:00:00.0]-0005: : QLogic Fibre Channel HBA Driver: 8.07.00.26-k.
[    6.147278] qla2xxx [0000:0e:00.0]-001d: : Found an ISP2432 irq 27 iobase 0xffffc900192b8000.
[    6.147618] qla2xxx [0000:0e:00.0]-0034:1: MSI-X: Unsupported ISP 2432 SSVID/SSDID (0x103C,0x7041).
[    6.352283] Copyright(c) 2004-2015 Emulex.  All rights reserved.
[    6.387626] scsi host2: Emulex LPe1150 PCIe Fibre Channel Adapter on PCI bus 0b device 00 irq 44
[    6.439004] bnx2 0000:04:00.0 enp4s0f0: renamed from eth2
[    6.470541] scsi host1: qla2xxx
[    6.488476] qla2xxx [0000:0e:00.0]-00fb:1: QLogic HPAE312A - PCI-Express Dual Port 4Gb Fibre Channel HBA.
[    6.540692] qla2xxx [0000:0e:00.0]-00fc:1: ISP2432: PCIe (2.5GT/s x4) @ 0000:0e:00.0 hdma+ host#=1 fw=7.03.00 (9496).
[    6.600102] qla2xxx [0000:0e:00.1]-001d: : Found an ISP2432 irq 45 iobase 0xffffc9001929c000.
[    6.648749] qla2xxx [0000:0e:00.1]-0034:3: MSI-X: Unsupported ISP 2432 SSVID/SSDID (0x103C,0x7041).
[    6.666651] mlx5_core 0000:08:00.1: firmware version: 12.14.2036
[    6.772560] bnx2 0000:03:00.0 enp3s0f0: renamed from eth0
[    7.056571] scsi host3: qla2xxx
[    7.074626] qla2xxx [0000:0e:00.1]-00fb:3: QLogic HPAE312A - PCI-Express Dual Port 4Gb Fibre Channel HBA.
[    7.112413] qla2xxx [0000:0e:00.0]-500a:1: LOOP UP detected (4 Gbps).
[    7.164549] qla2xxx [0000:0e:00.1]-00fc:3: ISP2432: PCIe (2.5GT/s x4) @ 0000:0e:00.1 hdma+ host#=3 fw=7.03.00 (9496).
[    7.225561] bnx2 0000:03:00.1 enp3s0f1: renamed from eth1
[    7.263344] [drm] radeon kernel modesetting enabled.
[    7.292316] [drm] initializing kernel modesetting (RV100 0x1002:0x515E 0x103C:0x31FB).
[    7.337153] [drm] register mmio base: 0xF1CF0000
[    7.363142] [drm] register mmio size: 65536
[    7.387189] radeon 0000:01:03.0: VRAM: 128M 0x00000000E0000000 - 0x00000000E7FFFFFF (64M used)
[    7.434215] radeon 0000:01:03.0: GTT: 512M 0x00000000C0000000 - 0x00000000DFFFFFFF
[    7.477250] [drm] Detected VRAM RAM=128M, BAR=128M
[    7.503412] [drm] RAM width 16bits DDR
[    7.524062] [TTM] Zone  kernel: Available graphics memory: 74007530 kiB
[    7.559905] [TTM] Zone   dma32: Available graphics memory: 2097152 kiB
[    7.595353] [TTM] Initializing pool allocator
[    7.619344] [TTM] Initializing DMA pool allocator
[    7.645975] [drm] radeon: 64M of VRAM memory ready
[    7.672908] [drm] radeon: 512M of GTT memory ready.
[    7.673258] mlx5_ib: Mellanox Connect-IB Infiniband driver v2.2-1 (Feb 2014)
[    7.699187] qla2xxx [0000:0e:00.1]-500a:3: LOOP UP detected (4 Gbps).
[    7.776438] [drm] GART: num cpu pages 131072, num gpu pages 131072
[    7.832626] [drm] PCI GART of 512M enabled (table at 0x0000000031200000).
[    7.870378] radeon 0000:01:03.0: WB disabled
[    7.893537] radeon 0000:01:03.0: fence driver on ring 0 use gpu addr 0x00000000c0000000 and cpu addr 0xffff880031070000
[    7.953875] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    7.990946] [drm] Driver supports precise vblank timestamp query.
[    7.997365] random: nonblocking pool is initialized
[    8.055710] [drm] radeon: irq initialized.
[    8.078772] [drm] Loading R100 Microcode
[    8.101197] [drm] radeon: ring at 0x00000000C0001000
[    8.129891] [drm] ring test succeeded in 1 usecs
[    8.655299] [drm] ib test succeeded in 0 usecs
[    8.678602] [drm] No TV DAC info found in BIOS
[    8.702772] [drm] Radeon Display Connectors
[    8.726801] [drm] Connector 0:
[    8.744275] [drm]   VGA-1
[    8.759047] [drm]   DDC: 0x60 0x60 0x60 0x60 0x60 0x60 0x60 0x60
[    8.793773] [drm]   Encoders:
[    8.811874] [drm]     CRT1: INTERNAL_DAC1
[    8.834626] [drm] Connector 1:
[    8.851683] [drm]   VGA-2
[    8.866289] [drm]   DDC: 0x6c 0x6c 0x6c 0x6c 0x6c 0x6c 0x6c 0x6c
[    8.899111] [drm]   Encoders:
[    8.914856] [drm]     CRT2: INTERNAL_DAC2
[    8.973015] [drm] fb mappable at 0xE0040000
[    8.996545] [drm] vram apper at 0xE0000000
[    9.019109] [drm] size 786432
[    9.035977] [drm] fb depth is 8
[    9.053620] [drm]    pitch is 1024
[    9.072966] fbcon: radeondrmfb (fb0) is primary device
[    9.228858] Console: switching to colour frame buffer device 128x48
[    9.300257] radeon 0000:01:03.0: fb0: radeondrmfb frame buffer device
[    9.349479] [drm] Initialized radeon 2.43.0 20080528 for 0000:01:03.0 on minor 0
[   10.032430] hpsa 0000:05:00.0: scsi 0:3:0:0: added RAID              HP       P410i            controller SSDSmartPathCap- En- Exp=1
[   10.098586] hpsa 0000:05:00.0: scsi 0:0:0:0: masked Direct-Access     HP       DG146BB976       PHYS DRV SSDSmartPathCap- En- Exp=0
[   10.166547] hpsa 0000:05:00.0: scsi 0:1:0:0: added Direct-Access     HP       LOGICAL VOLUME   RAID-0 SSDSmartPathCap- En- Exp=1
[   10.233884] scsi 0:1:0:0: Direct-Access     HP       LOGICAL VOLUME   6.40 PQ: 0 ANSI: 5
[   10.294476] sd 0:1:0:0: [sda] 286677120 512-byte logical blocks: (147 GB/137 GiB)
[   10.337955] sd 0:1:0:0: [sda] Write Protect is off
[   10.365772] sd 0:1:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   10.387947] lpfc 0000:0b:00.0: 0:1303 Link Up Event x1 received Data: x1 xf7 x10 x0 x0 x0 0
[   10.464599]  sda: sda1 sda2
[   10.481480] sd 0:1:0:0: [sda] Attached SCSI disk

[ OK ] Found device /dev/mapper/rhel-root.
Starting File System Check on /dev/mapper/rhel-root...
[ OK ] Started File System Check on /dev/mapper/rhel-root. ..
,,

Laurence Oberman
Principal Software Maintenance Engineer
Red Hat Global Support Services

----- Original Message -----
From: "Laurence Oberman" <[email protected]>
To: "Hannes Reinecke" <[email protected]>
Cc: "Bart Van Assche" <[email protected]>, "Martin K. Petersen" <[email protected]>, "Christoph Hellwig" <[email protected]>, "James Bottomley" <[email protected]>, [email protected]
Sent: Monday, March 21, 2016 4:40:57 PM
Subject: Re: [PATCHv3] scsi: disable automatic target scan

Hello Hannes

Please share latest scripts and an example of how you are using them.
I have some scripts from last November, that you posted but I am sure they have changed. If not then I will modify them as appropriate, just let me know.

I have added the patches and booted the system set to async, so before I boot with scsi_mod.scan=manual want to prepare my test system. This feature may be a very useful feature we would want to include in RHEL as we struggle with large LUN boot configurations all the time. When you have time and thanks

Laurence Oberman
Principal Software Maintenance Engineer
Red Hat Global Support Services

----- Original Message -----
From: "Hannes Reinecke" <[email protected]>
To: "Bart Van Assche" <[email protected]>, "Martin K. Petersen" <[email protected]>
Cc: "Christoph Hellwig" <[email protected]>, "James Bottomley" <[email protected]>, [email protected]
Sent: Monday, March 21, 2016 3:15:10 AM
Subject: Re: [PATCHv3] scsi: disable automatic target scan

Quoted 29 lines · Bart Van Assche
Quoted 28 lines · Hannes Reinecke
Quoted 12 lines · Bart Van Assche
Quoted 10 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan'
value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

Quoted 9 lines

Hello Hannes,

Will setting scsi_scan_type to 'manual' allow a system to boot from a
SCSI disk? If not, are there alternatives to this approach? Would it be
a valid alternative to e.g. introduce a new threshold parameter such that only LUN numbers below this threshold are scanned during boot?

I have a patch for dracut, which will generate udev rules for all devices required for mounting the root fs.
Once the system is booted properly I've got another patch for systemd which switches back to 'normal' scanning (ie by writing 'sync' into /sys/modules/scsi_mod/parameters/scan) and rescan all scsi hosts.

Quoted 8 lines
Quoted 2 lines

With that there's no need to have any arbitrary limits; only the necessary devices are enabled during boot.

Hello Hannes,

That sounds like a really interesting approach. Will this approach also work if the SCSI host and/or LUN numbers change during a reboot?

It's independent on the SCSI host as it just looks for the rport ID (FC WWPN, SAS ID, or iSCSI target name). The LUN number, however, is fixed; the whole point of this exercise is that you want to blank out individual LUNs behind a given target.
Hence you need to able to address the LUNs in the first place.

Cheers,

Hannes

Signature · 17 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw
In reply to Hannes Reinecke
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Hannes" == Hannes Reinecke <[email protected]> writes:

Hannes> On larger installations it is useful to disable automatic LUN Hannes> scanning, and only add the required LUNs via udev rules. This Hannes> can speed up bootup dramatically.

Hannes> This patch introduces a new scan module parameter value Hannes> 'manual', which works like 'none', but can be overriden by Hannes> setting the 'rescan' value from scsi_scan_target to Hannes> 'SCSI_SCAN_MANUAL'. And it updates all relevant callers to set Hannes> the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the Hannes> 'scan' option in sysfs.

Applied to 4.7/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#11 lore raw
In reply to Hannes Reinecke

Hello Hannes,

I am a bit late here, but as this got pulled and Steffen didn't have time to give it a review, I did today.

Quoted 4 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

Quoted 8 lines

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

---

[:snip:]

drivers/s390/scsi/zfcp_unit.c void zfcp_unit_scsi_scan(struct zfcp_unit *unit) · line 30

Quoted 12 lines
drivers/s390/scsi/zfcp_unit.c +2 -1
index 157d3d2..08bba7c 100644
@@ -26,7 +26,8 @@ void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
 	lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
 
 	if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
-		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun, 1);
+		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun,
+				 SCSI_SCAN_RESCAN);

I'd rather use the new SCSI_SCAN_MANUAL here. We don't want this to be "blocked" by an attribute set in a different (new) code-path and config-location.

This path is used by both, zfcp-recovery and -userinterfaces (sysfs) and in both cases we call it with the intend that the scan is really done - hence the SCSI_SCAN_MANUAL to force a scan. I'd find it very weird if suddenly our users would have to additionally use yet an other config to get the old interfaces working properly.

Beste Grüße / Best regards,
- Benjamin Block

Signature · 9 lines
Linux on z Systems Development         /         IBM Systems & Technology Group
		  IBM Deutschland Research & Development GmbH 
Vorsitz. AufsR.: Martina Koederitz     /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
Quoted 38 lines · Benjamin Block

Hello Hannes,

I am a bit late here, but as this got pulled and Steffen didn't have time to give it a review, I did today.

Quoted 4 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

Quoted 8 lines

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

---

[:snip:]

drivers/s390/scsi/zfcp_unit.c void zfcp_unit_scsi_scan(struct zfcp_unit *unit) · line 30

Quoted 12 lines
drivers/s390/scsi/zfcp_unit.c +2 -1
index 157d3d2..08bba7c 100644
@@ -26,7 +26,8 @@ void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
 	lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
 
 	if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
-		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun, 1);
+		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun,
+				 SCSI_SCAN_RESCAN);

I'd rather use the new SCSI_SCAN_MANUAL here. We don't want this to be "blocked" by an attribute set in a different (new) code-path and config-location.

Quoted 6 lines

This path is used by both, zfcp-recovery and -userinterfaces (sysfs) and in both cases we call it with the intend that the scan is really done - hence the SCSI_SCAN_MANUAL to force a scan. I'd find it very weird if suddenly our users would have to additionally use yet an other config to get the old interfaces working properly.

Okay, no problem with that.
zfcp has its own scanning rules (cf allow_lun_scan module parameter), so setting it to 'MANUAL' will just restore the original behaviour.

Will you be sending a patch for it?

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw
Quoted 45 lines · Hannes Reinecke
Quoted 38 lines · Benjamin Block

Hello Hannes,

I am a bit late here, but as this got pulled and Steffen didn't have time to give it a review, I did today.

Quoted 4 lines · Hannes Reinecke

On larger installations it is useful to disable automatic LUN scanning, and only add the required LUNs via udev rules. This can speed up bootup dramatically.

Quoted 8 lines

This patch introduces a new scan module parameter value 'manual', which works like 'none', but can be overriden by setting the 'rescan' value from scsi_scan_target to 'SCSI_SCAN_MANUAL'.
And it updates all relevant callers to set the 'rescan' value to 'SCSI_SCAN_MANUAL' if invoked via the 'scan' option in sysfs.

---

[:snip:]

drivers/s390/scsi/zfcp_unit.c void zfcp_unit_scsi_scan(struct zfcp_unit *unit) · line 30

Quoted 12 lines
drivers/s390/scsi/zfcp_unit.c +2 -1
index 157d3d2..08bba7c 100644
@@ -26,7 +26,8 @@ void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
 	lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
 
 	if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
-		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun, 1);
+		scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun,
+				 SCSI_SCAN_RESCAN);

I'd rather use the new SCSI_SCAN_MANUAL here. We don't want this to be "blocked" by an attribute set in a different (new) code-path and config-location.

Quoted 6 lines

This path is used by both, zfcp-recovery and -userinterfaces (sysfs) and in both cases we call it with the intend that the scan is really done - hence the SCSI_SCAN_MANUAL to force a scan. I'd find it very weird if suddenly our users would have to additionally use yet an other config to get the old interfaces working properly.

Quoted 6 lines

Okay, no problem with that.
zfcp has its own scanning rules (cf allow_lun_scan module parameter), so setting it to 'MANUAL' will just restore the original behaviour.

Will you be sending a patch for it?

Yeah, sry, once I am through our backlog and I find time to test that properly.

Beste Grüße / Best regards,
- Benjamin Block

Signature · 9 lines
Linux on z Systems Development         /         IBM Systems & Technology Group
		  IBM Deutschland Research & Development GmbH 
Vorsitz. AufsR.: Martina Koederitz     /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html