From: John Garry <john.garry@linux.dev>
To: daejun7.park@samsung.com, Carlos Maiolino <cem@kernel.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Cc: Pankaj Raghav Partha Sarathy <p.raghav@samsung.com>,
Pankaj Raghav <pankaj.raghav@linux.dev>,
"Darrick J. Wong" <djwong@kernel.org>,
Christoph Hellwig <hch@lst.de>,
Dave Chinner <david@fromorbit.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: (2) (2) [PATCH v2] xfs: check the disk address for hardware atomic writes
Date: Mon, 16 Nov 2026 08:11:51 +0000 [thread overview]
Message-ID: <96330e94-d3c0-447c-aef0-7c56b24e122b@linux.dev> (raw)
In-Reply-To: <20261116073903epcms2p13ca5bac24c591ae487f0b30dc45b87f8@epcms2p1>
On 11/16/26 07:39, Daejun Park wrote:
> On Fri, Nov 13, 2026 at 09:45:22AM +0000, John Garry wrote:
>> hmm.. I am still not confident that this the best fix. And if it is,
>> then I think that we should still change the size pre-check in
>> xfs_file_dio_write_atomic(). Here's a combined change which I am
>> thinking of:
> [...]
>> bt_awu_max is the HW max, and you are saying that it is not aligned with
>> the AG size (and so need a disk alignment check). However, opt max
>> should be (aligned to AG size), so we could check that vs size instead.
>
uhhh... I thought about this a bit more, and I am really not sure on the
best solution. On one hand, atomic writes whose length is above opt max
should not use HW atomics. Or, more specifically, the user can't expect
HW atomics to be used. However, if HW atomic is possible, then it would
be silly not to use it.
> Thanks, agreed. v3 will check the size instead of the disk address,
> in both xfs_file_dio_write_atomic() and
> xfs_bmap_hw_atomic_write_possible(). The limit is the one max_opt
> applies: the smaller of bt_awu_max and the largest power-of-two factor
> of the group size. Below that limit the existing br_startblock check is
> enough, so v3 drops the disk address check.
>
> v3 puts this limit in a helper that xfs_get_atomic_write_max_opt() also
> uses, so max_opt and the checks use the same hardware limit. The checks
> call the helper rather than max_opt, since max_opt is 0 on a filesystem
> without reflink. When I tried max_opt there, the one-block atomic
> writes went to COW and failed with -EINVAL. The helper returns
> bt_awu_max when there are no groups, which is the rt device without
> rtgroups.
>
>> BTW, with your proposed change, since HW size is not aligned to AG size
>> and we only check the size vs HW size for HW offload, it is in theory
>> possible to have an atomic write which straddles the AG and is rejected,
>> right?
>
> Userspace does not see a rejection. Such a write maps to two extents,
> so xfs_bmap_hw_atomic_write_possible() returns false and the write goes
> through COW.
Yeah, I was really asking if HW atomic could span 2x extents before we
catch it.
> This is the same in v2 and v3. In v3, a write sent to the
> hardware is also aligned and no larger than the group alignment, so it
> cannot cross a group boundary.
>
Maybe what you have in this patch is ok. I'll wait for v3 and consider
it more. Sorry for the hesitancy.
Thanks,
John
next prev parent reply other threads:[~2026-11-16 8:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 0:41 Daejun Park via B4 Relay
2026-11-12 8:29 ` John Garry
2026-11-12 13:49 ` Christoph Hellwig
2026-11-12 21:38 ` Pankaj Raghav (Samsung)
[not found] ` <CGME20261112082952epcas2p1f902c4243d451635ff27fe1a1c5035fe@epcms2p5>
2026-11-13 2:55 ` Daejun Park
2026-11-13 9:45 ` (2) " John Garry
[not found] ` <CGME20261112082952epcas2p1f902c4243d451635ff27fe1a1c5035fe@epcms2p1>
2026-11-16 7:39 ` Daejun Park
2026-11-16 8:11 ` John Garry [this message]
[not found] ` <CGME20261112082952epcas2p1f902c4243d451635ff27fe1a1c5035fe@epcms2p7>
2026-11-16 9:54 ` RE:(2) (2) " Daejun Park
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=96330e94-d3c0-447c-aef0-7c56b24e122b@linux.dev \
--to=john.garry@linux.dev \
--cc=cem@kernel.org \
--cc=daejun7.park@samsung.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=p.raghav@samsung.com \
--cc=pankaj.raghav@linux.dev \
/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
all inboxes | Powered by JetHome®