Linux block layer
 help / color / mirror / Atom feed
From: Daniel Gomez <da.gomez@kernel.org>
To: Arthur Simchaev <arthur.simchaev@sandisk.com>
Cc: Jens Axboe <axboe@kernel.dk>, Keith Busch <kbusch@kernel.org>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-nvme@lists.infradead.org,
	Andres Freund <andres@anarazel.de>,
	Pankaj Raghav <pankaj.raghav@linux.dev>,
	GOST <gost.dev@samsung.com>, Daniel Gomez <da.gomez@samsung.com>,
	Avi.Shchislowski@sandisk.com, Alex.Lemberg@sandisk.com
Subject: Re: [PATCH RFC 0/2] Support for Multiple Atomicity Mode
Date: Fri, 13 Nov 2026 11:31:42 +0100	[thread overview]
Message-ID: <20261113105333.3-da.gomez@kernel.org> (raw)
In-Reply-To: <20261103093839.203841-1-arthur.simchaev@sandisk.com>



On 2026-11-03T11:38:39+02:00, Arthur Simchaev <arthur.simchaev@sandisk.com> wrote:
> On Tue, Sep 29, 2026 at 01:17:10PM +0200, Daniel Gomez wrote:
> > While I think this small feature is worth having (hence this RFC)
> > for users sending atomic write commands that are contiguous, the
> > question I'd also like to discuss really is how to also expose clear
> > MAM semantics to userspace for users who can send larger commands,
> > so they avoid syscall overhead [2] and splitting, and still get the
> > atomic guarantees in the LBA subranges. RWF_ATOMIC currently exposes
> > SAM semantics, but I think MAM may be confusing for users, as it's not
> > simply a larger atomic write but an atomic carrier. Thoughts? What can
> > work best to leverage MAM from userspace without conflicting with SAM?
>
> Hi Daniel,
>
> I agree that RWF_ATOMIC should keep its current meaning: the whole write is
> untorn. Letting it accept larger writes on MAM devices would silently weaken
> that guarantee for existing users.
>
> If we want userspace to send one large write with per-piece guarantees, I would
> keep RWF_ATOMIC unchanged and add a separate opt-in flag that describes the
> guarantee rather than the device mode, for example (names are placeholders):
>
>   pwritev2(fd, iov, 1, pos, RWF_ATOMIC_CHUNKED);
>
>   - statx reports a granule G (e.g. stx_atomic_write_chunk)
>   - the range is split at file offsets that are multiples of G
>   - each piece is untorn; nothing is guaranteed across pieces
>
> If G is tied to atomic_write_unit_max, a G-aligned piece never crosses an atomic
> boundary, because the block layer already requires the boundary to be a power of
> two no smaller than unit_max. A SAM device could then implement the flag with
> one atomic bio per piece, and MAM would only be an optimisation underneath. Open

You mean a "fallthrough" for MAM while making SAM path an iterator?
I was thinking in something easier to start with like simply not
supporting SAM path in this RFW_ATOMIC_CHUNKED flag suggestion, and
return an error like we do today if you send a non atomic conformat io
with RWF_ATOMIC.

The "interesting" thing is (for NVMe MAM) that you can send a large
command and it will be atomic at the chunk boundary anyways. But I guess
users may want to have guarantees of their chunk atomic granularity.

> questions would be the semantics of partial completion and errors, and how
> filesystems keep each piece mapped to one contiguous extent.

Thanks for the suggestion. I plan to work on it after this series.

>
> Before adding a new flag, though: with this series your fio example (io_uring,
> iodepth_batch_submit=4) already sends four 16k RWF_ATOMIC writes as one 64k
> command, so a single large write would only save per-I/O work in the kernel, not
> device commands. I understand real MAM hardware may not be available, but that

HW is available for those who need it. FYI, I'm currently testing this
on a real device and post more details in a new revision.

> cost can be estimated without it, e.g. by comparing host CPU usage of a batch of
> small O_DIRECT writes against one large write of the same total size on any NVMe
> device. Even a relative number (e.g. % CPU per GB written) would show whether
> the remaining overhead justifies new uAPI.

100%.

Thanks Arthur for the review. I talked with Keith at LPC about this so
I was planning to resend it. I will now, take your suggestions and send a
new version.



      reply	other threads:[~2026-11-13 10:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 11:17 [PATCH RFC 0/2] Support for Multiple Atomicity Mode Daniel Gomez
2026-09-29 11:17 ` [PATCH RFC 1/2] block: add BLK_FEAT_ATOMIC_WRITE_MULTI Daniel Gomez
2026-11-03  9:38   ` Arthur Simchaev
2026-11-13 10:30     ` Daniel Gomez
2026-09-29 11:17 ` [PATCH RFC 2/2] nvme: enable multiple atomicity mode Daniel Gomez
2026-11-03  9:38   ` Arthur Simchaev
2026-11-13 10:31     ` Daniel Gomez
2026-11-03  9:38 ` [PATCH RFC 0/2] Support for Multiple Atomicity Mode Arthur Simchaev
2026-11-13 10:31   ` Daniel Gomez [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=20261113105333.3-da.gomez@kernel.org \
    --to=da.gomez@kernel.org \
    --cc=Alex.Lemberg@sandisk.com \
    --cc=Avi.Shchislowski@sandisk.com \
    --cc=andres@anarazel.de \
    --cc=arthur.simchaev@sandisk.com \
    --cc=axboe@kernel.dk \
    --cc=da.gomez@samsung.com \
    --cc=gost.dev@samsung.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=pankaj.raghav@linux.dev \
    --cc=sagi@grimberg.me \
    /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