If the FS has no reflink, then atomic writes greater than 1x block are not
supported. As such, for no reflink it is pointless to accept setting
max_atomic_write when it cannot be supported, so reject max_atomic_write
mount option in this case.
It could be still possible to accept max_atomic_write option of size 1x
block if HW atomics are supported, so check for this specifically.
Fixes: 4528b9052731 ("xfs: allow sysadmins to specify a maximum atomic write limit at mount time")
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
fs/xfs/xfs_mount.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 0b690bc119d7..1ec70f4e57b4 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -784,6 +784,25 @@ xfs_set_max_atomic_write_opt(
return -EINVAL;
}
+ if (xfs_has_reflink(mp))
+ goto set_limit;
+
+ if (new_max_fsbs == 1) {
+ if (mp->m_ddev_targp->bt_awu_max ||
+ (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_awu_max)) {
+ } else {
+ xfs_warn(mp,
+ "cannot support atomic writes of size %lluk with no reflink or HW support",
+ new_max_bytes >> 10);
+ return -EINVAL;
+ }
+ } else {
+ xfs_warn(mp,
+ "cannot support atomic writes of size %lluk with no reflink support",
+ new_max_bytes >> 10);
+ return -EINVAL;
+ }
+
set_limit:
error = xfs_calc_atomic_write_reservation(mp, new_max_fsbs);
if (error) {
--
2.43.5
On Thu, Jul 24, 2025 at 08:12:15AM +0000, John Garry wrote: > If the FS has no reflink, then atomic writes greater than 1x block are not > supported. As such, for no reflink it is pointless to accept setting > max_atomic_write when it cannot be supported, so reject max_atomic_write > mount option in this case. > > It could be still possible to accept max_atomic_write option of size 1x > block if HW atomics are supported, so check for this specifically. > > Fixes: 4528b9052731 ("xfs: allow sysadmins to specify a maximum atomic write limit at mount time") > Signed-off-by: John Garry <john.g.garry@oracle.com> /me wonders if "mkfs: allow users to configure the desired maximum atomic write size" needs a similar filter? Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > fs/xfs/xfs_mount.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c > index 0b690bc119d7..1ec70f4e57b4 100644 > --- a/fs/xfs/xfs_mount.c > +++ b/fs/xfs/xfs_mount.c > @@ -784,6 +784,25 @@ xfs_set_max_atomic_write_opt( > return -EINVAL; > } > > + if (xfs_has_reflink(mp)) > + goto set_limit; > + > + if (new_max_fsbs == 1) { > + if (mp->m_ddev_targp->bt_awu_max || > + (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_awu_max)) { > + } else { > + xfs_warn(mp, > + "cannot support atomic writes of size %lluk with no reflink or HW support", > + new_max_bytes >> 10); > + return -EINVAL; > + } > + } else { > + xfs_warn(mp, > + "cannot support atomic writes of size %lluk with no reflink support", > + new_max_bytes >> 10); > + return -EINVAL; > + } > + > set_limit: > error = xfs_calc_atomic_write_reservation(mp, new_max_fsbs); > if (error) { > -- > 2.43.5 > >
On 24/07/2025 17:32, Darrick J. Wong wrote: > On Thu, Jul 24, 2025 at 08:12:15AM +0000, John Garry wrote: >> If the FS has no reflink, then atomic writes greater than 1x block are not >> supported. As such, for no reflink it is pointless to accept setting >> max_atomic_write when it cannot be supported, so reject max_atomic_write >> mount option in this case. >> >> It could be still possible to accept max_atomic_write option of size 1x >> block if HW atomics are supported, so check for this specifically. >> >> Fixes: 4528b9052731 ("xfs: allow sysadmins to specify a maximum atomic write limit at mount time") >> Signed-off-by: John Garry<john.g.garry@oracle.com> > /me wonders if "mkfs: allow users to configure the desired maximum > atomic write size" needs a similar filter? > Yeah, probably. But I am wondering if we should always require reflink for setting that max atomic mkfs option, and not have a special case of HW atomics available for 1x blocksize atomic writes. > Reviewed-by: "Darrick J. Wong"<djwong@kernel.org> cheers
On Fri, Jul 25, 2025 at 09:39:42AM +0100, John Garry wrote: > On 24/07/2025 17:32, Darrick J. Wong wrote: > > On Thu, Jul 24, 2025 at 08:12:15AM +0000, John Garry wrote: > > > If the FS has no reflink, then atomic writes greater than 1x block are not > > > supported. As such, for no reflink it is pointless to accept setting > > > max_atomic_write when it cannot be supported, so reject max_atomic_write > > > mount option in this case. > > > > > > It could be still possible to accept max_atomic_write option of size 1x > > > block if HW atomics are supported, so check for this specifically. > > > > > > Fixes: 4528b9052731 ("xfs: allow sysadmins to specify a maximum atomic write limit at mount time") > > > Signed-off-by: John Garry<john.g.garry@oracle.com> > > /me wonders if "mkfs: allow users to configure the desired maximum > > atomic write size" needs a similar filter? > > > > Yeah, probably. But I am wondering if we should always require reflink for > setting that max atomic mkfs option, and not have a special case of HW > atomics available for 1x blocksize atomic writes. I think that's reasonable for mkfs since reflink=1 has been the default for quite a long while now. --D > > Reviewed-by: "Darrick J. Wong"<djwong@kernel.org> > > cheers >
© 2016 - 2025 Red Hat, Inc.