From patchwork Thu Feb 4 22:52:41 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: 8228761 Return-Path: X-Original-To: patchwork-linux-rdma@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 E91F1BEEE5 for ; Thu, 4 Feb 2016 22:52:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA0AA20390 for ; Thu, 4 Feb 2016 22:52:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2F8C201CD for ; Thu, 4 Feb 2016 22:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966023AbcBDWwt (ORCPT ); Thu, 4 Feb 2016 17:52:49 -0500 Received: from mail-bn1on0063.outbound.protection.outlook.com ([157.56.110.63]:2816 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934394AbcBDWwp (ORCPT ); Thu, 4 Feb 2016 17:52:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dYdHsZ9f3eIT1sd54C8Qhk3wuvYoADADlb1aYcJulVI=; b=ApxqfJA77nut3FziZDaZoyFCr+7VfCkfycM8AxXXJpIPibNnPb2FBM5ZipQtBgCBHyZxJoYMu7bnNuBHPniR/ktRAEXhoFkoub5qCxvJiAvy6kB7aHB6ljJr8qrT5ydiLN0VonuYTVarHHecZJ81bHwv7NdNjT67Lr5TkEguoIY= Received: from CY1PR0201CA0003.namprd02.prod.outlook.com (10.163.30.141) by BLUPR02MB295.namprd02.prod.outlook.com (10.141.77.23) with Microsoft SMTP Server (TLS) id 15.1.403.16; Thu, 4 Feb 2016 22:52:44 +0000 Received: from BL2FFO11FD010.protection.gbl (2a01:111:f400:7c09::173) by CY1PR0201CA0003.outlook.office365.com (2a01:111:e400:58b9::13) with Microsoft SMTP Server (TLS) id 15.1.403.16 via Frontend Transport; Thu, 4 Feb 2016 22:52:43 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BL2FFO11FD010.mail.protection.outlook.com (10.173.161.16) with Microsoft SMTP Server id 15.1.409.7 via Frontend Transport; Thu, 4 Feb 2016 22:52:42 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by (Symantec Messaging Gateway) with SMTP id 42.7E.02415.A36D3B65; Thu, 4 Feb 2016 14:52:42 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.248.2; Thu, 4 Feb 2016 14:52:42 -0800 X-AuditID: ac160a68-70bff7000000096f-a8-56b3d63a4cc9 Received: from [10.60.52.49] ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 5F.3E.03361.936D3B65; Thu, 4 Feb 2016 14:52:42 -0800 (PST) Subject: [PATCH v3 12/21] IB/srpt: Fix how aborted commands are processed To: Doug Ledford References: <56B3D453.7030409@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , "Alex Estrin" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <56B3D639.1000109@sandisk.com> Date: Thu, 4 Feb 2016 14:52:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56B3D453.7030409@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsWyRoxnka7Vtc1hBquuSVhcePqdyeLl+Q+s FitXH2WyeHaol8XiRtsDNgdWj8V7XjJ57L7ZwObxbPphJo/3+66yeXzeJBfAGsVlk5Kak1mW WqRvl8CV8WH2IuaCUxoVV878YWtg/KPQxcjJISFgInHgwGO2LkYuDiGBTYwS65ecY4ZwtjNK HP/ZxAxT9XhDJwtEYg6jxJYfn1hAEsICnhJPf7SzgdgiAmoSm14tYgexhQS0JKaum8kO0sAs sIpRYtPV62AJNgEjiW/vZ4I18wIVXVvbCBZnEVCRWL77KlhcVCBC4nBnFztEjaDEyZlPwOKc AtoSK28tArI5gIZqSqzfpQ8SZhaQl9j+dg7Y1RIC21glWk92MUIcoS5xcsl8pgmMwrOQjJqF 0D4LSfsCRuZVjGK5mTnFuempBYaGesWJeSmZxdl6yfm5mxjB8cGVsYNx6yTzQ4wCHIxKPLwH 1m4OE2JNLCuuzD3EKMHBrCTC23EBKMSbklhZlVqUH19UmpNafIhRmoNFSZzXukUtTEggPbEk NTs1tSC1CCbLxMEp1cAYwB3rmrjz9+b3W67drSk/fnkug91UvYzQvAeBou82veW5pTlz+j/2 3+Y53mlclvahX/V8lSJPKG1x+jLJKUEr09Rsq3e8/em5ubFZJuKTDaujZ11ctmhvj5CZ3ccS dXaTnyuuBG871HhFq4F/wouElx+ElHQOze5nuD+Pe0HlCaa5GydlHSxQYinOSDTUYi4qTgQA 4OOCnIsCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPJMWRmVeSWpSXmKPExsXCtZEjRdfq2uYwg009TBYXnn5nsnh5/gOr xcrVR5ksnh3qZbG40faAzYHVY/Gel0weu282sHk8m36YyeP9vqtsHp83yQWwRnHZpKTmZJal FunbJXBlfJi9iLnglEbFlTN/2BoY/yh0MXJySAiYSDze0MnSxcjFISQwi1Gi6dJZFpCEsICn xNMf7WwgtoiAmsSmV4vYQWwhAS2JqetmsoM0MAusYpT4vfIDWBGbgJHEt/czwZp5gYqurW0E a2ARUJFYvvsqWFxUIELicGcXO0SNoMTJmU/A4pwC2hIrby0Cs5kF1CX+zLvEDGHLS2x/O4d5 AiPfLCQts5CUzUJStoCReRWjWG5mTnFuemaBoZFecWJeSmZxtl5yfu4mRnCQckbtYLw+0fwQ IxMHp1QD4xTX1NBDRY1+M5t+5/7ea+Ax2dXB+/KDP6/MjP/e1V55RUXQb4sD39cV65efWMfP JazH/PrBG/bl24X2nwi3Ovwy2F5k6wEjZqaW8LPrN5YFth/59nm+eN1HteAVhg+XHcyL0O+b ap9SHDZ9bkXjxD1u7yfGpmnFvfay7725MHF2SEKXvelcHyWW4oxEQy3mouJEAJWuUIoCAgAA X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD010; 1:UEFjMUdl/54xahzNGTkKdIxq8BKtcGRfRAwqUAGNYKjSty5+4PJR4w+UKmB5zcIor8iYU1FFPZkmVe5cw4F6juB4asBscK7T7GpEqV43nODMkt8C9mmEiOjQUWjc6dpLwJm47YRT+I3HFeGFp5j8JTbfl/+4v5ONDnk9tsNahbSd6ZDRNIEwiTi6u/EMiTkYj5sdtAZOt+kZTlt7B0FTezf5gTXuyHDhjTu7J6wAsIyiGV4EyOM6qmXOkPaLDkzik8bi+ykGN93ef4vFWmNBkjAiIrPGWhtPqOcHm41p+VGNzaACRge7x06oEX0Vq3BqbzaFU5weAu6Ywxlo5NDYBDFODb5obtpIFB65jalneAFCZhJTN/QnCjRC5GpU1ANXAIpH6mmc36KTVnsSl+QXco8y9Dt3lsgeQIstjNXVUoEVFfbGvGkVIy1xMcvTaeg3 X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(47776003)(59896002)(83506001)(2906002)(4326007)(2950100001)(65806001)(86362001)(64126003)(50986999)(92566002)(77096005)(5008740100001)(54356999)(87266999)(76176999)(65816999)(36756003)(33656002)(5001960100002)(106466001)(110136002)(189998001)(1220700001)(23676002)(230700001)(4001350100001)(1096002)(19580395003)(87936001)(50466002)(586003)(19580405001)(80316001)(229853001)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR02MB295; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB295; 2:U5iTJd8zO4pd1ZLJguVwG7K/WcpGHhuQ5+Q8TBXU48jVZJ5FE5geLl+nEJUYrpEEssBQc7UdbWecOPHE1fzw3cIdWSPNJSrb7jtlNr7Eus83H/uv3UovrlUtM+ctivKMglyNv8uR9nKdeDyHJY19Gg==; 3:8gWU9b5ISpT0FvJ/GwiEGCSOOzlJRsepdW6+zxsw9OjJHuj+PCrzRP392y6NWkgCAdeTOfn5iNvT2i8qhYVBbcLMmbG7Iv58250HYO9v9iiUno0o1N7g4+32+eKsO5ysvpEDQckSzUDFcBjJNQehWUaWn+lZrI741WQ7F8REJZFQdOsdHkdgaL90kBQUHvUOGqtthEYLJNkbmJIO74TmbsKRP0e4qVQNGfaNbzTrarkeYhSWbrac3HjAm2VvpdiWCnbmyc2wr5nu6/gFHZ1gWA==; 25:aFlDvOJvnbiVx7eUhKNsoGcqrhRPZD5+O/0YL6v5hLiHBW9ttQVoTz9d/BpJB0Di7W2nNy5+oQu8uYQs8AYkdWc+L0lWtkDICy11krDrw24UwEAi4yN6qdz3xUHw29Nw572m9k55lQzvYDakIAxC7OsQKA4MDSjKokAD9+D0eg1/F51EOvjAav9vuhHVUaFjoBTKn6wK2bxHH0IGqtbCJ9w7t2uoDoUMAki/qkczOTv68SHNUombmlVoRC4tGt+kgkHd9F7RQRjUC9T7CezhC7Hz/VPrly7pNiiiy/sAvULsJgR9eUVsQ9m/022znkK9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BLUPR02MB295; X-MS-Office365-Filtering-Correlation-Id: 039d349d-3e32-478b-de58-08d32db5e449 X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB295; 20:CcBWfHL8bwjURnUDabdamLP3Xu1KkcPwTd9NrsxtVNvECtFmSzT4VR0F4Yp/2dRURUzc655ePcFNatTqeAXxUvf5acWegED7zs4YH8peVA4PHP1CFDVze1fWIUX7MpCm8lU2njUn44L7j6aNkWeKZ2cGseP2l+w8vYkxMUBdOp3Y3HjENniraZ2kKYXecu3XlVjskgEDEKdq4f7h2vrYob1Y47lGOx3GxqWbcGGdk7pwcs6UMUxnnsNcZiSaOR+GM6Cbtq2aifxjy/rYhq9H41z2ygSJBa40BS2kJAMA/KhCpvDC/b0c3LAbKKRBWVlZwaU/TnDPUGm95nyiACoefSuTRonfFDOJZhkwmrLQvpJxZOHlXpy8lb7hxkqr08/Q0y0EDuQhWNAj/M7eEH0TEVRvlxMFkAROXa7XHK4Aqz8+8aQWs/HqLlJe1Kbav5bhM83ybbdlNzNsGuw71Wq1mkR4191XD+OIIsf1vTQrvvsAxfJPmPj9ZbTlVtNRmO3V X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(34787635062028)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(13015025)(13024025)(5005006)(13018025)(8121501046)(13023025)(3002001)(10201501046); SRVR:BLUPR02MB295; BCL:0; PCL:0; RULEID:; SRVR:BLUPR02MB295; X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB295; 4:Z5nuCtsnnAEvpb3rQz2sUSbUl2GtW3cStaVNHxVlEOs1xAMdzhbZ3iCs+oBUbnmMXmD7OPFuVvNijyi7FD6acHDOLMvBgG4MFRlOGV1PCo+J3Nj94YcG1zImfxH9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?= =?utf-8?B?SWcvQjl3cG9oY1JjaGZudTR2Skc2Y1JzV1pveS8xR21TZkhOV1ZvWHJFazdE?= =?utf-8?Q?OPGjVmdhbVGcT5z6+iCSI26LsE?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB295; 5:IvtfE9dYluZBBS3K43o3aIFGctdMaSS5eRmC9XpZ0on6z3BeIB5TjeIK7l2HnvbBVp/vLlmDzX0Ul4htY0nJ1t2rnUB16AXMuIhmsktIbC9tS2yKkyYSSa+5GK+8aGHSEutJtP27B5yCob/bmbK6JQ==; 24:SOkNBwdJaDChkbLajZd+HwYBezU9t4+r3vLqHq+J0uLzY2HhXPfuyZaETSHHTHYeBK6yVnRxSGYMgKOZ362GCM6rxlvberhWkyjn003shx4=; 20:PYZaeT/DnIzVaKud0thoa3c3DdCToTVt6MiY/vyX37JYomT1+DAOfrbLVl7dssUp7G0N/HVSGM2GAiyVQF2LRZ4eTkSijyrqsBeMoP1txbmJlpcQpmXpq+yORuoospjn44BTyW5n/r7ax1q5N2QGS4OttNYdQ+fh7kmV7fgKtzHWSnmbxMiugfVHuPFrjNN9tOxpwfxPXEVmLtSy1TyQMETVD1+0hKzHPn85nmUwFdoKUvrCXE+od9DUtolc1laC SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2016 22:52:42.6288 (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.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB295 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 srpt_abort_cmd() must not be called in state SRPT_STATE_DATA_IN. Issue a warning if this occurs. srpt_abort_cmd() must not invoke target_put_sess_cmd() for commands in state SRPT_STATE_DONE because the srpt_abort_cmd() callers already do this when necessary. Hence remove this call. If an RDMA read fails the corresponding SCSI command must fail. Hence add a transport_generic_request_failure() call. Remove an incorrect srpt_abort_cmd() call from srpt_rdma_write_done(). Avoid that srpt_send_done() calls srpt_abort_cmd() for finished SCSI commands. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Alex Estrin Cc: Sagi Grimberg --- drivers/infiniband/ulp/srpt/ib_srpt.c | 49 ++++++++++++----------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 569820a..5b204f8 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1267,10 +1267,7 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) /* * If the command is in a state where the target core is waiting for - * the ib_srpt driver, change the state to the next state. Changing - * the state of the command from SRPT_STATE_NEED_DATA to - * SRPT_STATE_DATA_IN ensures that srpt_xmit_response() will call this - * function a second time. + * the ib_srpt driver, change the state to the next state. */ spin_lock_irqsave(&ioctx->spinlock, flags); @@ -1279,25 +1276,17 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) case SRPT_STATE_NEED_DATA: ioctx->state = SRPT_STATE_DATA_IN; break; - case SRPT_STATE_DATA_IN: case SRPT_STATE_CMD_RSP_SENT: case SRPT_STATE_MGMT_RSP_SENT: ioctx->state = SRPT_STATE_DONE; break; default: + WARN_ONCE(true, "%s: unexpected I/O context state %d\n", + __func__, state); break; } spin_unlock_irqrestore(&ioctx->spinlock, flags); - if (state == SRPT_STATE_DONE) { - struct srpt_rdma_ch *ch = ioctx->ch; - - BUG_ON(ch->sess == NULL); - - target_put_sess_cmd(&ioctx->cmd); - goto out; - } - pr_debug("Aborting cmd with state %d and tag %lld\n", state, ioctx->cmd.tag); @@ -1305,19 +1294,16 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) case SRPT_STATE_NEW: case SRPT_STATE_DATA_IN: case SRPT_STATE_MGMT: + case SRPT_STATE_DONE: /* * Do nothing - defer abort processing until * srpt_queue_response() is invoked. */ - WARN_ON(!transport_check_aborted_status(&ioctx->cmd, false)); break; case SRPT_STATE_NEED_DATA: - /* DMA_TO_DEVICE (write) - RDMA read error. */ - - /* XXX(hch): this is a horrible layering violation.. */ - spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags); - ioctx->cmd.transport_state &= ~CMD_T_ACTIVE; - spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags); + pr_debug("tag %#llx: RDMA read error\n", ioctx->cmd.tag); + transport_generic_request_failure(&ioctx->cmd, + TCM_CHECK_CONDITION_ABORT_CMD); break; case SRPT_STATE_CMD_RSP_SENT: /* @@ -1325,18 +1311,16 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) * not been received in time. */ srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx); - target_put_sess_cmd(&ioctx->cmd); + transport_generic_free_cmd(&ioctx->cmd, 0); break; case SRPT_STATE_MGMT_RSP_SENT: - srpt_set_cmd_state(ioctx, SRPT_STATE_DONE); - target_put_sess_cmd(&ioctx->cmd); + transport_generic_free_cmd(&ioctx->cmd, 0); break; default: WARN(1, "Unexpected command state (%d)", state); break; } -out: return state; } @@ -1376,9 +1360,14 @@ static void srpt_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) container_of(wc->wr_cqe, struct srpt_send_ioctx, rdma_cqe); if (unlikely(wc->status != IB_WC_SUCCESS)) { + /* + * Note: if an RDMA write error completion is received that + * means that a SEND also has been posted. Defer further + * processing of the associated command until the send error + * completion has been received. + */ pr_info("RDMA_WRITE for ioctx 0x%p failed with status %d\n", ioctx, wc->status); - srpt_abort_cmd(ioctx); } } @@ -1721,15 +1710,10 @@ static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc) atomic_inc(&ch->sq_wr_avail); - if (wc->status != IB_WC_SUCCESS) { + if (wc->status != IB_WC_SUCCESS) pr_info("sending response for ioctx 0x%p failed" " with status %d\n", ioctx, wc->status); - atomic_dec(&ch->req_lim); - srpt_abort_cmd(ioctx); - goto out; - } - if (state != SRPT_STATE_DONE) { srpt_unmap_sg_to_ib_sge(ch, ioctx); transport_generic_free_cmd(&ioctx->cmd, 0); @@ -1738,7 +1722,6 @@ static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc) " wr_id = %u.\n", ioctx->ioctx.index); } -out: while (!list_empty(&ch->cmd_wait_list) && ch->state == CH_LIVE && (ioctx = srpt_get_send_ioctx(ch)) != NULL) {