qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Keith Busch <kbusch@kernel.org>
Cc: Fam Zheng <fam@euphon.net>, 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>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH] hw/block/nvme: add broadcast nsid support flush command
Date: Mon, 8 Feb 2021 20:08:17 +0100	[thread overview]
Message-ID: <YCGMIcjRlw3auFNc@apples.localdomain> (raw)
In-Reply-To: <20210208185907.GA17042@redsun51.ssa.fujisawa.hgst.com>

[-- Attachment #1: Type: text/plain, Size: 2697 bytes --]

On Feb  9 03:59, Keith Busch wrote:
> On Mon, Jan 25, 2021 at 09:42:31PM +0100, Klaus Jensen wrote:
> > @@ -1644,10 +1679,56 @@ static uint16_t nvme_compare(NvmeCtrl *n, NvmeRequest *req)
> >  
> >  static uint16_t nvme_flush(NvmeCtrl *n, NvmeRequest *req)
> >  {
> > -    block_acct_start(blk_get_stats(req->ns->blkconf.blk), &req->acct, 0,
> > -                     BLOCK_ACCT_FLUSH);
> > -    req->aiocb = blk_aio_flush(req->ns->blkconf.blk, nvme_rw_cb, req);
> > -    return NVME_NO_COMPLETE;
> > +    uint32_t nsid = le32_to_cpu(req->cmd.nsid);
> > +    uintptr_t *num_flushes = (uintptr_t *)&req->opaque;
> > +    uint16_t status;
> > +    struct nvme_aio_flush_ctx *ctx;
> > +    NvmeNamespace *ns;
> > +
> > +    trace_pci_nvme_flush(nvme_cid(req), nsid);
> > +
> > +    if (nsid != NVME_NSID_BROADCAST) {
> > +        req->ns = nvme_ns(n, nsid);
> > +        if (unlikely(!req->ns)) {
> > +            return NVME_INVALID_FIELD | NVME_DNR;
> > +        }
> > +
> > +        block_acct_start(blk_get_stats(req->ns->blkconf.blk), &req->acct, 0,
> > +                         BLOCK_ACCT_FLUSH);
> > +        req->aiocb = blk_aio_flush(req->ns->blkconf.blk, nvme_rw_cb, req);
> > +        return NVME_NO_COMPLETE;
> > +    }
> > +
> > +    /* 1-initialize; see comment in nvme_dsm */
> > +    *num_flushes = 1;
> > +
> > +    for (int i = 1; i <= n->num_namespaces; i++) {
> > +        ns = nvme_ns(n, i);
> > +        if (!ns) {
> > +            continue;
> > +        }
> > +
> > +        ctx = g_new(struct nvme_aio_flush_ctx, 1);
> > +        ctx->req = req;
> > +        ctx->ns = ns;
> > +
> > +        (*num_flushes)++;
> > +
> > +        block_acct_start(blk_get_stats(ns->blkconf.blk), &ctx->acct, 0,
> > +                         BLOCK_ACCT_FLUSH);
> > +        req->aiocb = blk_aio_flush(ns->blkconf.blk, nvme_aio_flush_cb, ctx);
> > +    }
> 
> Overwriting req->aiocb with the most recent flush request doesn't seem
> right.
> 

It doesn't really matter if this[1] patch is merged, but it is wrong and
to align with the other multi-aio commands, this should just ignore the
returned aiocb.

> This whole implementation would be much simpler with the synchronous
> blk_flush() routine instead of the AIO equivalent. This is not really a
> performant feature, so I don't think it's critical to get these
> operations happening in parallel. What do you think?

It would definitely be simpler, but I believe that if there is a lot to
flush, then we won't just block the nvme device. We are holding the Big
QEMU Lock and will block most other devices as well.


  [1]: hw/block/nvme: drain namespaces on sq deletion

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-02-08 23:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25 20:42 [PATCH] hw/block/nvme: add broadcast nsid support flush command Klaus Jensen
2021-01-26 16:20 ` Stefan Hajnoczi
2021-02-08 17:48 ` Klaus Jensen
2021-02-08 18:59 ` Keith Busch
2021-02-08 19:08   ` Klaus Jensen [this message]
2021-02-10  3:32     ` Keith Busch
2021-02-10  6:42       ` Klaus Jensen
2021-02-11 16:43         ` Keith Busch
2021-02-11 18:33 ` Klaus Jensen

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=YCGMIcjRlw3auFNc@apples.localdomain \
    --to=its@irrelevant.dk \
    --cc=anaidu.gollu@samsung.com \
    --cc=fam@euphon.net \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).