Re: [PATCH RFC 2/2] nvme: enable multiple atomicity mode
From: Arthur Simchaev
Date: Tue Nov 03 2026 - 04:45:27 EST
On Tue, Sep 29, 2026 at 01:17:12PM +0200, Daniel Gomez wrote:
[...]
> @@ -993,6 +993,9 @@ static bool nvme_valid_atomic_write(struct request *req)
> struct request_queue *q = req->q;
> u32 boundary_bytes = queue_atomic_write_boundary_bytes(q);
>
> + if (q->limits.features & BLK_FEAT_ATOMIC_WRITE_MULTI)
> + return true;
> +
With the flag set this skips all checks. Since each REQ_ATOMIC bio carries
exactly one RWF_ATOMIC write (blkdev and iomap reject atomic writes that need
more than one bio), could it instead check every bio of the merged request with
__rq_for_each_bio(), using the existing size and boundary checks? That would
keep the safety net described in the comment above the function, at the cost of
a few comparisons per bio.
[...]
> +static bool nvme_mam_compliant(struct nvme_id_ns *id)
> +{
> + if (id->nabspf != id->nawupf)
> + return false;
> + if (id->nabsn && id->nabsn != id->nabspf)
> + return false;
> + if (id->nawun && id->nawun != id->nawupf)
> + return false;
> + return true;
> +}
This deliberately accepts NABSN == 0 and NAWUN == 0. I assume this is because
Linux only uses the power-fail values (NAWUPF/NABSPF) for atomic writes? If so,
a comment would help. Still, NVM Command Set 1.1 Figure 9 requires NABSN to
equal NAWUN (or AWUN when NAWUN is not reported) and NABSPF in MAM. NABSN == 0
means no boundary for normal operation while the device claims MAM, and NAWUN ==
0 would need NABSN == AWUN, which the driver does not track today. Would it be
safer to treat both as inconsistent, as your QEMU series does?
[...]
> + if (id->nsfeat & NVME_NS_FEAT_MAM) {
> + if (nvme_mam_compliant(id))
> + lim->features |= BLK_FEAT_ATOMIC_WRITE_MULTI;
> + else
> + dev_warn_once(ns->ctrl->device,
> + "Inconsistent MAM parameters, ignoring\n");
> + }
Minor: dev_warn_once() uses one static flag per call site, so only the first
affected controller is reported. Maybe dev_warn() (this runs on namespace scan,
not in the I/O path), and print the four values to make the report actionable?
Regards,
Arthur