From patchwork Fri Jan 29 23:15:52 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: 8168611 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 88521BEEE5 for ; Fri, 29 Jan 2016 23:16:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67BFD20256 for ; Fri, 29 Jan 2016 23:16:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4217A20253 for ; Fri, 29 Jan 2016 23:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755401AbcA2XP5 (ORCPT ); Fri, 29 Jan 2016 18:15:57 -0500 Received: from mail-bl2on0068.outbound.protection.outlook.com ([65.55.169.68]:10624 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755852AbcA2XPz (ORCPT ); Fri, 29 Jan 2016 18:15:55 -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=TmArauGW/AZ8PUIUh9Y69StHwu8kdAnmFPb61SNoUpY=; b=t+RyDOR9y2PaJiIcMCBrE8SoswvzLXERKVyN0Pevhti6T4/qysSXqyQG835/vuKc7Xr+cs0HBe0jM3bmaA8mrKeFF6h2CjCmqIiio7drTKDhB7/rrxtDBtKKVC5uwsnOHzEbpYELhWPzb3/cNaqG25USNXJjB9cG+obzaHVd/9w= Received: from BLUPR02CA031.namprd02.prod.outlook.com (10.160.23.149) by BN1PR0201MB0819.namprd02.prod.outlook.com (10.160.170.151) with Microsoft SMTP Server (TLS) id 15.1.390.13; Fri, 29 Jan 2016 23:15:53 +0000 Received: from BY2FFO11FD041.protection.gbl (2a01:111:f400:7c0c::172) by BLUPR02CA031.outlook.office365.com (2a01:111:e400:8ad::21) with Microsoft SMTP Server (TLS) id 15.1.396.15 via Frontend Transport; Fri, 29 Jan 2016 23:15:53 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; 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 BY2FFO11FD041.mail.protection.outlook.com (10.1.14.226) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Fri, 29 Jan 2016 23:15:52 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by (Symantec Messaging Gateway) with SMTP id B7.40.29304.8A2FBA65; Fri, 29 Jan 2016 15:15:52 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.248.2; Fri, 29 Jan 2016 15:15:53 -0800 X-AuditID: ac160a68-f4bff70000007278-7a-56abf2a8ac9f Received: from [10.60.52.49] ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 8E.67.02700.8A2FBA65; Fri, 29 Jan 2016 15:15:52 -0800 (PST) Subject: [PATCH v2 13/22] IB/srpt: Fix how aborted commands are processed To: Doug Ledford References: <56ABF16E.7070006@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , "Alex Estrin" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <56ABF2A8.5060200@sandisk.com> Date: Fri, 29 Jan 2016 15:15:52 -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: <56ABF16E.7070006@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKLMWRmVeSWpSXmKPExsWyRoxnke6KT6vDDF4d0ba48PQ7k8XL8x9Y LVauPspk8exQL4vFjbYHbA6sHov3vGTy2H2zgc3j2fTDTB7v911l8/i8SS6ANYrLJiU1J7Ms tUjfLoErY/7JL4wF/RoVbx4sZmxgPKbQxcjBISFgItF2y7uLkZNDSGATo8T2BoEuRi4gewej xL71nawgCZCaBWdPs0Ak5jBK9D44yQTSLCzgKXH9XRxIjYiAmsSmV4vYIQZpSZy78IUdpJ5Z YBWjxKar18ESbAJGEt/ez2QBsXmBirbencUEYrMIqEo0bXgPZosKREgc7uxih6gRlDg58wlY PaeAtsSS2RdYQPYyC2hKrN+lDxJmFpCX2P52DjPILgmBvawSLw8eZYI4Ql3i5JL5TBMYhWch GTULoX0WkvYFjMyrGMVyM3OKc9NTCwwN9YoT81Iyi7P1kvNzNzGCI4MrYwfj1knmhxgFOBiV eHg9lq0OE2JNLCuuzD3EKMHBrCTCW/cCKMSbklhZlVqUH19UmpNafIhRmoNFSZzXukUtTEgg PbEkNTs1tSC1CCbLxMEp1cB4Iae+TF1M8M+nJ8x+h0M6tnF80tr1UC1mF/PHmfx6+w/odxhc mRygzHacafVvO8nCucdWLEsWmHusWqNc6mHbjcq4wMorLx+ejpTfuyHpn+Ipz7TJdzPrpk4o +Lnjv4DU5Ubh31fnVKyewRdguWbV5iWFzl5v15V3Tr6gsIJv76KMubk22fvklViKMxINtZiL ihMBRlVCXogCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHJMWRmVeSWpSXmKPExsXCtZEjRXfFp9VhBnfnSFtcePqdyeLl+Q+s FitXH2WyeHaol8XiRtsDNgdWj8V7XjJ57L7ZwObxbPphJo/3+66yeXzeJBfAGsVlk5Kak1mW WqRvl8CVMf/kF8aCfo2KNw8WMzYwHlPoYuTkkBAwkVhw9jRLFyMXh5DALEaJuUvnADkcHMIC nhLX38WB1IgIqElserWIHcQWEtCSOHfhCztIPbPAKkaJ3ys/sIEk2ASMJL69n8kCYvMCFW29 O4sJxGYRUJVo2vAezBYViJA43NnFDlEjKHFy5hOwek4BbYklsy+A2cwC6hJ/5l1ihrDlJba/ ncM8gZFvFpKWWUjKZiEpW8DIvIpRLDczpzg3PbPA0FCvODEvJbM4Wy85P3cTIzhEOSN3MD6d aH6IkYmDU6qBcWLF2zAv3qVzHgi+UJtn0aIRpyFku4O3vpOdUbTKL9Hw+N/qwB+h+yqy+iRM 93hlrXz5PGjW2cqPMcv8d3NPs5kk+rah4cyGt0sPZ08O7pn4Qa7q9ay3BV84TxW0TLxTncZf Xdzdm7BM6E8dp8I2iYd8C9kPhM+4b1iovHZp/R3HBZ6FDgc2K7EUZyQaajEXFScCALl3IYEB AgAA X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD041; 1:T2xN2u3QyOiCdXtEFc+gtEdV5lM3CwXsU8hzHmklZQtS38Y8eRts9fphx99f5DF83H3OXMo+78OXppEM/3rxfyWC+HbcbFZwekAbDMoVsfQFTAYzXK90N5SceX5QfQFLyufwesAmKQT4lPT/7GmxNLnoGSua/e3fG5WxdxTMUg4lE6QvVMEvO30pY6zEBGWocBxhZbI/lDdIX1wQsvgkRqnYd0lroemjkfBwbmxCmQpapMqJHlMkcUCnjKizju1O0oxM4gS2i7eA6Mswm9DtAn+UHjw7+jDEBjEJy0B/0PJWnPI6+n8aSavJprT2J/N4I2SVH91rhLvCARpdpdlS5c+ujG0q3BgMAWwsGJbK/MQvEz1Ms4hrA6DLy9jrL2grjmD1xL4YRW8FTmaXAJWESg6gmtQ7Fvo4+QexBQJnVyk= X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(80316001)(19580395003)(83506001)(4326007)(86362001)(2906002)(50466002)(64126003)(33656002)(92566002)(23676002)(87936001)(36756003)(110136002)(229853001)(19580405001)(1096002)(87266999)(230700001)(5001960100002)(54356999)(2950100001)(106466001)(77096005)(76176999)(4001350100001)(65956001)(5008740100001)(189998001)(1220700001)(65806001)(11100500001)(65816999)(47776003)(586003)(50986999)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0201MB0819; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0819; 2:sBKDhh9sHGOtfJmltElRkf7m7p9cnH8V2Yv4AsuwLjhfhNerYLF2GawaxvJWCCl0mFZH8a/zEGMwK2r5xCnLg5XkB1FMGryz1U61jek1pWJcv/4qYSbWfZrVYIdD9nh7juryWt5rNDktQobtdytvyg==; 3:Mhioj54Ykn9zJ2vra8VyFZnnxcE8Q5k92jPjapbRKd0aFAXBc3/0XwxDqSEYBARx+RiKe1sKj/UXtCuyRpLWlTFzIDN3ejWaNL1qnspzpIQ4I1urhLhEIMJzNuQV/4I7hoGOyfy5q/Xf7xETT8eqZaixy0+coY/YeICAIfs1C/rWt7aIBIqU/X8D8wrPqVIFrS4mk9omdkgTk/TwrhCphT5HCEc4muiTw8d8yrUv4XrncSs2GQZycPbEXldfPHruLabrKT6Um3Mi7CIMfi7spg==; 25:qL5VodFhXxt4QLePSFCr73WNU9coNVUUds2u8D/dONs7ntInddRGLXWiBeOfVDxeGYQmJNnqCacbMDd2Lmd6km9ksLyqvS+8dn3U/afi9ugUX3fSdjvArAVeZ8Q73daDgRjKSJ2PU+RfF2rvYxZitws0vpz/IXS15GxCDFCY333vu6011mmg5WsZI83y0qoLKqD1ymfgcIerpQUuGZ9V/z0zifQhda4Y0QMhI8EepwDvgyYiYt+qwWAnwTS7lPK+ X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BN1PR0201MB0819; X-MS-Office365-Filtering-Correlation-Id: c8c2df07-db27-4d2b-a414-08d329022216 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0819; 20:FjuoY0wYJOqLXCSQphxWG/vQbXg0wSV3eWSEppVGDOzLgysybOyoiRNit7xlP/aw1smIirURaJCBOBERLnk6vvM442b6pc2jWhlHiSUMOZLvZOllK3MTu72j6cvVdUmsPfSiqYolBhoH8cLsmkdqjVr0gdaT+DKUXaqfrpYHStv/wMimgdw1J81RCNI5fjZCOtG6/jUenhQaOdl+nJgoqPAuoBYe5Gwt4swt2ZDzTeISumYTZWNvJMyngTJ0VKWXW31eou+R7rDYgl0PBwAA0fsqdM2pE5rC69U1wv+WRenPxHoPS9y6ppWjguDHt6L7O8KWxRMe5FziXffaLhT1x7U8+bxJVoW4GE3ozxqdHXFdBbDQAmSq0OOXhlnGNfCO3AQ3aB/xJI4OZA++99NVTTZOHAqIizYx5JQ8FDl6ri/+NZC+PftmkCMMOwymo7W8c7MWayoLr2AmI6ySdjV2qC9c3RA8QR/sMp0IJubv13vqjldB2Ttyw+XdZLBSgtLk 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)(13024025)(13017025)(13018025)(8121501046)(13015025)(13023025)(5005006)(3002001)(10201501046); SRVR:BN1PR0201MB0819; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0201MB0819; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0819; 4:5ly2L1P54y3Mn7EVcb+0VeuRtSRXdLuGyAO6ej+2jiCQDCEXqi+gZ2DY4qmhfsbrHBz8jvRasUORQ3+QSlkyvCuXPRSAo+zaAhPKZoVbEcX4ehnjH6Y0IK8QJLiwaCVpFtwaLKjaAOhqisgZiZpjhrOFrU7qDIqUhtryjfqe/fE/FGtLOO5U4mxyyH84HL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r?= =?utf-8?B?dTNaRHlEbTJDR01XVzF1Z2tKYjNwRUNhYXcrRjVUUjBjOEdCK0FQQ1B4Mmgx?= =?utf-8?B?R2lkRTlBPT0=?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0819; 5:gD14e9s3dup+T0QSz9SU5PTd66Z0VuDBekK1/tp7sjDh+8RZGG+SOlfvrorkaM7LBDDkKWVx/UBkGuxXlRzWCaW+929TwHa6sq6529e/ttcw4BOQb34Q0Zy9jH0ANjBltwdKOdcFZN1X85vBhb/CdQ==; 24:hwT8fSquRqHVQqIKc3bIvEI13Notx3t9HI1GowIVUkTtaQuCCNzhaBNZOtok25uYQ/WTFDkNkz5bY7j6f7j8WCFeW8xQZg0aqj9H6OOSiCY=; 20:DfF2+LZHRVB4UOnhBSdrfqF2WRKeHfyN40L1abDcPgOa96jKQqF1wi7xoyj3DlvbqloDh4vhsoRVXId9Q6lVvmBRuOJdPZyTc4OcHBDFeufeIQdUVjIxW7ewPV8HPNB4yavk4PNVq7tn68TzSIkDk9Uc6pQNtg0SQgPXbEdLea/jHJONR3uHeNnJvnHSD7WQuoBQPYuAIYQkoJQyou/df7hk5p+qfZQvit+9qA1JhEYlcvr9FEA1Vwku3cl28KQD SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2016 23:15:52.7486 (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: BN1PR0201MB0819 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 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 Cc: Christoph Hellwig Cc: Sagi Grimberg Reviewed-by: Christoph Hellwig Reviewed-by: Alex Estrin --- 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 8ab431f..652e1ef 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) {