All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Klaus Jensen <its@irrelevant.dk>
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: Tue, 9 Feb 2021 03:59:07 +0900	[thread overview]
Message-ID: <20210208185907.GA17042@redsun51.ssa.fujisawa.hgst.com> (raw)
In-Reply-To: <20210125204231.254925-1-its@irrelevant.dk>

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.

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?


  parent reply	other threads:[~2021-02-08 23:09 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 [this message]
2021-02-08 19:08   ` Klaus Jensen
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=20210208185907.GA17042@redsun51.ssa.fujisawa.hgst.com \
    --to=kbusch@kernel.org \
    --cc=anaidu.gollu@samsung.com \
    --cc=fam@euphon.net \
    --cc=its@irrelevant.dk \
    --cc=k.jensen@samsung.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.