From patchwork Wed Nov 23 00:17:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9442353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 27624605EE for ; Wed, 23 Nov 2016 00:18:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17C21204BA for ; Wed, 23 Nov 2016 00:18:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C3112074F; Wed, 23 Nov 2016 00:18:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC0DF204BA for ; Wed, 23 Nov 2016 00:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756000AbcKWASH (ORCPT ); Tue, 22 Nov 2016 19:18:07 -0500 Received: from mail-by2nam01on0042.outbound.protection.outlook.com ([104.47.34.42]:39151 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750776AbcKWASA (ORCPT ); Tue, 22 Nov 2016 19:18:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BQ4jQ/pZMS/IHAb7SqCGPkSlhAvqmf9+Bqamd9Qi4NQ=; b=ehS4E0FWtptK84IT8gDd36TcCX8ok9cfcZMCkbapwvYKFVYaq/D0UKX0jHzR/n6t523VLPtCkH5vtMKwB0yK8UB0UjhmZuU0rD2wNrkIWvaf+veO+vXkNhP9S0KfK2FXLQ0vZGqj8HEX/v/dZcBDdS9e8vhFCiI7uLSIKwvBIU0= Received: from CY4PR02CA0031.namprd02.prod.outlook.com (10.175.57.145) by DM5PR02MB2857.namprd02.prod.outlook.com (10.175.86.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8; Wed, 23 Nov 2016 00:17:17 +0000 Received: from BN1BFFO11FD026.protection.gbl (2a01:111:f400:7c10::1:176) by CY4PR02CA0031.outlook.office365.com (2603:10b6:903:117::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8 via Frontend Transport; Wed, 23 Nov 2016 00:17:17 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.225) smtp.mailfrom=sandisk.com; linux.vnet.ibm.com; dkim=none (message not signed) header.d=none;linux.vnet.ibm.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.225 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.225; helo=milsmgep14.sandisk.com; Received: from milsmgep14.sandisk.com (63.163.107.225) by BN1BFFO11FD026.mail.protection.outlook.com (10.58.144.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.4 via Frontend Transport; Wed, 23 Nov 2016 00:17:16 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:3270; Count:19 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id CD.4B.03811.15ED4385; Tue, 22 Nov 2016 16:09:54 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Tue, 22 Nov 2016 16:17:16 -0800 X-AuditID: 0ac94371-72fff70000000ee3-6e-5834de516534 Received: from exp-402881.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id B2.3D.03661.900E4385; Tue, 22 Nov 2016 16:17:15 -0800 (PST) Subject: [PATCH 1/2] SRP transport: Move queuecommand() wait code to SCSI core To: James Bottomley , "Martin K. Petersen" References: <39d8cb23-0406-e8c3-6e3a-a467ebe41470@sandisk.com> CC: Doug Ledford , Christoph Hellwig , "Sagi Grimberg" , Max Gurtovoy , "linux-scsi@vger.kernel.org" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <649cb037-3196-df4d-0d31-47f040ce44a2@sandisk.com> Date: Tue, 22 Nov 2016 16:17:13 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <39d8cb23-0406-e8c3-6e3a-a467ebe41470@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeLIzCtJLcpLzFFi42LhOum8SDfonkmEwV5Ni5fnP7BarFx9lMli 1cQ8i2eHelksuq/vYLNYfvwfk8XpRwfYLda9fs/iwOFx/t5GFo8HhzazeOy+2cDm8Wz6YSaP j09vsXi833eVzePzJrkA9igum5TUnMyy1CJ9uwSujMWvp7MWLDeqeH9iPlsDY59WFyMnh4SA icSpa3eYuxi5OIQEljJJNBx6xwrhbGOUmHz0EDtM1ZU3m5kgEosZJea3rmUDSQgL+EkcO94I ZosIJEl0zJnKDGILCdhJLJp3iAXEZhZoY5Jo31kHYrMJGEl8ez8TLM4LVLN29UywBSwCqhJL Hu4As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5w6+Lez+r/vrY/rk8O77E9fLA+8I3axbemEZOTZ/C5hvOL3raO1Mm7d2KL lE+XEktxRqKhFnNRcSIAUc4uLhgCAAA= X-IncomingHeaderCount: 19 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.225; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(3190300001)(189002)(199003)(76176999)(31696002)(54356999)(86362001)(50986999)(2950100002)(65826007)(36756003)(65956001)(53416004)(5001770100001)(4001350100001)(97736004)(31686004)(69596002)(4326007)(65806001)(106466001)(47776003)(626004)(189998001)(23676002)(68736007)(81166006)(77096005)(83506001)(8936002)(33646002)(305945005)(81156014)(64126003)(230700001)(7846002)(2270400002)(38730400001)(2906002)(92566002)(8676002)(5660300001)(356003)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR02MB2857; H:milsmgep14.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD026; 1:MqrLRaPimXznHyNMyOvkvTzBNmjVxKM0dXoAV2aHMSprxNEOU7sAZUvsQrmORhBRU55QrIILF9M4nuFWq53kByWZ7f/BjJQsxxBZ8AkMCDlIKHgvbwIBE8N6595AdomsFGcaoLWqx0QDN2Q/e6ws2EdMCZKLUFSKlATL1NtovGfAG1CCZdAjr7MyCyr7s6wy5mSLkOYzPBQeMcO/IYlWnwkYg0YKbYx9U50StYEZLTidzKcws7hC5Ut6BgCK3ghTvwkI7CXEtl1rOV40Z3jfKujMr3oxipfKO95TUQsyOgf9lqFuBlOqqWbO7JLzpSpKeD5sQxI/OF5yErrEEwjW/oG5CUwSsDJ45+f7jN4B4CP5ywWd1a2Z3N+rsftjG2o+4ITyWML4I9ykBNZN1SMk5fk54G5Cq/pnWWAqbe/pSi8lDAFPZ3wGzGIHPlPdMQ/c/oJu2Qc34WjoyvLRNj4rPredggnHP5s3aByyNWKNccRibmt88mBK1z1Xck5ai7eAuqPqgwYiwwgU3+VLbh2ONGxhNizKULSLSCQaMIAoFVFFwHz9mTtXsr8BDBJmas3H X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB2857; 2:5VECpi7qUiGGl/PZnFTbrX5L3S3kO3QQIB0kHv0DwLXOe+STZ+MiCmBFeSB7UTG2WiswCVz8z/sfwSLHLr9ngO5pEPGq8Is9w1o7IO6c8MY9Hw/YUnK7d3HTueqvt0RIDsa8jLjCmClGF0C9zL5yKO1rhxE9yrKTtScTx9Lk7Y0=; 3:4e7yne2WwJ6WNR1bDu/JFPDyzudr6rHXab2xZVO+iaJvMRXZKfb6/VTVednZO9eWV/Setv1wSvL3PSVNnCX5v+yh9VNrI0sjb5rYLFnd6Tcg8SITY94l7ubFBM/XRF/2m3Q/2cys1ALNwT+tb4yVFyK+Wwq0bgGiztQRTNST37QCj6fAr7Ku7iHTDie2J6rybIf9SN4IfW/7l2r3B1gAZwUxBwTh2eeEEkUNg/Yl/lKwQw1AxzMI4j1s0afNKtqDm493ciuzhHlmO6mhvSj3qUVamyLx6XM0eUaEB4dQVMk= X-MS-Office365-Filtering-Correlation-Id: 21065f13-597f-4870-1492-08d41336155b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:DM5PR02MB2857; X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB2857; 25:1CSH7QlcnrNQPSVe/IA2GJ8Zm0X/vhj2RXhKoOHEf6h8llTfIxC3QjiX5860AvS9m530WiErw1tsyI3ORcAV0dMA4xMYFMBRFfNpoZCbHwn5pATLxGnpp9IGJztuSSB/whAE/mwLxVsiXInjGNL6T9yYP4+hTgw/A44g5/jnJDo9Bqi+qdpBBQh+piOZAZ+sZ/Hc51pVDMX5HD2DCOSOPy02sMMzAO+LIhh2H6zcnzCjCUkQN0eNrAaKZTTq8dNsfR/zbYO0wfo6+hHMl1Lg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ange-Antispam-Report-Test: UriScan:(104084551191319)(146099531331640)(42932892334569)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(6040307)(6045199)(601004)(2401047)(13016025)(13018025)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(6061324); SRVR:DM5PR02MB2857; BCL:0; PCL:0; RULEID:; SRVR:DM5PR02MB2857; X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB2857; 4:Hb3W/l2qjJm0Ce7Zj4Y7BpnHphtBlG7C9TpKl0MWjG42Kduuqput3b8vFtk9om7IqDl7T4yWPuWUXiTyMEVw8nzFJyMOsHWozDqTHoPERMjtP/UA9tvcoJWz+CDJ65tIJ1/+WiROkqSCrM8ZeTOF7DibBIQFVjhsmEWTbSvnGzDtlCZZKHjCF9Nhm3kYjdUnRjGkkqvWnMtwRffJhqY4cs2EOgcuwy3TdqCnKVPQETYk1Pi/H7W5rtrHQXz81rsZK26Dr5CuoV+phdJPN6dYWVG9uJk1IwMFCuiK9onlpLb7UjqQOi7H0j9UuWdomnCsdTMMAu7KSbo0kL40qGuN5QmGoBNo++aDE5QGrW2jYcMSFH8MHaKLAsDFh1LoMOZ7H7EJX7lIprVydUuH4urWSngvYUMlkeCrSBCBXQBuzZoIdn32EUWihN22SoJmKY4yFnZ9NpBwUnZBpUp42Dw3YeO2ziylYy/8EkKOnxZqbf8G33OtHJP51ySUfvCpSDAZ+jZdw7v5ioRu6rOrUV4yJ77TFi8D/ed+PXu6WxtygTyni3VVfPIGN2hoH443xWyNw44Bm4bRSR2C5KUS/pbEIgQCKo7f6W5Saj8DJWMvyQ/GwYdc58Uq6ORvm0NPnz2HUhfQhoCUEaqmAbhs4L3CMa6wT2TCQsVtczrV/ct9/sgePocYDMzP+P7qeYGblqcz X-Forefront-PRVS: 013568035E X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjAyTUIyODU3OzIzOlcxVFlmT1JpUnVndFNIM3BxZi9lMkRJb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kzdTPrw8jlfVTKta4qMaLEfZ/FOvVuh2zV8ywQHRdplLjPxIlIKv X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2016 00:17:16.5578 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.225]; Helo=[milsmgep14.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2857 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Additionally, rename srp_wait_for_queuecommand() into scsi_wait_for_queuecommand() and add a comment about the queuecommand() call from scsi_send_eh_cmnd(). Note: this patch changes scsi_internal_device_block from a function that did not sleep into a function that may sleep. This is fine for all callers of this function: * scsi_internal_device_block() is called from the mpt3sas device while that driver holds the ioc->dm_cmds.mutex. This means that the mpt3sas driver calls this function from thread context. * scsi_target_block() is called by __iscsi_block_session() from kernel thread context and with IRQs enabled. * The SRP transport code also calls scsi_target_block() from kernel thread context while sleeping is allowed. * The snic driver also calls scsi_target_block() from a context from which sleeping is allowed. The scsi_target_block() call namely occurs immediately after a scsi_flush_work() call. Signed-off-by: Bart Van Assche Reviewed-by: Sagi Grimberg Reviewed-by: Martin K. Petersen Cc: James Bottomley Cc: Christoph Hellwig Cc: Doug Ledford --- drivers/scsi/scsi_lib.c | 41 +++++++++++++++++++++++++++++++++++++-- drivers/scsi/scsi_transport_srp.c | 41 ++++++--------------------------------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b4f682c..84c9e61 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2721,6 +2721,39 @@ void sdev_evt_send_simple(struct scsi_device *sdev, EXPORT_SYMBOL_GPL(sdev_evt_send_simple); /** + * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn() + * @sdev: SCSI device to count the number of scsi_request_fn() callers for. + */ +static int scsi_request_fn_active(struct scsi_device *sdev) +{ + struct request_queue *q = sdev->request_queue; + int request_fn_active; + + WARN_ON_ONCE(sdev->host->use_blk_mq); + + spin_lock_irq(q->queue_lock); + request_fn_active = q->request_fn_active; + spin_unlock_irq(q->queue_lock); + + return request_fn_active; +} + +/** + * scsi_wait_for_queuecommand() - wait for ongoing queuecommand() calls + * @shost: SCSI host pointer. + * + * Wait until the ongoing shost->hostt->queuecommand() calls that are + * invoked from scsi_request_fn() have finished. + */ +static void scsi_wait_for_queuecommand(struct scsi_device *sdev) +{ + WARN_ON_ONCE(sdev->host->use_blk_mq); + + while (scsi_request_fn_active(sdev)) + msleep(20); +} + +/** * scsi_device_quiesce - Block user issued commands. * @sdev: scsi device to quiesce. * @@ -2804,8 +2837,7 @@ EXPORT_SYMBOL(scsi_target_resume); * @sdev: device to block * * Block request made by scsi lld's to temporarily stop all - * scsi commands on the specified device. Called from interrupt - * or normal process context. + * scsi commands on the specified device. May sleep. * * Returns zero if successful or error if not * @@ -2814,6 +2846,10 @@ EXPORT_SYMBOL(scsi_target_resume); * (which must be a legal transition). When the device is in this * state, all commands are deferred until the scsi lld reenables * the device with scsi_device_unblock or device_block_tmo fires. + * + * To do: avoid that scsi_send_eh_cmnd() calls queuecommand() after + * scsi_internal_device_block() has blocked a SCSI device and also + * remove the rport mutex lock and unlock calls from srp_queuecommand(). */ int scsi_internal_device_block(struct scsi_device *sdev) @@ -2841,6 +2877,7 @@ scsi_internal_device_block(struct scsi_device *sdev) spin_lock_irqsave(q->queue_lock, flags); blk_stop_queue(q); spin_unlock_irqrestore(q->queue_lock, flags); + scsi_wait_for_queuecommand(sdev); } return 0; diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c index e3cd3ec..b48328a 100644 --- a/drivers/scsi/scsi_transport_srp.c +++ b/drivers/scsi/scsi_transport_srp.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -402,36 +401,6 @@ static void srp_reconnect_work(struct work_struct *work) } } -/** - * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn() - * @shost: SCSI host for which to count the number of scsi_request_fn() callers. - * - * To do: add support for scsi-mq in this function. - */ -static int scsi_request_fn_active(struct Scsi_Host *shost) -{ - struct scsi_device *sdev; - struct request_queue *q; - int request_fn_active = 0; - - shost_for_each_device(sdev, shost) { - q = sdev->request_queue; - - spin_lock_irq(q->queue_lock); - request_fn_active += q->request_fn_active; - spin_unlock_irq(q->queue_lock); - } - - return request_fn_active; -} - -/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */ -static void srp_wait_for_queuecommand(struct Scsi_Host *shost) -{ - while (scsi_request_fn_active(shost)) - msleep(20); -} - static void __rport_fail_io_fast(struct srp_rport *rport) { struct Scsi_Host *shost = rport_to_shost(rport); @@ -441,14 +410,17 @@ static void __rport_fail_io_fast(struct srp_rport *rport) if (srp_rport_set_state(rport, SRP_RPORT_FAIL_FAST)) return; + /* + * Call scsi_target_block() to wait for ongoing shost->queuecommand() + * calls before invoking i->f->terminate_rport_io(). + */ + scsi_target_block(rport->dev.parent); scsi_target_unblock(rport->dev.parent, SDEV_TRANSPORT_OFFLINE); /* Involve the LLD if possible to terminate all I/O on the rport. */ i = to_srp_internal(shost->transportt); - if (i->f->terminate_rport_io) { - srp_wait_for_queuecommand(shost); + if (i->f->terminate_rport_io) i->f->terminate_rport_io(rport); - } } /** @@ -576,7 +548,6 @@ int srp_reconnect_rport(struct srp_rport *rport) if (res) goto out; scsi_target_block(&shost->shost_gendev); - srp_wait_for_queuecommand(shost); res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV; pr_debug("%s (state %d): transport.reconnect() returned %d\n", dev_name(&shost->shost_gendev), rport->state, res);