From: Klaus Jensen <its@irrelevant.dk>
To: Minwoo Im <minwoo.im.dev@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>,
Gollu Appalanaidu <anaidu.gollu@samsung.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH] hw/block/nvme: add compare command
Date: Wed, 25 Nov 2020 15:15:50 +0100 [thread overview]
Message-ID: <X75nFo7LD7Ltb4MF@apples.localdomain> (raw)
In-Reply-To: <20201125141104.bs5fwi7xtyo4nyv7@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2359 bytes --]
On Nov 25 23:11, Minwoo Im wrote:
> Hello,
>
> On 20-11-24 08:37:14, Klaus Jensen wrote:
> > From: Gollu Appalanaidu <anaidu.gollu@samsung.com>
> >
> > Add the Compare command.
> >
> > This implementation uses a bounce buffer to read in the data from
> > storage and then compare with the host supplied buffer.
> >
> > Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
> > [k.jensen: rebased]
> > Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> > ---
> > hw/block/nvme.c | 100 +++++++++++++++++++++++++++++++++++++++++-
> > hw/block/trace-events | 2 +
> > 2 files changed, 101 insertions(+), 1 deletion(-)
> >
> > 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);
> > }
> >
> > +struct nvme_compare_ctx {
> > + QEMUIOVector iov;
> > + uint8_t *bounce;
> > + size_t len;
> > +};
> > +
> > +static void nvme_compare_cb(void *opaque, int ret)
> > +{
> > + NvmeRequest *req = opaque;
> > + NvmeNamespace *ns = req->ns;
> > + struct nvme_compare_ctx *ctx = req->opaque;
> > + g_autofree uint8_t *buf = NULL;
>
> nit-picking here: unnecessary initialization to NULL.
>
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 = g_malloc(ctx->len);
> > +
> > + status = nvme_dma(nvme_ctrl(req), buf, ctx->len, DMA_DIRECTION_TO_DEVICE,
> > + req);
> > + if (status) {
> > + goto out;
> > + }
>
> Don't we need to give status value to req->status in case of
> (status != 0)? If we don't give it to req->status, it will complete
> with success status code even it fails during the nvme_dma().
>
Nice catch! nvme_aio_err normally takes care of this for blk/aio errors,
but this one slipped. Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2020-11-25 14:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 7:37 [PATCH] hw/block/nvme: add compare command Klaus Jensen
2020-11-25 14:11 ` Minwoo Im
2020-11-25 14:15 ` Klaus Jensen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=X75nFo7LD7Ltb4MF@apples.localdomain \
--to=its@irrelevant.dk \
--cc=anaidu.gollu@samsung.com \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=minwoo.im.dev@gmail.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).