Re: [RFC PATCH] xfs: add a per-filesystem switch to force atomic CoW
From: Pankaj Raghav (Samsung)
Date: Mon Nov 23 2026 - 08:43:27 EST
On Mon, Nov 23, 2026 at 11:44:19AM +0000, John Garry wrote:
> On 11/21/26 15:47, Wayne Gao wrote:
> >
>
> Christoph was proposing something similar here:
>
> https://lore.kernel.org/linux-xfs/20250714131713.GA8742@xxxxxx/
>
> Plesse check it. But it is for a difference purpose to what you propose,
> below. Actually, I am not sure on the motivation.
>
> >
> > Hardware-capable devices normally prefer hardware atomic writes, making
> > it difficult to exercise the software CoW path deterministically without
> > changing file layouts or affecting ordinary writes.
> >
> > Add a non-debug force_atomic_cow sysfs control for each filesystem.
Why do you think this should be a non-debug interface? Why would anyone
want to disable HW atomics if the device supports it in production?
> > When enabled, route RWF_ATOMIC writes directly to the existing software
> > CoW path regardless of hardware eligibility. Keep automatic selection
> > as the default and reject enabling the control without software atomic
> > write support.
> >
> > Sample the setting once per I/O so in-flight requests retain their
> > selected path. Preserve existing validation, completion and error
> > handling, and leave non-atomic writes unchanged.
> >
> > Report no separate optimized atomic write limit while CoW is forced
> > and document the control's runtime scope and lifetime.
> >
> > Validation: strict checkpatch passed. Linux kernel build and mounted-XFS
> > runtime tests have not been run.
> >
>
> Hmmm.. you are just describing what it does. Not why.
>
> > Signed-off-by: Wayne Gao <wayne.gao1@xxxxxxxxxxxx>
> > ---
> > Hi Carlos and XFS developers,
> >
> > I would appreciate feedback on this proposed interface.
> >
> > The intended use is a controlled comparison of hardware-backed and
> > software-backed RWF_ATOMIC writes on the same hardware, without having
> > to construct misaligned mappings to trigger fallback.
>
> Why do you want to compare?
>
Probably to measure the performance of HW atomics vs SW atomics?
If the goal is to compare HW atomics vs SW atomics, then a simple module
parameter in the nvme driver (or scsi) to disable atomics even on HW atomic
capable device should force SW atomics from XFS. I am not sure if it
needs to be in the upstream kernel.
--
Pankaj