diff mbox series

[1/2] src/fiexchange.h: add the start-commit/commit-range ioctls

Message ID 172780126034.3586479.14747488978575659943.stgit@frogsfrogsfrogs (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/2] src/fiexchange.h: add the start-commit/commit-range ioctls | expand

Commit Message

Darrick J. Wong Oct. 1, 2024, 4:49 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Add these two ioctls as well, since they're a part of the file content
exchange functionality.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 m4/package_xfslibs.m4 |    2 ++
 src/fiexchange.h      |   26 ++++++++++++++++++++++++++
 src/global.h          |    4 ++++
 3 files changed, 32 insertions(+)

Comments

Christoph Hellwig Oct. 2, 2024, 5:45 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/m4/package_xfslibs.m4 b/m4/package_xfslibs.m4
index 5604989e34..ec7b91986c 100644
--- a/m4/package_xfslibs.m4
+++ b/m4/package_xfslibs.m4
@@ -100,7 +100,9 @@  AC_DEFUN([AC_NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE],
 #include <xfs/xfs.h>
     ]], [[
          struct xfs_exchange_range obj;
+         struct xfs_commit_range obj2;
          ioctl(-1, XFS_IOC_EXCHANGE_RANGE, &obj);
+         ioctl(-1, XFS_IOC_COMMIT_RANGE, &obj2);
     ]])],[AC_MSG_RESULT(yes)],
          [need_internal_xfs_ioc_exchange_range=yes
           AC_MSG_RESULT(no)])
diff --git a/src/fiexchange.h b/src/fiexchange.h
index 02eb0027d1..b9eb2a7e26 100644
--- a/src/fiexchange.h
+++ b/src/fiexchange.h
@@ -26,6 +26,30 @@  struct xfs_exchange_range {
 	__u64		flags;		/* see XFS_EXCHANGE_RANGE_* below */
 };
 
+/*
+ * Using the same definition of file2 as struct xfs_exchange_range, commit the
+ * contents of file1 into file2 if file2 has the same inode number, mtime, and
+ * ctime as the arguments provided to the call.  The old contents of file2 will
+ * be moved to file1.
+ *
+ * Returns -EBUSY if there isn't an exact match for the file2 fields.
+ *
+ * Filesystems must be able to restart and complete the operation even after
+ * the system goes down.
+ */
+struct xfs_commit_range {
+	__s32		file1_fd;
+	__u32		pad;		/* must be zeroes */
+	__u64		file1_offset;	/* file1 offset, bytes */
+	__u64		file2_offset;	/* file2 offset, bytes */
+	__u64		length;		/* bytes to exchange */
+
+	__u64		flags;		/* see XFS_EXCHANGE_RANGE_* below */
+
+	/* opaque file2 metadata for freshness checks */
+	__u64		file2_freshness[5];
+};
+
 /*
  * Exchange file data all the way to the ends of both files, and then exchange
  * the file sizes.  This flag can be used to replace a file's contents with a
@@ -53,5 +77,7 @@  struct xfs_exchange_range {
 					 XFS_EXCHANGE_RANGE_FILE1_WRITTEN)
 
 #define XFS_IOC_EXCHANGE_RANGE	     _IOW ('X', 129, struct xfs_exchange_range)
+#define XFS_IOC_START_COMMIT	     _IOR ('X', 130, struct xfs_commit_range)
+#define XFS_IOC_COMMIT_RANGE	     _IOW ('X', 131, struct xfs_commit_range)
 
 #endif /* _LINUX_FIEXCHANGE_H */
diff --git a/src/global.h b/src/global.h
index fc48d82e03..fbc0a0b5e1 100644
--- a/src/global.h
+++ b/src/global.h
@@ -12,6 +12,7 @@ 
 #ifdef NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE
 /* Override struct xfs_exchange_range in xfslibs */
 # define xfs_exchange_range		sys_xfs_exchange_range
+# define xfs_commit_range		sys_xfs_commit_range
 #endif
 
 #ifdef HAVE_XFS_XFS_H
@@ -20,7 +21,10 @@ 
 
 #ifdef NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE
 # undef xfs_exchange_range
+# undef xfs_commit_range
 # undef XFS_IOC_EXCHANGE_RANGE
+# undef XFS_IOC_START_COMMIT
+# undef XFS_IOC_COMMIT_RANGE
 #endif
 
 #ifdef HAVE_XFS_LIBXFS_H