* [PATCH v2 1/3] statx.2: Document STATX_WRITE_ATOMIC
2024-01-24 11:27 [PATCH v2 0/3] man2: Document RWF_ATOMIC John Garry
@ 2024-01-24 11:27 ` John Garry
2024-01-24 11:27 ` [PATCH v2 2/3] readv.2: Document RWF_ATOMIC flag John Garry
2024-01-24 11:27 ` [PATCH v2 3/3] io_submit.2: Document RWF_ATOMIC John Garry
2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2024-01-24 11:27 UTC (permalink / raw)
To: linux-kernel, linux-api
Cc: martin.petersen, djwong, david, himanshu.madhani, hch, viro,
brauner, jack, John Garry
From: Himanshu Madhani <himanshu.madhani@oracle.com>
Add the text to the statx man page.
Signed-off-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
man2/statx.2 | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/man2/statx.2 b/man2/statx.2
index 0dcf7e20b..aa056ecdf 100644
--- a/man2/statx.2
+++ b/man2/statx.2
@@ -68,6 +68,10 @@ struct statx {
/* Direct I/O alignment restrictions */
__u32 stx_dio_mem_align;
__u32 stx_dio_offset_align;
+\&
+ __u32 stx_atomic_write_unit_min;
+ __u32 stx_atomic_write_unit_max;
+ __u32 stx_atomic_write_segments_max;
};
.EE
.in
@@ -255,6 +259,9 @@ STATX_ALL The same as STATX_BASIC_STATS | STATX_BTIME.
STATX_MNT_ID Want stx_mnt_id (since Linux 5.8)
STATX_DIOALIGN Want stx_dio_mem_align and stx_dio_offset_align
(since Linux 6.1; support varies by filesystem)
+STATX_WRITE_ATOMIC Want stx_atomic_write_unit_min, stx_atomic_write_unit_max,
+ and stx_atomic_write_segments_max.
+ (since Linux 6.9; support varies by filesystem)
.TE
.in
.P
@@ -439,6 +446,25 @@ or 0 if direct I/O is not supported on this file.
This will only be nonzero if
.I stx_dio_mem_align
is nonzero, and vice versa.
+.TP
+.I stx_atomic_write_unit_min
+The minimum size (in bytes) supported for direct I/O
+.RB ( O_DIRECT )
+on the file to be written with torn-write protection. This value is guaranteed
+to be a power-of-2.
+.TP
+.I stx_atomic_write_unit_max
+The maximum size (in bytes) supported for direct I/O
+.RB ( O_DIRECT )
+on the file to be written with torn-write protection. This value is guaranteed
+to be a power-of-2.
+.TP
+.I stx_atomic_write_segments_max
+The maximum number of elements in an array of vectors for a write with
+torn-write protection enabled. See
+.BR RWF_ATOMIC
+flag for
+.BR pwritev2 (2).
.P
For further information on the above fields, see
.BR inode (7).
@@ -492,6 +518,9 @@ It cannot be written to, and all reads from it will be verified
against a cryptographic hash that covers the
entire file (e.g., via a Merkle tree).
.TP
+.BR STATX_ATTR_WRITE_ATOMIC " (since Linux 6.8)"
+The file supports torn-write protection.
+.TP
.BR STATX_ATTR_DAX " (since Linux 5.8)"
The file is in the DAX (cpu direct access) state.
DAX state attempts to
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/3] readv.2: Document RWF_ATOMIC flag
2024-01-24 11:27 [PATCH v2 0/3] man2: Document RWF_ATOMIC John Garry
2024-01-24 11:27 ` [PATCH v2 1/3] statx.2: Document STATX_WRITE_ATOMIC John Garry
@ 2024-01-24 11:27 ` John Garry
2024-01-24 11:27 ` [PATCH v2 3/3] io_submit.2: Document RWF_ATOMIC John Garry
2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2024-01-24 11:27 UTC (permalink / raw)
To: linux-kernel, linux-api
Cc: martin.petersen, djwong, david, himanshu.madhani, hch, viro,
brauner, jack, John Garry
From: Himanshu Madhani <himanshu.madhani@oracle.com>
Add RWF_ATOMIC flag description for pwritev2().
Signed-off-by: Himanshu Madhani <himanshu.madhani@oracle.com>
#jpg: complete rewrite
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
man2/readv.2 | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
diff --git a/man2/readv.2 b/man2/readv.2
index d39f2b9b9..aa5d6576b 100644
--- a/man2/readv.2
+++ b/man2/readv.2
@@ -193,6 +193,61 @@ which provides lower latency, but may use additional resources.
.B O_DIRECT
flag.)
.TP
+.BR RWF_ATOMIC " (since Linux 6.8)"
+Requires that writes to regular files in block-based filesystems be issued with
+torn-write protection. Torn-write protection means that for a power failure or
+any other hardware failure, all or none of the data from the write will be
+stored, but never a mix of old and new data. This flag is meaningful only for
+.BR pwritev2 (),
+and its effect applies only to the data range written by the system call.
+The total write length must be power-of-2 and must be sized between
+.I stx_atomic_write_unit_min
+ and
+.I stx_atomic_write_unit_max
+, both inclusive. The
+write must be at a naturally-aligned offset within the file with respect to the
+total write length - for example, a write of length 32KB at a file offset of
+32KB is permitted, however a write of length 32KB at a file offset of 48KB is
+not permitted. The upper limit of
+.I iovcnt
+for
+.BR pwritev2 ()
+is in
+.I stx_atomic_write_segments_max.
+Torn-write protection only works with
+.B O_DIRECT
+flag, i.e. buffered writes are not supported. To guarantee consistency from
+the write between a file's in-core state with the storage device,
+.BR fdatasync (2),
+or
+.BR fsync (2),
+or
+.BR open (2)
+and either
+.B O_SYNC
+or
+.B O_DSYNC,
+or
+.B pwritev2 ()
+and either
+.B RWF_SYNC
+or
+.B RWF_DSYNC
+is required. Flags
+.B O_SYNC
+or
+.B RWF_SYNC
+provide the strongest guarantees for
+.BR RWF_ATOMIC,
+in that all data and also file metadata updates will be persisted for a
+successfully completed write. Just using either flags
+.B O_DSYNC
+or
+.B RWF_DSYNC
+means that all data and any file updates will be persisted for a successfully
+completed write. Not using any sync flags means that there
+is no guarantee that data or filesystem updates are persisted.
+.TP
.BR RWF_SYNC " (since Linux 4.7)"
.\" commit e864f39569f4092c2b2bc72c773b6e486c7e3bd9
Provide a per-write equivalent of the
@@ -279,10 +334,26 @@ values overflows an
.I ssize_t
value.
.TP
+.B EINVAL
+ For
+.BR RWF_ATOMIC
+set,
+the combination of the sum of the
+.I iov_len
+values and the
+.I offset
+value
+does not comply with the length and offset torn-write protection rules.
+.TP
.B EINVAL
The vector count,
.IR iovcnt ,
-is less than zero or greater than the permitted maximum.
+is less than zero or greater than the permitted maximum. For
+.BR RWF_ATOMIC
+set, this maximum is in
+.I stx_atomic_write_segments_max
+from
+.I statx.
.TP
.B EOPNOTSUPP
An unknown flag is specified in \fIflags\fP.
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] io_submit.2: Document RWF_ATOMIC
2024-01-24 11:27 [PATCH v2 0/3] man2: Document RWF_ATOMIC John Garry
2024-01-24 11:27 ` [PATCH v2 1/3] statx.2: Document STATX_WRITE_ATOMIC John Garry
2024-01-24 11:27 ` [PATCH v2 2/3] readv.2: Document RWF_ATOMIC flag John Garry
@ 2024-01-24 11:27 ` John Garry
2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2024-01-24 11:27 UTC (permalink / raw)
To: linux-kernel, linux-api
Cc: martin.petersen, djwong, david, himanshu.madhani, hch, viro,
brauner, jack, John Garry
Document RWF_ATOMIC for asynchronous I/O.
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
man2/io_submit.2 | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/man2/io_submit.2 b/man2/io_submit.2
index c53ae9aaf..fb6c4d9bc 100644
--- a/man2/io_submit.2
+++ b/man2/io_submit.2
@@ -140,6 +140,23 @@ as well the description of
.B O_SYNC
in
.BR open (2).
+.TP
+.BR RWF_ATOMIC " (since Linux 6.9)"
+Write a block of data such that a write will never be
+torn from power fail or similar. See the description
+of the flag of the same name in
+.BR pwritev2 (2).
+For usage with
+.BR IOCB_CMD_PWRITEV,
+the upper vector limit is in
+.I stx_atomic_write_segments_max.
+See
+.B STATX_WRITE_ATOMIC
+and
+.I stx_atomic_write_segments_max
+description
+in
+.BR statx (2).
.RE
.TP
.I aio_lio_opcode
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread