From 1e02682bf6204656f37e7c0d30aef29c6a246cb2 Mon Sep 17 00:00:00 2001
From: John Garry <john.g.garry@oracle.com>
Date: Fri, 1 Mar 2024 17:15:22 +0000
Subject: [PATCH 09/11] xfs_io: Implement lsattr and chattr support for atomic
 writes

Use something like the following:
xfs_io -c "chattr +W" mnt/file

forcealign must be aliged for the file.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 io/attr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/io/attr.c b/io/attr.c
index 248a9c2..bc27a1a 100644
--- a/io/attr.c
+++ b/io/attr.c
@@ -39,9 +39,10 @@ static struct xflags {
 	{ FS_XFLAG_COWEXTSIZE,		"C", "cowextsize"	},
 	{ FS_XFLAG_HASATTR,		"X", "has-xattr"	},
 	{ FS_XFLAG_FORCEALIGN,		"F", "force-align"	},
+	{ FS_XFLAG_ATOMICWRITES,	"W", "atomic-writes"	},
 	{ 0, NULL, NULL }
 };
-#define CHATTR_XFLAG_LIST	"r"/*p*/"iasAdtPneEfSxC"/*X*/"F"
+#define CHATTR_XFLAG_LIST	"r"/*p*/"iasAdtPneEfSxC"/*X*/"FW"
 
 static void
 lsattr_help(void)
@@ -69,6 +70,7 @@ lsattr_help(void)
 " C -- for files with shared blocks, observe the inode CoW extent size value\n"
 " X -- file has extended attributes (cannot be changed using chattr)\n"
 " F -- data extent mappings must be aligned to extent size hint\n"
+" W -- atomic writes enabled for a file\n"
 "\n"
 " Options:\n"
 " -R -- recursively descend (useful when current file is a directory)\n"
@@ -107,6 +109,7 @@ chattr_help(void)
 " +/-x -- set/clear the direct access (DAX) flag\n"
 " +/-C -- set/clear the CoW extent-size flag\n"
 " +/-F -- set/clear the forcealign flag\n"
+" +/-W -- set/clear the atomic writes flag\n"
 " Note1: user must have certain capabilities to modify immutable/append-only.\n"
 " Note2: immutable/append-only files cannot be deleted; removing these files\n"
 "        requires the immutable/append-only flag to be cleared first.\n"
-- 
2.33.0

