From patchwork Thu Jun 11 15:53:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dakshaja Uppalapati X-Patchwork-Id: 224573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCE59C433E0 for ; Thu, 11 Jun 2020 15:56:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA3E62075E for ; Thu, 11 Jun 2020 15:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728496AbgFKP4z (ORCPT ); Thu, 11 Jun 2020 11:56:55 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:40346 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726863AbgFKP4z (ORCPT ); Thu, 11 Jun 2020 11:56:55 -0400 Received: from moto.blr.asicdesigners.com (moto.blr.asicdesigners.com [10.193.184.79] (may be forged)) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 05BFrs76005517; Thu, 11 Jun 2020 08:55:30 -0700 From: Dakshaja Uppalapati To: eduard@hasenleithner.at, kbusch@kernel.org, sagi@grimberg.me, hch@lst.de Cc: stable@vger.kernel.org, nirranjan@chelsio.com, bharat@chelsio.com, dakshaja@chelsio.com, Logan Gunthorpe , Jens Axboe Subject: [PATCH for-stable nvmet 3/6] nvmet: Introduce nvmet_dsm_len() helper Date: Thu, 11 Jun 2020 21:23:36 +0530 Message-Id: <20200611155339.9429-4-dakshaja@chelsio.com> X-Mailer: git-send-email 2.18.0.232.gb7bd9486b.dirty In-Reply-To: <20200611155339.9429-1-dakshaja@chelsio.com> References: <20200611155339.9429-1-dakshaja@chelsio.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Similar to the nvmet_rw_len helper. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Dakshaja Uppalapati Signed-off-by: Christoph Hellwig [split patch, update changelog] Signed-off-by: Logan Gunthorpe Signed-off-by: Keith Busch Signed-off-by: Jens Axboe --- drivers/nvme/target/io-cmd-file.c | 3 +-- drivers/nvme/target/nvmet.h | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 05453f5d1448..7481556da6e6 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -379,8 +379,7 @@ u16 nvmet_file_parse_io_cmd(struct nvmet_req *req) return 0; case nvme_cmd_dsm: req->execute = nvmet_file_execute_dsm; - req->data_len = (le32_to_cpu(cmd->dsm.nr) + 1) * - sizeof(struct nvme_dsm_range); + req->data_len = nvmet_dsm_len(req); return 0; case nvme_cmd_write_zeroes: req->execute = nvmet_file_execute_write_zeroes; diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index c51f8dd01dc4..6ccf2d098d9f 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -495,6 +495,12 @@ static inline u32 nvmet_rw_len(struct nvmet_req *req) req->ns->blksize_shift; } +static inline u32 nvmet_dsm_len(struct nvmet_req *req) +{ + return (le32_to_cpu(req->cmd->dsm.nr) + 1) * + sizeof(struct nvme_dsm_range); +} + u16 errno_to_nvme_status(struct nvmet_req *req, int errno); /* Convert a 32-bit number to a 16-bit 0's based number */