mbox series

[v6,00/12] large atomic writes for xfs

Message ID 20250408104209.1852036-1-john.g.garry@oracle.com (mailing list archive)
Headers show
Series large atomic writes for xfs | expand

Message

John Garry April 8, 2025, 10:41 a.m. UTC
Currently atomic write support for xfs is limited to writing a single
block as we have no way to guarantee alignment and that the write covers
a single extent.

This series introduces a method to issue atomic writes via a
software-based method.

The software-based method is used as a fallback for when attempting to
issue an atomic write over misaligned or multiple extents.

For xfs, this support is based on reflink CoW support.

The basic idea of this CoW method is to alloc a range in the CoW fork,
write the data, and atomically update the mapping.

Initial mysql performance testing has shown this method to perform ok.
However, there we are only using 16K atomic writes (and 4K block size),
so typically - and thankfully - this software fallback method won't be
used often.

For other FSes which want large atomics writes and don't support CoW, I
think that they can follow the example in [0].

Catherine is currently working on further xfstests for this feature,
which we hope to share soon.

Based on v6.15-rc1

[0] https://lore.kernel.org/linux-xfs/20250310183946.932054-1-john.g.garry@oracle.com/

Differences to v5:
- Add statx unit_max_opt (Christoph, me)
- Add xfs_atomic_write_cow_iomap_begin() (Christoph)
- drop old mechanical changes
- limit atomic write max according to CoW-based atomic write max (Christoph)
- Add xfs_compute_atomic_write_unit_max()
- this contains changes for limiting awu max according to max
  transaction log items (Darrick)
- use -ENOPROTOOPT for fallback (Christoph)
- rename xfs_inode_can_atomicwrite() -> xfs_inode_can_hw_atomicwrite()
- rework varoious code comments (Christoph)
- limit CoW-based atomic write to log size and add helpers (Darrick)
- drop IOMAP_DIO_FORCE_WAIT usage in xfs_file_dio_write_atomic()
- Add RB tags from Christoph (thanks!)

Differences to v4:
- Omit iomap patches which have already been queued
- Add () in xfs_bmap_compute_alignments() (Dave)
- Rename awu_max -> m_awu_max (Carlos)
- Add RFC to change IOMAP flag names
- Rebase

Darrick J. Wong (1):
  xfs: add helpers to compute log item overhead

John Garry (11):
  fs: add atomic write unit max opt to statx
  xfs: rename xfs_inode_can_atomicwrite() ->
    xfs_inode_can_hw_atomicwrite()
  xfs: allow block allocator to take an alignment hint
  xfs: refactor xfs_reflink_end_cow_extent()
  xfs: refine atomic write size check in xfs_file_write_iter()
  xfs: add xfs_atomic_write_cow_iomap_begin()
  xfs: add large atomic writes checks in xfs_direct_write_iomap_begin()
  xfs: commit CoW-based atomic writes atomically
  xfs: add xfs_file_dio_write_atomic()
  xfs: add xfs_compute_atomic_write_unit_max()
  xfs: update atomic write limits

 block/bdev.c                   |   3 +-
 fs/ext4/inode.c                |   2 +-
 fs/stat.c                      |   6 +-
 fs/xfs/libxfs/xfs_bmap.c       |   5 +
 fs/xfs/libxfs/xfs_bmap.h       |   6 +-
 fs/xfs/libxfs/xfs_trans_resv.c |   6 +-
 fs/xfs/libxfs/xfs_trans_resv.h |   4 +
 fs/xfs/xfs_bmap_item.c         |  10 ++
 fs/xfs/xfs_bmap_item.h         |   3 +
 fs/xfs/xfs_buf_item.c          |  19 ++++
 fs/xfs/xfs_buf_item.h          |   3 +
 fs/xfs/xfs_extfree_item.c      |  10 ++
 fs/xfs/xfs_extfree_item.h      |   3 +
 fs/xfs/xfs_file.c              |  87 ++++++++++++++--
 fs/xfs/xfs_inode.h             |   2 +-
 fs/xfs/xfs_iomap.c             | 183 ++++++++++++++++++++++++++++++++-
 fs/xfs/xfs_iomap.h             |   1 +
 fs/xfs/xfs_iops.c              |  61 ++++++++++-
 fs/xfs/xfs_iops.h              |   3 +
 fs/xfs/xfs_log_cil.c           |   4 +-
 fs/xfs/xfs_log_priv.h          |  13 +++
 fs/xfs/xfs_mount.c             |  36 +++++++
 fs/xfs/xfs_mount.h             |   5 +
 fs/xfs/xfs_refcount_item.c     |  10 ++
 fs/xfs/xfs_refcount_item.h     |   3 +
 fs/xfs/xfs_reflink.c           | 130 +++++++++++++++++------
 fs/xfs/xfs_reflink.h           |   4 +
 fs/xfs/xfs_rmap_item.c         |  10 ++
 fs/xfs/xfs_rmap_item.h         |   3 +
 fs/xfs/xfs_super.c             |  22 ++++
 fs/xfs/xfs_super.h             |   1 +
 fs/xfs/xfs_trace.h             |  22 ++++
 include/linux/fs.h             |   3 +-
 include/linux/stat.h           |   1 +
 include/uapi/linux/stat.h      |   8 +-
 35 files changed, 631 insertions(+), 61 deletions(-)