]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: add RWF_ATOMIC support to pwrite
authorCatherine Hoang <catherine.hoang@oracle.com>
Tue, 1 Oct 2024 18:28:49 +0000 (11:28 -0700)
committerAndrey Albershteyn <aalbersh@redhat.com>
Thu, 3 Oct 2024 13:44:03 +0000 (15:44 +0200)
Enable testing write behavior with the per-io RWF_ATOMIC flag.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
include/linux.h
io/pwrite.c
man/man8/xfs_io.8

index a13072d2f3af349dd958aa39aac150a3b4da7d0a..e9eb7bfb26a13707e387f11e1b381a3d32b8cbb6 100644 (file)
@@ -231,6 +231,11 @@ struct fsxattr {
 #define FS_XFLAG_COWEXTSIZE    0x00010000      /* CoW extent size allocator hint */
 #endif
 
+/* Atomic Write */
+#ifndef RWF_ATOMIC
+#define RWF_ATOMIC     ((__kernel_rwf_t)0x00000040)
+#endif
+
 /*
  * Reminder: anything added to this file will be compiled into downstream
  * userspace projects!
index a88cecc7ea511d7c52835fd0300ba308a13d880f..fab59be40a4d24e4db9f00cf3d32683205abbc56 100644 (file)
@@ -44,6 +44,7 @@ pwrite_help(void)
 #ifdef HAVE_PWRITEV2
 " -N   -- Perform the pwritev2() with RWF_NOWAIT\n"
 " -D   -- Perform the pwritev2() with RWF_DSYNC\n"
+" -A   -- Perform the pwritev2() with RWF_ATOMIC\n"
 #endif
 "\n"));
 }
@@ -284,7 +285,7 @@ pwrite_f(
        init_cvtnum(&fsblocksize, &fssectsize);
        bsize = fsblocksize;
 
-       while ((c = getopt(argc, argv, "b:BCdDf:Fi:NqRs:OS:uV:wWZ:")) != EOF) {
+       while ((c = getopt(argc, argv, "Ab:BCdDf:Fi:NqRs:OS:uV:wWZ:")) != EOF) {
                switch (c) {
                case 'b':
                        tmp = cvtnum(fsblocksize, fssectsize, optarg);
@@ -324,6 +325,9 @@ pwrite_f(
                case 'D':
                        pwritev2_flags |= RWF_DSYNC;
                        break;
+               case 'A':
+                       pwritev2_flags |= RWF_ATOMIC;
+                       break;
 #endif
                case 's':
                        skip = cvtnum(fsblocksize, fssectsize, optarg);
@@ -476,7 +480,7 @@ pwrite_init(void)
        pwrite_cmd.argmax = -1;
        pwrite_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
        pwrite_cmd.args =
-_("[-i infile [-qdDwNOW] [-s skip]] [-b bs] [-S seed] [-FBR [-Z N]] [-V N] off len");
+_("[-i infile [-qAdDwNOW] [-s skip]] [-b bs] [-S seed] [-FBR [-Z N]] [-V N] off len");
        pwrite_cmd.oneline =
                _("writes a number of bytes at a specified offset");
        pwrite_cmd.help = pwrite_help;
index 303c6447892399c20ab2671d89451c15b8f4a45b..1e7901393ff4d40dafbb744247f5fe653b0c759c 100644 (file)
@@ -244,7 +244,7 @@ See the
 .B pread
 command.
 .TP
-.BI "pwrite [ \-i " file " ] [ \-qdDwNOW ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-V " vectors " ] " "offset length"
+.BI "pwrite [ \-i " file " ] [ \-qAdDwNOW ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-V " vectors " ] " "offset length"
 Writes a range of bytes in a specified blocksize from the given
 .IR offset .
 The bytes written can be either a set pattern or read in from another
@@ -281,6 +281,12 @@ Perform the
 call with
 .IR RWF_DSYNC .
 .TP
+.B \-A
+Perform the
+.BR pwritev2 (2)
+call with
+.IR RWF_ATOMIC .
+.TP
 .B \-O
 perform pwrite once and return the (maybe partial) bytes written.
 .TP