From patchwork Thu Feb 11 19:05:19 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: 8284551 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 64D41BEEE5 for ; Thu, 11 Feb 2016 19:05:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48F3720222 for ; Thu, 11 Feb 2016 19:05:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1217320121 for ; Thu, 11 Feb 2016 19:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750987AbcBKTF2 (ORCPT ); Thu, 11 Feb 2016 14:05:28 -0500 Received: from mail-bn1bon0067.outbound.protection.outlook.com ([157.56.111.67]:4917 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750974AbcBKTFZ (ORCPT ); Thu, 11 Feb 2016 14:05:25 -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=rxrXKhHk1tRTHvFk3KvX6f3UrMhGiHsSxA9yvPpuhcM=; b=rCf1VWVaJJFgqapgZDxDj01lZ0th/1QPTrhJTpIH/21QPXAMxHttbx2ohTwzfSf5f9Q1FOhVs7zjF7pTflPL5xrXFsOKHVVTsRqtis8m29hKM7GHOil2lmx1xZTFOgi2o4B+zD6sc6jEmlNOxD/TXseUCPe4kEF44HQ4K8K1Uiw= Received: from BY2PR02CA0022.namprd02.prod.outlook.com (10.141.216.12) by BN1PR0201MB0817.namprd02.prod.outlook.com (10.160.170.15) with Microsoft SMTP Server (TLS) id 15.1.403.16; Thu, 11 Feb 2016 19:05:23 +0000 Received: from BN1AFFO11FD030.protection.gbl (2a01:111:f400:7c10::164) by BY2PR02CA0022.outlook.office365.com (2a01:111:e400:2c40::12) with Microsoft SMTP Server (TLS) id 15.1.409.15 via Frontend Transport; Thu, 11 Feb 2016 19:05:22 +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 BN1AFFO11FD030.mail.protection.outlook.com (10.58.52.168) with Microsoft SMTP Server id 15.1.415.6 via Frontend Transport; Thu, 11 Feb 2016 19:05:20 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by (Symantec Messaging Gateway) with SMTP id 87.16.02658.07BDCB65; Thu, 11 Feb 2016 11:05:20 -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, 11 Feb 2016 11:05:19 -0800 X-AuditID: ac160a68-70fff70000000a62-ed-56bcdb70b588 Received: from [10.60.52.49] ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 44.83.03361.F6BDCB65; Thu, 11 Feb 2016 11:05:19 -0800 (PST) Subject: [PATCH v4 07/21] IB/srpt: Use scsilun_to_int() To: Doug Ledford References: <56BCDAAD.7030906@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , "Alex Estrin" , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <56BCDB6F.3070807@sandisk.com> Date: Thu, 11 Feb 2016 11:05:19 -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: <56BCDAAD.7030906@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRmVeSWpSXmKPExsWyRoxnkW7B7T1hBjfaGC0uPP3OZPHy/AdW i5WrjzJZPDvUy2Jxo+0BmwOrx+I9L5k8dt9sYPN4Nv0wk8f7fVfZPD5vkgtgjeKySUnNySxL LdK3S+DKmHT4AXtBi0rF1b+L2BoYf8l0MXJySAiYSOzq387cxcjFISSwiVFi7uxfUM4ORokl /XfZYKpefHjLApGYwyhxenM/WEJYwFzizq/vYLaIgJrEpleL2EFsIQEtief9/awgDcwCqxgl Nl29DpZgEzCS+PZ+JguIzQtUtP/DHlYQm0VAVeLChW5mEFtUIELicGcXO0SNoMTJmU+A6jk4 OAW0JWZeiQAxmQU0Jdbv0gepYBaQl9j+dg7Y0RICB1klVkxexwxxg7rEySXzmSYwCs9CMmkW QvssJO0LGJlXMYrlZuYU56anFhga6hUn5qVkFmfrJefnbmIERwdXxg7GrZPMDzEKcDAq8fDe uL4nTIg1say4MvcQowQHs5II7/1NQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK81i1qYUIC6Ykl qdmpqQWpRTBZJg5OqQbGhiNuuTH1jrnvYwx9RY7GdOz7FMdSv1409Wy3BuOPxTvb81Q/h+Vd fXdeJN/6tb+uyTRDuXdBR383iqeliv49KrhH8YKRkudCbna3XjvRuCtvljl0eu3NjH1gxz/x dxEfT0+KkbVcq9pRhv4tkqwXu++LTDb1/v6588HJ9kAl//5X6h8ncSqxFGckGmoxFxUnAgAs gT9OigIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHJMWRmVeSWpSXmKPExsXCtZEjRTf/9p4wgyWXdCwuPP3OZPHy/AdW i5WrjzJZPDvUy2Jxo+0BmwOrx+I9L5k8dt9sYPN4Nv0w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Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(229853001)(5008740100001)(86362001)(2906002)(83506001)(33656002)(77096005)(92566002)(36756003)(4326007)(59896002)(1220700001)(2950100001)(586003)(65816999)(106466001)(50466002)(19580405001)(5001960100002)(65956001)(19580395003)(80316001)(47776003)(54356999)(1096002)(50986999)(189998001)(11100500001)(4001350100001)(87266999)(65806001)(76176999)(87936001)(23676002)(64126003)(230700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0201MB0817; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0817; 2:3y49+dtY5RYujaxZHm/DYeKcCFafAATbOERRs/bPcReoWBr21TIFRI2OJoKsVcsi8FYkO+RU6ZhHEunlBEACXzrxyMIPmS2pJocA5Ie/sjnL9idNoSzMiXx1bAnA/Yv2Ci0vBb1P9HkxYkDrX35IsA==; 3:E/85bLg2jb8rYBuk+pK28AzpVPAGUtwTG1K/5tEE0bh/uQWy/P9Rx5Oy6XUSXhb6Gh9ui+iA8EUvyt1PcJwP9W6x5QJqeFXyf//BQFabwJFcs8AULMIQxEqZ5wSWTlHCBO1hvrVvbO/i5MzvSq0vlRFbvY83mMfcBCYoucrduCbIoKSK5SXR6SJEBV3CFhTgRhQRcMu8lLnw5+mRiOVA1u3uDro02Z+nPqD3x6npVN40ks0QrRUQEZlwbLjRpe+8h6VuN4QZNV+m6Qx1HulL0Q==; 25:PQd7qJDLfojCb0nUAz7ZeLpgKvQUP6SA06yljoNdVx4S5BNR9HyHprqpnIdXfho2FMEcf4nEoFgTGMlGaXYlslVX07ye96Lwfjdr+AfLIWEQobIisjD2p7XgnkqGN//rx9l2yxvQVk6uM6RH1A6fAvWGBHTGtOaBkfEe1p7558hMVA4Ob+UsEjyDHrsh3y/Dmva+NmY/Hv6rvryiTfFVUfg1cNHHxN0aTRe/Mb+JQdftUYXcyIYS/l9wSQTcZcAtB8BSK07PEwGbdY8ulwukXJY+chV0pqXN9jE4lfUFKL5P7/DLhccjjATw11UNJQG3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BN1PR0201MB0817; X-MS-Office365-Filtering-Correlation-Id: 38e74f6d-a0ea-45ca-b720-08d333164a40 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0817; 20:91h6wQbiZR+JMsybd3TgFp2GHE8X6N6uuYXmTNnSAFRlf/lGSJhLAETa720Lj0nG/VcspZ9pELt/0I2uM9Dc+t5GmnPLh2asa5klIP/u+zYNtZ2m6IXk/twklp8wxIh4E2/WWBTrO2PWsCGtomBt8HJS56TMbVisiZLG1MvdykmGAhXr9dtQmFPgUCKSXfsP+PiNN807muyQJ9tUUBCRWlKzvGhm81t0Cq6HlD5mcstV/cVqmTOP0oC65SGOiMb8E3h69rA1ZrYlvlFjrHc0TBjFmAIjZ3Dtrxsr8igHPoPWpKOEYUK1lM1dHdu7HuPo6LkR45XZtYPFBsD9zoasWFUzPLbKaRCPNplguwX9A8iqDJFhI/JrJdTd9B7ImCGHFcvXYSuKU3vSduw9lin5ZkUkK+c5GQx4Te0ZzFToCaBsDAali8BEGt3bDNkIG68syTkVDu88lSoV8TLot1OGG/vAg69Lz0O7f23PyedIvfoMPz56oiMWjTX0uMUHG0ld X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(13018025)(13024025)(13015025)(13023025)(8121501046)(5005006)(10201501046)(3002001); SRVR:BN1PR0201MB0817; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0201MB0817; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0817; 4:ECy3blPE6P1+6OfWgWgXcnM5kW7h0Yl7i0Adq+2SaEk6o9s2s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UZjc1ZxMHRqNGgrRnAyTld3MHFC?= =?utf-8?B?aEZwdVpTbnFta2ZnNGtVenR2R0lHS1A0MnlodGJWZCtKQlZNazR4RGV4RE05?= =?utf-8?Q?8W2DPnPQetass34xekl498+sobnE2?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0817; 5:tcIn7MT7RMNLFPbru67juDIafrcFIZ36JqzyfufGQszCZuSLJY2KdNPW+MXuZ0RFXo/NKf9I19LsLz0Y42YD61wYXTIGuEV9eiyjoNy7LqiidqZh/WPTOtaaJFjuov9+RAM4BfHh/8+y5HhvhF4iNQ==; 24:fzfR6kCBxhTOj5l9KgYEyntvK+7dxZaCoy1bzHMikyqXs+vCkKJfy2DLoMypTyt06o/YINzWCgtZS/1k2Gzzs2gZos9CRoe14JmCccCjxgA=; 20:96cy6XN5oWXxxQNc9XCZuoxV/BL0+c3TB1iIxhe2sMWnLiMtZdpZQtpVGljklJJKzDlQxb1YrKiYCbHYwW4YT91qpEEjdwHvj5L/FBgNawLCjZ6abptpI5qJvMm4W/fKy+qpKV0KrpxB7O3avwi4yRknR3V5IdnEHxvVQ2+11cVo2+79vTeZTHpISjlG8LBN565JXa0NSnTtUh+ITGUKFMqd+/K7b6WRmKHfq/xDhYLDFY1F8taaDB0GggA9gG6r SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2016 19:05:20.8844 (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: BN1PR0201MB0817 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.0 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 Just like other target drivers, use scsilun_to_int() to unpack SCSI LUN numbers. This patch only changes the behavior of ib_srpt for LUN numbers >= 16384. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Cc: Alex Estrin --- drivers/infiniband/ulp/srpt/ib_srpt.c | 92 +++-------------------------------- 1 file changed, 7 insertions(+), 85 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 5da59f4..716f429 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1494,80 +1494,6 @@ static int srpt_build_tskmgmt_rsp(struct srpt_rdma_ch *ch, return resp_len; } -#define NO_SUCH_LUN ((uint64_t)-1LL) - -/* - * SCSI LUN addressing method. See also SAM-2 and the section about - * eight byte LUNs. - */ -enum scsi_lun_addr_method { - SCSI_LUN_ADDR_METHOD_PERIPHERAL = 0, - SCSI_LUN_ADDR_METHOD_FLAT = 1, - SCSI_LUN_ADDR_METHOD_LUN = 2, - SCSI_LUN_ADDR_METHOD_EXTENDED_LUN = 3, -}; - -/* - * srpt_unpack_lun() - Convert from network LUN to linear LUN. - * - * Convert an 2-byte, 4-byte, 6-byte or 8-byte LUN structure in network byte - * order (big endian) to a linear LUN. Supports three LUN addressing methods: - * peripheral, flat and logical unit. See also SAM-2, section 4.9.4 (page 40). - */ -static uint64_t srpt_unpack_lun(const uint8_t *lun, int len) -{ - uint64_t res = NO_SUCH_LUN; - int addressing_method; - - if (unlikely(len < 2)) { - pr_err("Illegal LUN length %d, expected 2 bytes or more\n", - len); - goto out; - } - - switch (len) { - case 8: - if ((*((__be64 *)lun) & - cpu_to_be64(0x0000FFFFFFFFFFFFLL)) != 0) - goto out_err; - break; - case 4: - if (*((__be16 *)&lun[2]) != 0) - goto out_err; - break; - case 6: - if (*((__be32 *)&lun[2]) != 0) - goto out_err; - break; - case 2: - break; - default: - goto out_err; - } - - addressing_method = (*lun) >> 6; /* highest two bits of byte 0 */ - switch (addressing_method) { - case SCSI_LUN_ADDR_METHOD_PERIPHERAL: - case SCSI_LUN_ADDR_METHOD_FLAT: - case SCSI_LUN_ADDR_METHOD_LUN: - res = *(lun + 1) | (((*lun) & 0x3f) << 8); - break; - - case SCSI_LUN_ADDR_METHOD_EXTENDED_LUN: - default: - pr_err("Unimplemented LUN addressing method %u\n", - addressing_method); - break; - } - -out: - return res; - -out_err: - pr_err("Support for multi-level LUNs has not yet been implemented\n"); - goto out; -} - static int srpt_check_stop_free(struct se_cmd *cmd) { struct srpt_send_ioctx *ioctx = container_of(cmd, @@ -1585,7 +1511,6 @@ static int srpt_handle_cmd(struct srpt_rdma_ch *ch, { struct se_cmd *cmd; struct srp_cmd *srp_cmd; - uint64_t unpacked_lun; u64 data_len; enum dma_data_direction dir; sense_reason_t ret; @@ -1620,11 +1545,10 @@ static int srpt_handle_cmd(struct srpt_rdma_ch *ch, goto send_sense; } - unpacked_lun = srpt_unpack_lun((uint8_t *)&srp_cmd->lun, - sizeof(srp_cmd->lun)); rc = target_submit_cmd(cmd, ch->sess, srp_cmd->cdb, - &send_ioctx->sense_data[0], unpacked_lun, data_len, - TCM_SIMPLE_TAG, dir, TARGET_SCF_ACK_KREF); + &send_ioctx->sense_data[0], + scsilun_to_int(&srp_cmd->lun), data_len, + TCM_SIMPLE_TAG, dir, TARGET_SCF_ACK_KREF); if (rc != 0) { ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; goto send_sense; @@ -1669,7 +1593,6 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, struct srp_tsk_mgmt *srp_tsk; struct se_cmd *cmd; struct se_session *sess = ch->sess; - uint64_t unpacked_lun; int tcm_tmr; int rc; @@ -1685,11 +1608,10 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, srpt_set_cmd_state(send_ioctx, SRPT_STATE_MGMT); send_ioctx->cmd.tag = srp_tsk->tag; tcm_tmr = srp_tmr_to_tcm(srp_tsk->tsk_mgmt_func); - unpacked_lun = srpt_unpack_lun((uint8_t *)&srp_tsk->lun, - sizeof(srp_tsk->lun)); - rc = target_submit_tmr(&send_ioctx->cmd, sess, NULL, unpacked_lun, - srp_tsk, tcm_tmr, GFP_KERNEL, srp_tsk->task_tag, - TARGET_SCF_ACK_KREF); + rc = target_submit_tmr(&send_ioctx->cmd, sess, NULL, + scsilun_to_int(&srp_tsk->lun), srp_tsk, tcm_tmr, + GFP_KERNEL, srp_tsk->task_tag, + TARGET_SCF_ACK_KREF); if (rc != 0) { send_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED; goto fail;