All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Wendel Devantier <foss@defmacro.it>
To: Klaus Jensen <its@irrelevant.dk>
Cc: qemu-devel@nongnu.org, Keith Busch <kbusch@kernel.org>,
	qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>,
	qemu-stable@nongnu.org
Subject: Re: [PATCH 3/3] hw/nvme: advance zone write pointer only once the write is committed
Date: Thu, 19 Nov 2026 11:35:29 +0000	[thread overview]
Message-ID: <20261119123529.2-foss@defmacro.it> (raw)
In-Reply-To: <20261118-fix-4520-v1-3-dfa182213376@samsung.com>



On Wed, 18 Nov 2026 13:45:36 +0100, Klaus Jensen <its@irrelevant.dk> wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
>
> nvme_do_write stages the updated zone write pointer before data is
> mapped. If that fails, the write pointer update is already staged and
> subsequent writes will be rejected if attempted at the original
> position.
>
> Move the staging down.
>
> Cc: qemu-stable@nongnu.org
> Link: https://gitlab.com/qemu-project/qemu/-/work_items/4520
> Fixes: 975b64665048 ("hw/block/nvme: refactor zone resource management")
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/nvme/ctrl.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 35e2c57851ae..5755aad1fa72 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -3800,7 +3800,7 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
>      uint64_t data_size = nvme_l2b(ns, nlb);
>      uint64_t mapped_size = data_size;
>      uint64_t data_offset;
> -    NvmeZone *zone;
> +    NvmeZone *zone = NULL;
>      NvmeZonedResult *res = (NvmeZonedResult *)&req->cqe;
>      BlockBackend *blk = ns->blkconf.blk;
>      uint16_t status;
> @@ -3893,10 +3893,6 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
>          if (status) {
>              goto invalid;
>          }
> -
> -        if (!(zone->d.za & NVME_ZA_ZRWA_VALID)) {
> -            zone->w_ptr += nlb;
> -        }
>      } else if (ns->endgrp && ns->endgrp->fdp.enabled) {
>          nvme_do_write_fdp(n, req, slba, nlb);
>      }
> @@ -3904,7 +3900,13 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
>      data_offset = nvme_l2b(ns, slba);
>  
>      if (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
> -        return nvme_dif_rw(n, req);
> +        status = nvme_dif_rw(n, req);
> +
> +        if (status != NVME_NO_COMPLETE) {
> +            return status;
> +        }
> +
> +        goto out;
>      }
>  
>      if (!wrz) {
> @@ -3922,6 +3924,11 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
>                                             req);
>      }
>  
> +out:
> +    if (ns->params.zoned && !(zone->d.za & NVME_ZA_ZRWA_VALID)) {
> +        zone->w_ptr += nlb;
> +    }
> +
>      return NVME_NO_COMPLETE;
>  
>  invalid:
>
> -- 
> 2.53.0
>
>
>

Reviewed-by: Jesper Wendel Devantier <foss@defmacro.it>



      reply	other threads:[~2026-11-19 11:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 12:45 [PATCH 0/3] hw/nvme: zns/zrwa fixes Klaus Jensen
2026-11-18 12:45 ` [PATCH 1/3] hw/nvme: fix open zone zrwa allocation Klaus Jensen
2026-11-19 11:09   ` Jesper Wendel Devantier
2026-11-18 12:45 ` [PATCH 2/3] hw/nvme: bound zrwa flush by the write area and zone write boundary Klaus Jensen
2026-11-19 11:38   ` Jesper Wendel Devantier
2026-11-18 12:45 ` [PATCH 3/3] hw/nvme: advance zone write pointer only once the write is committed Klaus Jensen
2026-11-19 11:35   ` Jesper Wendel Devantier [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=20261119123529.2-foss@defmacro.it \
    --to=foss@defmacro.it \
    --cc=its@irrelevant.dk \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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 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.