]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
src/fiexchange.h: add the start-commit/commit-range ioctls
authorDarrick J. Wong <djwong@kernel.org>
Tue, 1 Oct 2024 16:49:11 +0000 (09:49 -0700)
committerZorro Lang <zlang@kernel.org>
Sat, 12 Oct 2024 14:06:46 +0000 (22:06 +0800)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
m4/package_xfslibs.m4
src/fiexchange.h
src/global.h

index 5604989e34b2be831b4e1423ad934c803c30712c..ec7b91986c63637de1bd2241d26df95cd55ba698 100644 (file)
@@ -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)])
index 02eb0027d1338b09b82deb594172d9f1aa98b9e2..b9eb2a7e2651e412500152af668f88585d3a739b 100644 (file)
@@ -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 */
index fc48d82e03abad392f529e891107c65e119e544b..fbc0a0b5e1c6b6560d85c6255805a7175a31b932 100644 (file)
@@ -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
 
 #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