From patchwork Thu Apr 7 22:55:04 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: 8777881 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 F24D4C0553 for ; Thu, 7 Apr 2016 22:55:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC582201ED for ; Thu, 7 Apr 2016 22:55:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76D1C201CD for ; Thu, 7 Apr 2016 22:55:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752627AbcDGWzN (ORCPT ); Thu, 7 Apr 2016 18:55:13 -0400 Received: from mail-by2on0053.outbound.protection.outlook.com ([207.46.100.53]:24310 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751706AbcDGWzK (ORCPT ); Thu, 7 Apr 2016 18:55:10 -0400 X-Greylist: delayed 995 seconds by postgrey-1.27 at vger.kernel.org; Thu, 07 Apr 2016 18:55:10 EDT 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=vuBjVM8uMwV3sFADFH+eYiHaWWCJ2Jy2VxmQ5MH+mXE=; b=Qmad9JzxAwfqocHe/IPFHT5ppCSnFmWuhjOV13f/n+MLsbUI/EvnvH8wJRlL+mKf6r3ZrR4Ayv0QV4TZwth6IK55PrCRV8R8DfxBjmLY9iB+7RJx/j2iCYe9cbiRaGXxCCoEY8mCSlSrJNPcNrUM8E9JNudjqbxEivnhCQXdcxI= Received: from BY2PR02CA0093.namprd02.prod.outlook.com (10.242.32.51) by SN1PR0201MB1872.namprd02.prod.outlook.com (10.163.76.144) with Microsoft SMTP Server (TLS) id 15.1.447.15; Thu, 7 Apr 2016 22:55:07 +0000 Received: from BL2FFO11FD031.protection.gbl (2a01:111:f400:7c09::193) by BY2PR02CA0093.outlook.office365.com (2a01:111:e400:2c2a::51) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Thu, 7 Apr 2016 22:55:06 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) 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.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by BL2FFO11FD031.mail.protection.outlook.com (10.173.160.71) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Thu, 7 Apr 2016 22:55:05 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [172.22.12.162]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id BA.95.03047.C15E6075; Thu, 7 Apr 2016 15:54:20 -0700 (PDT) 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; Thu, 7 Apr 2016 15:55:04 -0700 X-AuditID: ac160c69-5dfff70000000be7-2a-5706e51c0b17 Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 20.44.02566.845E6075; Thu, 7 Apr 2016 15:55:04 -0700 (PDT) From: Bart Van Assche Subject: [PATCH] IB/srpt: Revert "Convert to percpu_ida tag allocation" To: Linus Torvalds References: <57055BC6.7070402@sandisk.com> CC: "Nicholas A. Bellinger" , Doug Ledford , "linux-rdma@vger.kernel.org" , target-devel Message-ID: <5706E548.3080002@sandisk.com> Date: Thu, 7 Apr 2016 15:55:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <57055BC6.7070402@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsWyRoxnka7MU7ZwgznfzCxenv/AavHsUC+L RdvqM4wWrUvfMlk86nvL7sDqcWLGbxaP+9uPMHm833eVzePzJrkAligum5TUnMyy1CJ9uwSu jFd3DjMVbNWr+Hqpi6mB8ZxaFyMnh4SAicTPb8+Zuxi5OIQE5jJJzNu2iAXC2c4osebFOTaY qi8Tp4DZQgJLGSU2P9EAsdkEjCS+vZ/JAmILC7hLnJy5ihnEFgGKf35xhRWiXkti8rp+sKHM AgcZJVpOnGHvYuTg4AVKvLwdDlLDIqAi0blwGlivqECEROuDp+wgNq+AINDMJ2DzOQW0JX53 vWUCaWUW0JRYv0sfJMwsIC+x/e0csAckBLaxSny/v4cZYq+6xMkl85kmMArPQjJqFkL7LCTt CxiZVzGK5WbmFOempxYYmuoVJ+alZBZn6yXn525ihERE5g7Gu0+8DzEKcDAq8fBadLKGC7Em lhVX5h5ilOBgVhLhPfeYLVyINyWxsiq1KD++qDQntfgQozQHi5I4r9u9L2FCAumJJanZqakF qUUwWSYOTqkGxkmvHt8N+CqvPXGD4ulEzR93gx7NbOf88mDV45vzuXlfzXdnruw6G7K1uSWr s1rhntZHg4DLZUeym9aqProZcWSz/LEPxaWWlmd532XeizK8+V662iziS5RBcvrkzQkeQev2 m1s9cWeMiZXnCLQ8K1NeFSR+r28aQ5KJiXSrJiM377GWPRYtSizFGYmGWsxFxYkAEH28TIQC AAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJJMWRmVeSWpSXmKPExsXCtZEjRdfjKVu4wdEHkhYvz39gtXh2qJfF om31GUaL1qVvmSwe9b1ld2D1ODHjN4vH/e1HmDze77vK5vF5k1wASxSXTUpqTmZZapG+XQJX xqs7h5kKtupVfL3UxdTAeE6ti5GTQ0LAROLLxClsXYxcHEICixklTv5aywySYBMwkvj2fiYL iC0s4C5xcuYqsLgIUPzziyusILaQgJbE5HX9LCDNzAKHGSX+zJrF1MXIwcELlHh5OxykhkVA RaJz4TSwXlGBCInWB0/ZQWxeAUGgmU/A5nMKaEv87nrLBGIzC6hL/Jl3iRnClpfY/nYO8wRG vllIWmYhKZuFpGwBI/MqRrHczJzi3PTMAkNDveLEvJTM4my95PzcTYzgwOSM3MH4dKL5IUYm Dk6pBsZVvXJLAxt37WOdccz46PPvqTlWc3mDQmd779yszszz/VvM5IlJ2VEPFzZLWm6/p+ax rf1fXuT+rYvN1ZSeWxsELOPcpfBmpn/goYtWbT8d9zd4nGvOP2q25sXFmp8+3/dLrNZ4/nl1 1rXvf+dL/zWYu/jwBJPdz/ijlz5t8/sxn+fFo2NW7s/ElViKMxINtZiLihMB3KGcT/wBAAA= X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(51234002)(83506001)(64126003)(106466001)(19580395003)(77096005)(19580405001)(87936001)(2270400002)(80316001)(5003600100002)(81166005)(50466002)(2950100001)(4326007)(50986999)(65806001)(65816999)(65956001)(189998001)(47776003)(230700001)(54356999)(2906002)(23676002)(4001350100001)(110136002)(59896002)(53416004)(586003)(36756003)(33656002)(76176999)(6806005)(86362001)(87266999)(1220700001)(229853001)(1096002)(92566002)(5008740100001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0201MB1872; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD031; 1:ku5jVogmBNm4/rtdL/TVDgXtAqm/mWsN+ezCqyykCdg1BLoxDCojMGmL13BEqRCVlRP6dSvo5fYvul8Dui9JdFk4HmhyNY4WXHtyIBnADFFfE1k0FwVL0UNJoxqTOAIUlL9uvubd2fe5WQjTgfUH8WBbKm/8gnXv18vZFPwGWn28mSpNubNzymyCRecR+8O2RolmOfxMle6XmAQ6cJUFwgdnEHjUkyugCyCGI/vV3Hbb3K1G680vGHTb9AAUNB3DAp7T07mPT2EHfmTaF90q0BRwh6IR8RCn6AvfjT7kV+5p+3SCTTxHmP8j1UAwFe6y/d+I7SghvdIArUJZ6RdATShWXsCRyAaXTUUeBIdlr1g7IWEvDFtfsNtSlsWWx++/SxXRFMzAcgvIr3yrt3w96OfKtN9foFix1XzEX9Gu//u8tccI3d78c/rT/VgpC2Q9kbj3zMcWjjxds42RPPKz3+96bBUKtUWEpT0K3GpuxxE= X-MS-Office365-Filtering-Correlation-Id: d1fa2c0e-bf34-4329-b12b-08d35f37a9a3 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0201MB1872; 2:f0CpPyTvItNk762xG09C6UP6VHNTyFisKDaR6izZeF5EmNLAmVxafyOk7QFIZohBkSDDU50SMkLAOGXd8D0VIl3xemo3fyglYfk0X6528xbAUjG8V0h1xqdvcWvON0bBEqAaaeXAPE/EaiSIxv8Sqxh01vIJHuZD+mkkKBi4WKkttt+RFy1Eo0wb0ok/z890; 3:drndcUlSRqjlwxEA10kO/6LdwLjhVe6ggFY6H22zTlLF8W/W53f3xnPCoDGBaoA/vsGEmLs9kQ4vlB418lO2y/TMFUtkH2evu0K4DYnFfAacUak1prKAr6pGwf3bPiF5PRt3EmeHlPt4fEURn2P7yPWEte+k/fZ8tphFY0xmRoSAzgRlRSZ43ttRv+HKbJQ4YbStXY9oZ+oQCvGQhVPaptrSRdcNqkxCmbciKvG+ZnIOyhxMHrdIIffV+V95NJmRYYyLEHNHcEGq8B1IXp//3w==; 25:ThFdbqYLN4m4ToD+/Z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hhwUtRjxdDnbF6InAoX2G2HkE+tWBUbyYQFswuAK9ASrMx8hzGxe/Jyy4IBkdMaUNFakeZOkG1HuWsfotdY7pBou/RDeYZExJImysAM2ZFfpODIvkfBWWw7bzWaMXBjU477LnkctH+d922UIxN15w4TbPU1YQqTqZYWjn8HBKaTYsvaZqyzeblKRHPOhAI2eGCS9UzCskWNJeoGhJfzuisoAbEo2tXu54S7hGGHCLDvmKDs7LwSGJPnj3OiUnGSgM1dzasqsxam3p4C1/ZNzCj35UHGKoY7S+ gbElwr4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13016025)(5005006)(8121501046)(13018025)(10201501046)(3002001); SRVR:SN1PR0201MB1872; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0201MB1872; X-Forefront-PRVS: 0905A6B2C7 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjAyMDFNQjE4NzI7MjM6YnNTcFgrNjhIUGVHalJKTE5oSmxVQk1B?= =?utf-8?B?NERteEhDdUZiaHRKQjdEYVJjYk1xL2pWYjVheVN3aGp4QnNVTlVtN3JyOFdh?= =?utf-8?B?SUtnZXROdkpPWVMzQUtxWGlCc2ljK0NDZ1lQRFBVbTVoM3VZbFl0L1dCVHZO?= =?utf-8?B?aFZOVXhudlJncGtucWdTWmI1SXJaQ0svM0lUOHMwYkJBUndqbFdJWEk0Nllu?= =?utf-8?B?WjZ2bng4VGFNL1ZCR0lCWEdDUU5JSm92ZjRVVG1qOW1ScVdqemU1OUg4dHRD?= =?utf-8?B?UmtaQmEyZVphNE1CWWFHQW85SGU3TTJ2YlFqZjBELzdUeTlVWnNUK2JRVG5v?= =?utf-8?B?Q0lnVWFsZk92UkcrYmxoNHoyMG5KeXdjWmd4bDg5UjB6b0ZHbEpPMzJWMmo2?= =?utf-8?B?Y2RnUThGeUJhUk5rQVp5dHlBN3BScWdCRk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ZUtaaG1LQlR0RjQ4WUZENkRLcG5HQTJaZ0Q1RzRiK3F5ZFRsTW1o?= =?utf-8?B?eFdFM3h0R0M3RzN4Z25hYW4vU3RGM3d4U2RQQlU2bnFOOFVYaml5Wm9UZFFS?= =?utf-8?B?TGpYVjRtaW9aUEh0ejRuK3MzTzA4ckdwS2xNSGJSM1JVS3lxUStwU0YwYk9Y?= =?utf-8?B?N0hLYm90NjRZekdEallhK2RvK05rY1hlUEJRRHVWK1RoRXNkN1h0NlA4TEg3?= =?utf-8?B?NlpkREZ6clhrMjhyM1FHVXpWbndqYUkxSW1vNG9OVjNlNTdoQnlTTDA3U2lH?= =?utf-8?Q?Y=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0201MB1872; 5:wB6gXitI3sHxegYS7ytyyUhBvuMVpFfRpC85JKk9fl+f/u42NvnwgYZYwQG5bFBc05cm2lNmFsngD3BuS7BcGBO91nybks2N8cbppDG/Bmuo6A9Cg374JneY7Xmxvj/Ng1qfdrISyI4AIiQzOEZsHA==; 24:T1V0e/D90a8Td1Lx92SzTAtSFhMbNryuye7cY8PAR2ngPbb4BU6oPkGIuBaHQwh88YgGXgenGj2LCsG3xsnl3LFy8VhEqp6vDi9gMhKEWe8=; 20:7vcAanVBd1pBj465T0RVv6xOk1yzxOqBUqybaQR8VCZcmbhye1SW3R+oyO3/87JM9Q8CfeFThuj9GutO0ruPDEktAU10dAoay0ckI3Gjr4emtt0i6OkFSlWMgpagaH7GW9Xlod5kZcsk96dcZ7eEez6f6SJcKP+5neQykcCJb+DQz+DMVJklNmF9aEKNiQ5f/qJxQlVTDOmoO5B9TG5yt6e4Awm/Qu48T7bC3HWPpan/R5EOUYdQiaiUNd7KYtxb SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2016 22:55:05.7985 (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.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0201MB1872 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.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 That patch causes the ib_srpt driver to crash as soon as the first SCSI command is received. This means that that patch was untested. Hence revert it. The shortcomings of that patch are as follows: - It makes the ib_srpt driver use I/O contexts allocated by transport_alloc_session_tags() but it does not initialize these I/O contexts properly. All the initializations performed by srpt_alloc_ioctx() are skipped. - It swaps the order of the send ioctx allocation and the transition to RTR mode which is wrong. - The amount of memory that is needed for I/O contexts is doubled. - srpt_rdma_ch.free_list is no longer used but is not removed. Revert commit 0fd10721fe36 and thereby fix the following kernel crash: kernel BUG at drivers/infiniband/ulp/srpt/ib_srpt.c:1439! invalid opcode: 0000 [#1] SMP Workqueue: target_completion target_complete_ok_work [target_core_mod] RIP: 0010:[] [] srpt_queue_response+0x437/0x4a0 [ib_srpt] Call Trace: [] srpt_queue_data_in+0x9/0x10 [ib_srpt] [] target_complete_ok_work+0x152/0x2b0 [target_core_mod] [] process_one_work+0x197/0x480 [] worker_thread+0x49/0x490 [] kthread+0xea/0x100 [] ret_from_fork+0x22/0x40 Signed-off-by: Bart Van Assche Cc: Nicholas Bellinger --- drivers/infiniband/ulp/srpt/ib_srpt.c | 55 ++++++++++++++++++++++++----------- drivers/infiniband/ulp/srpt/ib_srpt.h | 2 ++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 13594db..3b425af 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1264,26 +1264,40 @@ free_mem: */ static struct srpt_send_ioctx *srpt_get_send_ioctx(struct srpt_rdma_ch *ch) { - struct se_session *se_sess; struct srpt_send_ioctx *ioctx; - int tag; + unsigned long flags; BUG_ON(!ch); - se_sess = ch->sess; - tag = percpu_ida_alloc(&se_sess->sess_tag_pool, TASK_RUNNING); - if (tag < 0) { - pr_err("Unable to obtain tag for srpt_send_ioctx\n"); - return NULL; + ioctx = NULL; + spin_lock_irqsave(&ch->spinlock, flags); + if (!list_empty(&ch->free_list)) { + ioctx = list_first_entry(&ch->free_list, + struct srpt_send_ioctx, free_list); + list_del(&ioctx->free_list); } - ioctx = &((struct srpt_send_ioctx *)se_sess->sess_cmd_map)[tag]; - memset(ioctx, 0, sizeof(struct srpt_send_ioctx)); - ioctx->ch = ch; + spin_unlock_irqrestore(&ch->spinlock, flags); + + if (!ioctx) + return ioctx; + + BUG_ON(ioctx->ch != ch); spin_lock_init(&ioctx->spinlock); ioctx->state = SRPT_STATE_NEW; + ioctx->n_rbuf = 0; + ioctx->rbufs = NULL; + ioctx->n_rdma = 0; + ioctx->n_rdma_wrs = 0; + ioctx->rdma_wrs = NULL; + ioctx->mapped_sg_count = 0; init_completion(&ioctx->tx_done); - - ioctx->cmd.map_tag = tag; + ioctx->queue_status_only = false; + /* + * transport_init_se_cmd() does not initialize all fields, so do it + * here. + */ + memset(&ioctx->cmd, 0, sizeof(ioctx->cmd)); + memset(&ioctx->sense_data, 0, sizeof(ioctx->sense_data)); return ioctx; } @@ -2013,7 +2027,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, struct ib_cm_rep_param *rep_param; struct srpt_rdma_ch *ch, *tmp_ch; u32 it_iu_len; - int ret = 0; + int i, ret = 0; unsigned char *p; WARN_ON_ONCE(irqs_disabled()); @@ -2135,6 +2149,12 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, if (!ch->ioctx_ring) goto free_ch; + INIT_LIST_HEAD(&ch->free_list); + for (i = 0; i < ch->rq_size; i++) { + ch->ioctx_ring[i]->ch = ch; + list_add_tail(&ch->ioctx_ring[i]->free_list, &ch->free_list); + } + ret = srpt_create_ch_ib(ch); if (ret) { rej->reason = cpu_to_be32( @@ -2165,8 +2185,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, p = &ch->sess_name[0]; try_again: - ch->sess = target_alloc_session(&sport->port_tpg_1, ch->rq_size, - sizeof(struct srpt_send_ioctx), + ch->sess = target_alloc_session(&sport->port_tpg_1, 0, 0, TARGET_PROT_NORMAL, p, ch, NULL); if (IS_ERR(ch->sess)) { pr_info("Rejected login because no ACL has been" @@ -2873,7 +2892,7 @@ static void srpt_release_cmd(struct se_cmd *se_cmd) struct srpt_send_ioctx *ioctx = container_of(se_cmd, struct srpt_send_ioctx, cmd); struct srpt_rdma_ch *ch = ioctx->ch; - struct se_session *se_sess = ch->sess; + unsigned long flags; WARN_ON(ioctx->state != SRPT_STATE_DONE); WARN_ON(ioctx->mapped_sg_count != 0); @@ -2884,7 +2903,9 @@ static void srpt_release_cmd(struct se_cmd *se_cmd) ioctx->n_rbuf = 0; } - percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); + spin_lock_irqsave(&ch->spinlock, flags); + list_add(&ioctx->free_list, &ch->free_list); + spin_unlock_irqrestore(&ch->spinlock, flags); } /** diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h index ca288f0..af9b8b5 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -179,6 +179,7 @@ struct srpt_recv_ioctx { * struct srpt_send_ioctx - SRPT send I/O context. * @ioctx: See above. * @ch: Channel pointer. + * @free_list: Node in srpt_rdma_ch.free_list. * @n_rbuf: Number of data buffers in the received SRP command. * @rbufs: Pointer to SRP data buffer array. * @single_rbuf: SRP data buffer if the command has only a single buffer. @@ -201,6 +202,7 @@ struct srpt_send_ioctx { struct srp_direct_buf *rbufs; struct srp_direct_buf single_rbuf; struct scatterlist *sg; + struct list_head free_list; spinlock_t spinlock; enum srpt_command_state state; struct se_cmd cmd;