From nobody Fri May 3 18:39:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552317313548423.6082465438129; Mon, 11 Mar 2019 08:15:13 -0700 (PDT) Received: from localhost ([127.0.0.1]:35100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Mdy-0002hh-22 for importer@patchew.org; Mon, 11 Mar 2019 11:15:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3MaT-0008NY-IK for qemu-devel@nongnu.org; Mon, 11 Mar 2019 11:11:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3MaS-0001nV-LE for qemu-devel@nongnu.org; Mon, 11 Mar 2019 11:11:33 -0400 Received: from mga03.intel.com ([134.134.136.65]:59318) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3MaR-0001er-MV for qemu-devel@nongnu.org; Mon, 11 Mar 2019 11:11:32 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2019 08:11:22 -0700 Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by orsmga007.jf.intel.com with ESMTP; 11 Mar 2019 08:11:21 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,468,1544515200"; d="scan'208";a="121690362" From: Keith Busch To: qemu-devel@nongnu.org, Kevin Wolf Date: Mon, 11 Mar 2019 09:11:53 -0600 Message-Id: <20190311151153.10516-1-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [PATCH] nvme: fix write zeroes offset and count X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , linux-nvme@lists.infradead.org, Ming Lei Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The implementation used blocks units rather than the expected bytes. Fixes: c03e7ef12a9 ("nvme: Implement Write Zeroes") Reported-by: Ming Lei Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- hw/block/nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 7c8c63e8f5..e8fe8f1ddd 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -324,8 +324,8 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNames= pace *ns, NvmeCmd *cmd, const uint8_t data_shift =3D ns->id_ns.lbaf[lba_index].ds; uint64_t slba =3D le64_to_cpu(rw->slba); uint32_t nlb =3D le16_to_cpu(rw->nlb) + 1; - uint64_t aio_slba =3D slba << (data_shift - BDRV_SECTOR_BITS); - uint32_t aio_nlb =3D nlb << (data_shift - BDRV_SECTOR_BITS); + uint64_t offset =3D slba << data_shift; + uint32_t count =3D nlb << data_shift; =20 if (unlikely(slba + nlb > ns->id_ns.nsze)) { trace_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze); @@ -335,7 +335,7 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNames= pace *ns, NvmeCmd *cmd, req->has_sg =3D false; block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0, BLOCK_ACCT_WRITE); - req->aiocb =3D blk_aio_pwrite_zeroes(n->conf.blk, aio_slba, aio_nlb, + req->aiocb =3D blk_aio_pwrite_zeroes(n->conf.blk, offset, count, BDRV_REQ_MAY_UNMAP, nvme_rw_cb, re= q); return NVME_NO_COMPLETE; } --=20 2.14.4