From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7E87FC5519F for ; Wed, 25 Nov 2020 14:19:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A92A206D9 for ; Wed, 25 Nov 2020 14:19:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A92A206D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=irrelevant.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khvdh-0001Bh-7p for qemu-devel@archiver.kernel.org; Wed, 25 Nov 2020 09:19:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khvaU-0008Af-Fn; Wed, 25 Nov 2020 09:16:03 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:49363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khvaS-0001Gj-4V; Wed, 25 Nov 2020 09:16:02 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 5AC31DD3; Wed, 25 Nov 2020 09:15:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 25 Nov 2020 09:15:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=htAe+SZZaZ8W/qtE4Gtr4UrTtOg 4Kv+K30N3RDpc9lg=; b=s2TSOHYJXUKbMFMWGlpT6oMLYhRM2YXwSAEmK/P2rJV yyc0Z9WE5F7IRPz9eY/1Y8MVYW3Nol62xQwcx87AkX70FEwhNSjbddx14N2saRnF n7s1x9ksgmbxMmL9vk/TKfkdiNiPYmvVqu72ETWsec3EFJaG/4XXxCel93fKHPDQ 3139QW01kAfhPB/en1w7NmUT6k1i0piYzm8C2VPkTuoGIX1HMgEg9Stvj6MOrX9F Gbk4s3LpLdB7RjFji/zWX9sbJ4PIeAgQmJINIx/AZxAAxF8rPWC0urvxhH+2ENUM xaNyJyX6cxmQ/L7auVqPWKnq1lfxyvRgSp0NtLKK4tQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type: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=fm1; bh=htAe+S ZZaZ8W/qtE4Gtr4UrTtOg4Kv+K30N3RDpc9lg=; b=jl9dOucaRIm9GV3/LsY3qB evVoQ9x+Jm8DBGh95vVfBqfJSMizK9e+J7g8BqzqhVM/iFiIELglySBDEoZCD7UO CwVDcsaczNMgKL0r59scKaJmRvXie3Hkl7NOipmxgJDqKHpIWTwMkE+a7+ODZrki 1i6V5Vwn/jcPAqL5nMkQfEg92tSKlT1qL6ENUCeRwpzNBc8f11k3GyvAMQ+UbBgm qlhdaGGTzDvGmVuTj9oPWqOqy7Arqu/dkNOUlY/kLSJvchWknD35YmNKTOnN0SYx 7J1h0xmCb1VpWXyJMl9ltVjRne8iacuFM+5ROr8NKoBl+Wz6QcneeFtJbNFLxPsw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudehtddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeejgeduffeuieetkeeileekvdeuleetveejudeileduffefjeegfffhuddvudff keenucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Received: from apples.localdomain (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id D138D3280065; Wed, 25 Nov 2020 09:15:52 -0500 (EST) Date: Wed, 25 Nov 2020 15:15:50 +0100 From: Klaus Jensen To: Minwoo Im Subject: Re: [PATCH] hw/block/nvme: add compare command Message-ID: References: <20201124073714.24458-1-its@irrelevant.dk> <20201125141104.bs5fwi7xtyo4nyv7@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Ty+wSX1Sbfmfmtu4" Content-Disposition: inline In-Reply-To: <20201125141104.bs5fwi7xtyo4nyv7@localhost.localdomain> Received-SPF: pass client-ip=64.147.123.24; envelope-from=its@irrelevant.dk; helo=wout1-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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Gollu Appalanaidu , qemu-devel@nongnu.org, Max Reitz , Keith Busch Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --Ty+wSX1Sbfmfmtu4 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Nov 25 23:11, Minwoo Im wrote: > Hello, >=20 > On 20-11-24 08:37:14, Klaus Jensen wrote: > > From: Gollu Appalanaidu > >=20 > > Add the Compare command. > >=20 > > This implementation uses a bounce buffer to read in the data from > > storage and then compare with the host supplied buffer. > >=20 > > Signed-off-by: Gollu Appalanaidu > > [k.jensen: rebased] > > Signed-off-by: Klaus Jensen > > --- > > hw/block/nvme.c | 100 +++++++++++++++++++++++++++++++++++++++++- > > hw/block/trace-events | 2 + > > 2 files changed, 101 insertions(+), 1 deletion(-) > >=20 > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > > index f7f888402b06..f88710ca3948 100644 > > --- a/hw/block/nvme.c > > +++ b/hw/block/nvme.c > > @@ -999,6 +999,50 @@ static void nvme_aio_discard_cb(void *opaque, int = ret) > > nvme_enqueue_req_completion(nvme_cq(req), req); > > } > > =20 > > +struct nvme_compare_ctx { > > + QEMUIOVector iov; > > + uint8_t *bounce; > > + size_t len; > > +}; > > + > > +static void nvme_compare_cb(void *opaque, int ret) > > +{ > > + NvmeRequest *req =3D opaque; > > + NvmeNamespace *ns =3D req->ns; > > + struct nvme_compare_ctx *ctx =3D req->opaque; > > + g_autofree uint8_t *buf =3D NULL; >=20 > nit-picking here: unnecessary initialization to NULL. >=20 I don't think it is unnecessary when it using g_autofree? > > + uint16_t status; > > + > > + trace_pci_nvme_compare_cb(nvme_cid(req)); > > + > > + if (!ret) { > > + block_acct_done(blk_get_stats(ns->blkconf.blk), &req->acct); > > + } else { > > + block_acct_failed(blk_get_stats(ns->blkconf.blk), &req->acct); > > + nvme_aio_err(req, ret); > > + goto out; > > + } > > + > > + buf =3D g_malloc(ctx->len); > > + > > + status =3D nvme_dma(nvme_ctrl(req), buf, ctx->len, DMA_DIRECTION_T= O_DEVICE, > > + req); > > + if (status) { > > + goto out; > > + } >=20 > Don't we need to give status value to req->status in case of > (status !=3D 0)? If we don't give it to req->status, it will complete > with success status code even it fails during the nvme_dma(). >=20 Nice catch! nvme_aio_err normally takes care of this for blk/aio errors, but this one slipped. Thanks! --Ty+wSX1Sbfmfmtu4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAl++ZxIACgkQTeGvMW1P DenbuQf/Vv7pB2yWRqdxoipaHjnVE1X82ZDRFyA6ixvyOITHPko1OeAB4lR8Ryol ELf0+RD+MkeJ21zprcttp1Is4WdKZFFsfwQwmX/3BYCzJLYhkv8LoHlt4LvETJRd pWFU9IE+L16QvVPMrkAxLCz1zAZluniOWl7demCmW7eSOJ+cF6ggn859OAZ6zptL /j0ZYFumzRZmIjprEIc38dCJ0EFcnfFbC7gDUs1wpITNP6GlyHIIxEcAXvIbhrgW JDq0BJPeo3omdkalagkykAh1yrakVq82MVx6Zkxs+GHqqRbY3LsIJiwXHOzC7/wt ge9HVxaqydhpQtxMcvFM44925zvSUQ== =AtM6 -----END PGP SIGNATURE----- --Ty+wSX1Sbfmfmtu4--