linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: disable automatic target scan
@ 2016-03-11 15:33 Hannes Reinecke
  2016-03-14  8:08 ` Johannes Thumshirn
  2016-03-14 23:57 ` Martin K. Petersen
  0 siblings, 2 replies; 6+ messages in thread
From: Hannes Reinecke @ 2016-03-11 15:33 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, 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 scan_type 'disabled', which work like
'none', but can be overriden by setting the 'rescan' value
from scsi_scan_target to '2'.
And it updates all relevant callers to set the 'rescan' value
to '2' if invoked via the 'scan' option in sysfs.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_scan.c            | 17 ++++++++++++-----
 drivers/scsi/scsi_sysfs.c           |  2 +-
 drivers/scsi/scsi_transport_fc.c    |  2 +-
 drivers/scsi/scsi_transport_iscsi.c |  2 +-
 drivers/scsi/scsi_transport_sas.c   |  2 +-
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 97074c9..929204b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -96,10 +96,11 @@ 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[9] = 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, disabled, or none");
 
 static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ + 18;
 
@@ -1604,7 +1605,9 @@ 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; 0 for no rescan, 1 to rescan
+ *              existing LUNs, and 2 to override any 'scan_disabled' setting
+ *              from the host.
  *
  * Description:
  *     Scan the target id on @parent, @channel, and @id. Scan at least LUN 0,
@@ -1621,6 +1624,9 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
 	if (strncmp(scsi_scan_type, "none", 4) == 0)
 		return;
 
+	if (rescan < 2 && strncmp(scsi_scan_type, "disabled", 8) == 0)
+		return;
+
 	mutex_lock(&shost->scan_mutex);
 	if (!shost->async_scan)
 		scsi_complete_async_scans();
@@ -1844,7 +1850,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, "disabled", 8) == 0)
 		return;
 	if (scsi_autopm_get_host(shost) < 0)
 		return;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 92ffd24..d805d55 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -143,7 +143,7 @@ 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, 2);
 	return res;
 }
 
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 8a88226..018b2da 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2110,7 +2110,7 @@ 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, 2);
 			return;
 		}
 	}
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 4414816..2941598 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1819,7 +1819,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, 2);
 	}
 
 user_scan_exit:
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index deb3fde..1e0664f 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -1740,7 +1740,7 @@ 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);
+					 rphy->scsi_target_id, lun, 2);
 		}
 	}
 	mutex_unlock(&sas_host->lock);
-- 
1.8.5.6


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

* Re: [PATCH] scsi: disable automatic target scan
  2016-03-11 15:33 [PATCH] scsi: disable automatic target scan Hannes Reinecke
@ 2016-03-14  8:08 ` Johannes Thumshirn
  2016-03-14 23:57 ` Martin K. Petersen
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2016-03-14  8:08 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi

On Fri, Mar 11, 2016 at 04:33:40PM +0100, Hannes Reinecke wrote:
> 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 scan_type 'disabled', which work like
> 'none', but can be overriden by setting the 'rescan' value
> from scsi_scan_target to '2'.
> And it updates all relevant callers to set the 'rescan' value
> to '2' if invoked via the 'scan' option in sysfs.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] scsi: disable automatic target scan
  2016-03-11 15:33 [PATCH] scsi: disable automatic target scan Hannes Reinecke
  2016-03-14  8:08 ` Johannes Thumshirn
@ 2016-03-14 23:57 ` Martin K. Petersen
  2016-03-15  6:47   ` Hannes Reinecke
  1 sibling, 1 reply; 6+ messages in thread
From: Martin K. Petersen @ 2016-03-14 23:57 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi

>>>>> "Hannes" == Hannes Reinecke <hare@suse.de> writes:

> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 97074c9..929204b 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -96,10 +96,11 @@ 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[9] = 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, disabled, or none");

So "disabled" is "sometimes enabled" and "none" is "really disabled"?
 
>  static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ + 18;
>  
> @@ -1604,7 +1605,9 @@ 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; 0 for no rescan, 1 to rescan
> + *              existing LUNs, and 2 to override any 'scan_disabled' setting
> + *              from the host.

enum SCSI_SCAN_FOO_BAR instead of magic values, please.

What's this "scan_disabled" setting from the host?

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: disable automatic target scan
  2016-03-14 23:57 ` Martin K. Petersen
@ 2016-03-15  6:47   ` Hannes Reinecke
  2016-03-15  6:48     ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Reinecke @ 2016-03-15  6:47 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Christoph Hellwig, James Bottomley, linux-scsi

On 03/15/2016 12:57 AM, Martin K. Petersen wrote:
>>>>>> "Hannes" == Hannes Reinecke <hare@suse.de> writes:
> 
>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>> index 97074c9..929204b 100644
>> --- a/drivers/scsi/scsi_scan.c
>> +++ b/drivers/scsi/scsi_scan.c
>> @@ -96,10 +96,11 @@ 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[9] = 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, disabled, or none");
> 
> So "disabled" is "sometimes enabled" and "none" is "really disabled"?
>  
'disabled' means:
disable automatic scanning, but allow manual scanning via the 'scan'
attribute.

>>  static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ + 18;
>>  
>> @@ -1604,7 +1605,9 @@ 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; 0 for no rescan, 1 to rescan
>> + *              existing LUNs, and 2 to override any 'scan_disabled' setting
>> + *              from the host.
> 
> enum SCSI_SCAN_FOO_BAR instead of magic values, please.
> 
Okay.

> What's this "scan_disabled" setting from the host?
> 
It's called a 'typo' and found quite frequently in the wilds :-)

I'll be sending a respin.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] scsi: disable automatic target scan
  2016-03-15  6:47   ` Hannes Reinecke
@ 2016-03-15  6:48     ` Christoph Hellwig
  2016-03-15  6:53       ` Hannes Reinecke
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2016-03-15  6:48 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi

On Tue, Mar 15, 2016 at 07:47:34AM +0100, Hannes Reinecke wrote:
> > So "disabled" is "sometimes enabled" and "none" is "really disabled"?
> >  
> 'disabled' means:
> disable automatic scanning, but allow manual scanning via the 'scan'
> attribute.

maybe rename disabled to manual?  And improve the modoule parameter
description while we're at it.

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

* Re: [PATCH] scsi: disable automatic target scan
  2016-03-15  6:48     ` Christoph Hellwig
@ 2016-03-15  6:53       ` Hannes Reinecke
  0 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2016-03-15  6:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Martin K. Petersen, James Bottomley, linux-scsi

On 03/15/2016 07:48 AM, Christoph Hellwig wrote:
> On Tue, Mar 15, 2016 at 07:47:34AM +0100, Hannes Reinecke wrote:
>>> So "disabled" is "sometimes enabled" and "none" is "really disabled"?
>>>  
>> 'disabled' means:
>> disable automatic scanning, but allow manual scanning via the 'scan'
>> attribute.
> 
> maybe rename disabled to manual?  And improve the modoule parameter
> description while we're at it.
> 
Okay, will be doing so.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-03-15  6:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-11 15:33 [PATCH] scsi: disable automatic target scan Hannes Reinecke
2016-03-14  8:08 ` Johannes Thumshirn
2016-03-14 23:57 ` Martin K. Petersen
2016-03-15  6:47   ` Hannes Reinecke
2016-03-15  6:48     ` Christoph Hellwig
2016-03-15  6:53       ` Hannes Reinecke

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