106 lines
3.6 KiB
Diff
106 lines
3.6 KiB
Diff
From eb775dfcd8c48d4a60f3989f5b5707c96a9612f4 Mon Sep 17 00:00:00 2001
|
|
From: John Garry <john.g.garry@oracle.com>
|
|
Date: Mon, 4 Mar 2024 10:27:27 +0000
|
|
Subject: [PATCH 10/11] xfs_io: Support statx for atomic writes
|
|
|
|
This should be done properly by installing the kernel headers with
|
|
atomic write statx support.
|
|
|
|
Signed-off-by: John Garry <john.g.garry@oracle.com>
|
|
|
|
---
|
|
io/stat.c | 3 +++
|
|
io/statx.h | 20 +++++++++++++++++++-
|
|
2 files changed, 22 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/io/stat.c b/io/stat.c
|
|
index b57f9ee..d7f4047 100644
|
|
--- a/io/stat.c
|
|
+++ b/io/stat.c
|
|
@@ -434,6 +434,9 @@ statx_f(
|
|
printf(_("stat.btime = %s"),
|
|
ctime((time_t *)&stx.stx_btime.tv_sec));
|
|
}
|
|
+ printf(_("stat.stx_atomic_write_unit_min = %lld\n"), (long long)stx.stx_atomic_write_unit_min);
|
|
+ printf(_("stat.stx_atomic_write_unit_max = %lld\n"), (long long)stx.stx_atomic_write_unit_max);
|
|
+ printf(_("stat.stx_atomic_write_segments_max = %lld\n"), (long long)stx.stx_atomic_write_segments_max);
|
|
|
|
if (file->flags & IO_FOREIGN)
|
|
return 0;
|
|
diff --git a/io/statx.h b/io/statx.h
|
|
index c6625ac..80745e8 100644
|
|
--- a/io/statx.h
|
|
+++ b/io/statx.h
|
|
@@ -34,6 +34,7 @@
|
|
#endif
|
|
|
|
|
|
+#undef STATX_TYPE
|
|
#ifndef STATX_TYPE
|
|
/* Pick up kernel definitions if glibc didn't already provide them */
|
|
#include <linux/stat.h>
|
|
@@ -56,6 +57,9 @@
|
|
*
|
|
* __reserved is held in case we need a yet finer resolution.
|
|
*/
|
|
+#define statx_timestamp _statx_timestamp
|
|
+#undef _statx_timestamp
|
|
+
|
|
struct statx_timestamp {
|
|
__s64 tv_sec;
|
|
__s32 tv_nsec;
|
|
@@ -99,6 +103,8 @@ struct statx_timestamp {
|
|
* will have values installed for compatibility purposes so that stat() and
|
|
* co. can be emulated in userspace.
|
|
*/
|
|
+#define statx _statx
|
|
+#undef _statx
|
|
struct statx {
|
|
/* 0x00 */
|
|
__u32 stx_mask; /* What results were written [uncond] */
|
|
@@ -126,7 +132,16 @@ struct statx {
|
|
__u32 stx_dev_major; /* ID of device containing file [uncond] */
|
|
__u32 stx_dev_minor;
|
|
/* 0x90 */
|
|
- __u64 __spare2[14]; /* Spare space for future expansion */
|
|
+ __u64 stx_mnt_id;
|
|
+ __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */
|
|
+ __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */
|
|
+ /* 0xa0 */
|
|
+ __u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */
|
|
+ __u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */
|
|
+ __u32 stx_atomic_write_segments_max; /* Max atomic write segment count */
|
|
+ __u32 __spare1;
|
|
+ /* 0xb0 */
|
|
+ __u64 __spare3[10]; /* Spare space for future expansion */
|
|
/* 0x100 */
|
|
};
|
|
|
|
@@ -138,6 +153,7 @@ struct statx {
|
|
* These bits should be set in the mask argument of statx() to request
|
|
* particular items when calling statx().
|
|
*/
|
|
+#undef STATX_ALL
|
|
#define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
|
|
#define STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */
|
|
#define STATX_NLINK 0x00000004U /* Want/got stx_nlink */
|
|
@@ -151,6 +167,7 @@ struct statx {
|
|
#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
|
|
#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
|
|
#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
|
|
+#define STATX_WRITE_ATOMIC 0x00008000U /* Want/got atomic_write_* fields */
|
|
#define STATX_ALL 0x00000fffU /* All currently supported flags */
|
|
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
|
|
|
|
@@ -172,6 +189,7 @@ struct statx {
|
|
#define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */
|
|
|
|
#define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */
|
|
+#define STATX_ATTR_WRITE_ATOMIC 0x00400000 /* File supports atomic write operations */
|
|
|
|
#endif /* STATX_TYPE */
|
|
#endif /* XFS_IO_STATX_H */
|
|
--
|
|
2.33.0
|
|
|