[PATCHSET v31.2 1/5] xfsprogs: atomic file content commits

Darrick J. Wong
2024-10-25T06:31:25Z

Hi all,

This series creates XFS_IOC_START_COMMIT and XFS_IOC_COMMIT_RANGE ioctls
to perform the exchange only if the target file has not been changed
since a given sampling point.

This new functionality uses the mechanism underlying EXCHANGE_RANGE to
stage and commit file updates such that reader programs will see either
the old contents or the new contents in their entirety, with no chance
of torn writes. A successful call completion guarantees that the new
contents will be seen even if the system fails. The pair of ioctls
allows userspace to perform what amounts to a compare and exchange
operation on entire file contents.

Note that there are ongoing arguments in the community about how best to
implement some sort of file data write counter that nfsd could also use
to signal invalidations to clients. Until such a thing is implemented,
this patch will rely on ctime/mtime updates.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

Comments and questions are, as always, welcome.

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=atomic-file-commits-6.12

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=atomic-file-commits-6.12
---
Commits in this patchset:
* man: document file range commit ioctls
* libfrog: add support for commit range ioctl family
* libxfs: remove unused xfs_inode fields
* libxfs: validate inumber in xfs_iget
* xfs_fsr: port to new file exchange library function
* xfs_io: add a commitrange option to the exchangerange command
* xfs_io: add atomic file update commands to exercise file commit range
---
fsr/xfs_fsr.c | 74 +++----
include/xfs_inode.h | 4
io/exchrange.c | 390 +++++++++++++++++++++++++++++++++++++
io/io.h | 4
io/open.c | 27 ++-
libfrog/file_exchange.c | 194 ++++++++++++++++++
libfrog/file_exchange.h | 10 +
libxfs/inode.c | 2
man/man2/ioctl_xfs_commit_range.2 | 296 ++++++++++++++++++++++++++++
man/man2/ioctl_xfs_fsgeometry.2 | 2
man/man2/ioctl_xfs_start_commit.2 | 1
man/man8/xfs_io.8 | 35 +++
12 files changed, 983 insertions(+), 56 deletions(-)
create mode 100644 man/man2/ioctl_xfs_commit_range.2
create mode 100644 man/man2/ioctl_xfs_start_commit.2