From nobody Mon Feb 9 23:59:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162499435497070.11068302040451; Tue, 29 Jun 2021 12:19:14 -0700 (PDT) Received: from localhost ([::1]:38482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyJGL-0007Qd-Gg for importer@patchew.org; Tue, 29 Jun 2021 15:19:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyImc-0001T4-Bs; Tue, 29 Jun 2021 14:48:30 -0400 Received: from wnew1-smtp.messagingengine.com ([64.147.123.26]:58629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyImW-0005Qm-0I; Tue, 29 Jun 2021 14:48:30 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id D29062B00AB1; Tue, 29 Jun 2021 14:48:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 29 Jun 2021 14:48:22 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 29 Jun 2021 14:48:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=sayXcsn4DEb9/ gACYLFIhgMEM0NU2CKj9XIdsqrahu4=; b=B6so6S1vONCZZGuVwMubtDDy1SLsV RNzqlcumX5aohbRCRCG2oWucN8jk9/Cv78b0VG2Pe7vv3tuS51xwPK5tYN9yCOfu DU3ODmZ0phCpzwmrUWYADOYm1Xxkp8mSYU6cQrHtZUrg5atKdmn0RyYe8ygcCXv8 fElNLFHE7HnSJWVBq2B8Y3DLjM1/D78uKIiWJgKxsX8DqczS0tGW6LEbCui9GpW4 ybSTkWiFKA6wsvUQeMMUX5A/LF9Ha/YZcVXV1GBjKtBNwUNS8UMYe9Ln88vgk7+N s74DrBMFmcNU6L7WUI9sUtzOndCaInycT0oI6lTfDLH8JVLw1Ud6f693g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=sayXcsn4DEb9/gACYLFIhgMEM0NU2CKj9XIdsqrahu4=; b=T9tgSc/S YW9Mehv4MU/ZkW/J1b3fBXAnFgLMQdzpogWP6mZwD+EOSktGOY0jZqME30rP9X6k pEcbX4r9JnkarUWohJvlbCY2LdxHJiZthIkoJowPgtS3e6nbUhEL3xnnl0fHVYun zmvVh18jWhnhOtoO4z5XTBzsmMkDMmtlTpVDlTODjHL2Ja4I3ZKCVSlsQlBSM8Ur Ys+GcZUB19YAXPFQv2mgWVGSzyA7PhJb2Hhm3mFM/ShichS54pd/k0sE9EJFK8wn /IoCS71OT7jB24fOvhNMTBIicBLj/Vjagr6Z2kkCNfyiOW1/7k5o+XVCq9P4f/oA z9GnBsOZ4p90jg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeitddgleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 09/23] hw/nvme: add nvme_block_status_all helper Date: Tue, 29 Jun 2021 20:47:29 +0200 Message-Id: <20210629184743.230173-10-its@irrelevant.dk> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210629184743.230173-1-its@irrelevant.dk> References: <20210629184743.230173-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=64.147.123.26; envelope-from=its@irrelevant.dk; helo=wnew1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Klaus Jensen , Max Reitz , Keith Busch , Stefan Hajnoczi , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Pull the gist of nvme_check_dulbe() into a helper function. This is in preparation for dsm refactoring. Signed-off-by: Klaus Jensen Reviewed-by: Keith Busch --- hw/nvme/ctrl.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 26c65a12e80c..5777c7ea1704 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1438,18 +1438,15 @@ static inline uint16_t nvme_check_bounds(NvmeNamesp= ace *ns, uint64_t slba, return NVME_SUCCESS; } =20 -static uint16_t nvme_check_dulbe(NvmeNamespace *ns, uint64_t slba, - uint32_t nlb) +static int nvme_block_status_all(NvmeNamespace *ns, uint64_t slba, + uint32_t nlb, int flags) { BlockDriverState *bs =3D blk_bs(ns->blkconf.blk); =20 int64_t pnum =3D 0, bytes =3D nvme_l2b(ns, nlb); int64_t offset =3D nvme_l2b(ns, slba); - bool zeroed; int ret; =20 - Error *local_err =3D NULL; - /* * `pnum` holds the number of bytes after offset that shares the same * allocation status as the byte at offset. If `pnum` is different from @@ -1461,23 +1458,41 @@ static uint16_t nvme_check_dulbe(NvmeNamespace *ns,= uint64_t slba, =20 ret =3D bdrv_block_status(bs, offset, bytes, &pnum, NULL, NULL); if (ret < 0) { - error_setg_errno(&local_err, -ret, "unable to get block status= "); - error_report_err(local_err); - - return NVME_INTERNAL_DEV_ERROR; + return ret; } =20 - zeroed =3D !!(ret & BDRV_BLOCK_ZERO); =20 - trace_pci_nvme_block_status(offset, bytes, pnum, ret, zeroed); + trace_pci_nvme_block_status(offset, bytes, pnum, ret, + !!(ret & BDRV_BLOCK_ZERO)); =20 - if (zeroed) { - return NVME_DULB; + if (!(ret & flags)) { + return 1; } =20 offset +=3D pnum; } while (pnum !=3D bytes); =20 + return 0; +} + +static uint16_t nvme_check_dulbe(NvmeNamespace *ns, uint64_t slba, + uint32_t nlb) +{ + int ret; + Error *err =3D NULL; + + ret =3D nvme_block_status_all(ns, slba, nlb, BDRV_BLOCK_DATA); + if (ret) { + if (ret < 0) { + error_setg_errno(&err, -ret, "unable to get block status"); + error_report_err(err); + + return NVME_INTERNAL_DEV_ERROR; + } + + return NVME_DULB; + } + return NVME_SUCCESS; } =20 --=20 2.32.0