Re: [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter

2016-03-01 Thread Christoph Hellwig
Bah.  Async scanning seems useful, but it shouldn't be a module option
that breaks exsiting users of the attribute, and it shouldn't be in
the FC transport class.

Just add a new async_scan attribute that works like scan, but works
asynchronously in the core.

Or figure out if we can overload the already parsed but ignored
junk argument in the scan attribute to accept an 'a' for async?
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter

2016-03-01 Thread Johannes Thumshirn
On Mon, Feb 22, 2016 at 08:51:02AM +0100, Hannes Reinecke wrote:
> When invoking a scan via the sysfs 'scan' attribute the process
> will be blocked until the scan is completed, which can take a
> very long time on large installations.
> Enabling the 'async_user_scan' parameter moves the actual
> LUN scanning to a workqueue, thereby unblocking the process.
> 
> Signed-off-by: Hannes Reinecke 

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter

2016-02-29 Thread Seymour, Shane M

Reviewed-by: Shane Seymour 

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


[PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter

2016-02-21 Thread Hannes Reinecke
When invoking a scan via the sysfs 'scan' attribute the process
will be blocked until the scan is completed, which can take a
very long time on large installations.
Enabling the 'async_user_scan' parameter moves the actual
LUN scanning to a workqueue, thereby unblocking the process.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_transport_fc.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 90228b4..3afe60a9 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -82,6 +82,21 @@ MODULE_PARM_DESC(disable_target_scan,
 "Disable target scan on remote ports (default=0)");
 
 /*
+ * async_user_scan: make 'scan' sysfs attribute asynchronous
+ *   on larger installations scanning can take a very long time
+ *   during which the process invoking the scan will be blocked
+ *   on writing to the 'scan' attribute. Enabling this attribute
+ *   will move scanning to a work queue, allowing the process
+ *   to return immediately.
+ */
+static bool fc_async_user_scan;
+
+module_param_named(async_user_scan, fc_async_user_scan,
+  bool, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(async_user_scan,
+"Allow for asynchronous user LUN scanning (default=0)");
+
+/*
  * Redefine so that we can have same named attributes in the
  * sdev/starget/host objects.
  */
@@ -2121,8 +2136,18 @@ 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);
+   if (lun == SCAN_WILD_CARD &&
+   fc_async_user_scan) {
+   if (!(rport->flags & FC_RPORT_SCAN_PENDING)) {
+   rport->flags |= FC_RPORT_SCAN_PENDING;
+   scsi_queue_work(shost,
+   &rport->scan_work);
+   }
+   spin_unlock_irqrestore(shost->host_lock, flags);
+   } else {
+   spin_unlock_irqrestore(shost->host_lock, flags);
+   scsi_scan_target(&rport->dev, channel, id, lun, 
1);
+   }
return;
}
}
-- 
2.6.2

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


[PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter

2015-11-11 Thread Hannes Reinecke
When invoking a scan via the sysfs 'scan' attribute the process
will be blocked until the scan is completed, which can take a
very long time on large installations.
Enabling the 'async_user_scan' parameter moves the actual
LUN scanning to a workqueue, thereby unblocking the process.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_transport_fc.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 72954a8..af1d35b 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -83,6 +83,21 @@ MODULE_PARM_DESC(disable_target_scan,
 "Disable target scan on remote ports (default=0)");
 
 /*
+ * async_user_scan: make 'scan' sysfs attribute asynchronous
+ *   on larger installations scanning can take a very long time
+ *   during which the process invoking the scan will be blocked
+ *   on writing to the 'scan' attribute. Enabling this attribute
+ *   will move scanning to a work queue, allowing the process
+ *   to return immediately.
+ */
+static bool fc_async_user_scan;
+
+module_param_named(async_user_scan, fc_async_user_scan,
+  bool, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(async_user_scan,
+"Allow for asynchronous user LUN scanning (default=0)");
+
+/*
  * Redefine so that we can have same named attributes in the
  * sdev/starget/host objects.
  */
@@ -2121,8 +2136,18 @@ fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, 
uint id, uint 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);
+   if (lun == SCAN_WILD_CARD &&
+   fc_async_user_scan) {
+   if (!(rport->flags & FC_RPORT_SCAN_PENDING)) {
+   rport->flags |= FC_RPORT_SCAN_PENDING;
+   scsi_queue_work(shost,
+   &rport->scan_work);
+   }
+   spin_unlock_irqrestore(shost->host_lock, flags);
+   } else {
+   spin_unlock_irqrestore(shost->host_lock, flags);
+   scsi_scan_target(&rport->dev, channel, id, lun, 
1);
+   }
return;
}
}
-- 
1.8.5.6

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