All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	Johannes Thumshirn <jthumshirn@suse.com>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter
Date: Mon, 22 Feb 2016 08:51:02 +0100	[thread overview]
Message-ID: <1456127462-2817-3-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1456127462-2817-1-git-send-email-hare@suse.de>

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 <hare@suse.de>
---
 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


  parent reply	other threads:[~2016-02-22  7:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22  7:51 [PATCH 0/2][RESEND] scsi_transport_fc: LUN masking Hannes Reinecke
2016-02-22  7:51 ` [PATCH 1/2] scsi_transport_fc: implement 'disable_target_scan' module parameter Hannes Reinecke
2016-03-01  9:06   ` Johannes Thumshirn
2016-03-01 13:12   ` Christoph Hellwig
2016-03-02  5:59     ` Hannes Reinecke
2016-03-02  9:18       ` Christoph Hellwig
2016-03-02  9:35         ` Hannes Reinecke
2016-02-22  7:51 ` Hannes Reinecke [this message]
2016-03-01  5:45   ` [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' " Seymour, Shane M
2016-03-01  9:07   ` Johannes Thumshirn
2016-03-01 13:15   ` Christoph Hellwig
2016-02-22 11:39 ` [PATCH 0/2][RESEND] scsi_transport_fc: LUN masking Seymour, Shane M
2016-02-23 10:21   ` Hannes Reinecke
2016-02-24  0:35     ` Seymour, Shane M
2016-03-01 19:54     ` Ewan Milne
2016-03-02  6:35       ` Hannes Reinecke
  -- strict thread matches above, loose matches on Subject: below --
2015-11-11 10:34 [PATCH 0/2] " Hannes Reinecke
2015-11-11 10:34 ` [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456127462-2817-3-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=jthumshirn@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.