From patchwork Wed Nov 11 10:34:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 7594811 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E2AE0BF90C for ; Wed, 11 Nov 2015 10:34:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19BDD20529 for ; Wed, 11 Nov 2015 10:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32CBC20527 for ; Wed, 11 Nov 2015 10:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752110AbbKKKeo (ORCPT ); Wed, 11 Nov 2015 05:34:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:44261 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbbKKKen (ORCPT ); Wed, 11 Nov 2015 05:34:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 58F24AAB2; Wed, 11 Nov 2015 10:34:21 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , Ewan Milne , linux-scsi@vger.kernel.org, James Bottomley , Hannes Reinecke Subject: [PATCH 2/2] scsi_transport_fc: Implement 'async_user_scan' module parameter Date: Wed, 11 Nov 2015 11:34:40 +0100 Message-Id: <1447238080-109942-3-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1447238080-109942-1-git-send-email-hare@suse.de> References: <1447238080-109942-1-git-send-email-hare@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; } }