misc: Add support for Linux uio.h RWF_ATOMIC flag (RHEL-87645)

Resolves: RHEL-87645
This commit is contained in:
Patsy Griffin 2025-12-16 14:45:40 -05:00
parent 9852cf6015
commit b520db1431

67
glibc-RHEL-87645.patch Normal file
View File

@ -0,0 +1,67 @@
commit 5ffc903216901914dc2ad9715088d3fe9d1ef205
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Oct 8 15:45:29 2024 -0300
misc: Add support for Linux uio.h RWF_ATOMIC flag
Linux 6.11 adds the new flag for pwritev2 (commit
c34fc6f26ab86d03a2d47446f42b6cd492dfdc56).
Checked on x86_64-linux-gnu on 6.11 kernel.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
diff --git a/manual/llio.texi b/manual/llio.texi
index 05ab44c6e7..0eb336f70b 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -1381,6 +1381,19 @@ Per-IO synchronization as if the file was opened with @code{O_APPEND} flag.
@item RWF_NOAPPEND
This flag allows an offset to be honored, even if the file was opened with
@code{O_APPEND} flag.
+
+@item RWF_ATOMIC
+Indicate that the write is to be issued with torn-write prevention. The
+input buffer should follow some contraints: the total length should be
+power-of-2 in size and also sizes between @code{atomic_write_unit_min}
+and @code{atomic_write_unit_max}, the @code{struct iovec} count should be
+up to @code{atomic_write_segments_max}, and the offset should be
+naturally-aligned with regard to total write length.
+
+The @code{atomic_*} values can be obtained with @code{statx} along with
+@code{STATX_WRITE_ATOMIC} flag.
+
+This is a Linux-specific extension.
@end vtable
When the source file is compiled with @code{_FILE_OFFSET_BITS == 64} the
diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c
index 8e04ff7282..4556421a43 100644
--- a/misc/tst-preadvwritev2-common.c
+++ b/misc/tst-preadvwritev2-common.c
@@ -37,8 +37,11 @@
#ifndef RWF_NOAPPEND
# define RWF_NOAPPEND 0
#endif
+#ifndef RWF_ATOMIC
+# define RWF_ATOMIC 0
+#endif
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT \
- | RWF_APPEND | RWF_NOAPPEND)
+ | RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC)
/* Generic uio_lim.h does not define IOV_MAX. */
#ifndef IOV_MAX
diff --git a/sysdeps/unix/sysv/linux/bits/uio-ext.h b/sysdeps/unix/sysv/linux/bits/uio-ext.h
index ead7a09156..85ed21bac5 100644
--- a/sysdeps/unix/sysv/linux/bits/uio-ext.h
+++ b/sysdeps/unix/sysv/linux/bits/uio-ext.h
@@ -48,6 +48,8 @@ extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
#define RWF_NOWAIT 0x00000008 /* per-IO nonblocking mode. */
#define RWF_APPEND 0x00000010 /* per-IO O_APPEND. */
#define RWF_NOAPPEND 0x00000020 /* per-IO negation of O_APPEND */
+#define RWF_ATOMIC 0x00000040 /* Write is to be issued with torn-write
+ prevention. */
__END_DECLS