[RFC PATCH v4 09/12] fs: Introduce RWF_NOSERIAL flag to indicate parallel reads/writes
From: Ojaswin Mujoo
Date: Mon Sep 28 2026 - 08:51:43 EST
Introduce RWF_NOSERIAL flag to indicate that the application is
okay with its reads and writes going in parallel to other read/writes.
This flag will allow writes and read to go in parallel (for eg, under a
shared lock) increasing performance at the cost of losing the (loosely
implemented) POSIX guarantees wrt to R/W serialization that various
filesystems provide.
In this patch we just introduce the flag and in upcoming patches we will
use it to implement parallel writes to increase performance of
RWF_WRITETHROUGH
Co-developed-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>
Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>
---
include/linux/fs.h | 10 +++++++++-
include/uapi/linux/fs.h | 6 +++++-
tools/include/uapi/linux/fs.h | 5 ++++-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cbaa65e05d9e..6f84bb41f84a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -345,6 +345,7 @@ struct readahead_control;
#define IOCB_DONTCACHE (__force int) RWF_DONTCACHE
#define IOCB_NOSIGNAL (__force int) RWF_NOSIGNAL
#define IOCB_WRITETHROUGH (__force int) RWF_WRITETHROUGH
+#define IOCB_NOSERIAL (__force int) RWF_NOSERIAL
/* non-RWF related bits - start at 16 */
#define IOCB_EVENTFD (1 << 16)
@@ -375,7 +376,8 @@ struct readahead_control;
{ IOCB_NOIO, "NOIO" }, \
{ IOCB_ALLOC_CACHE, "ALLOC_CACHE" }, \
{ IOCB_AIO_RW, "AIO_RW" }, \
- { IOCB_HAS_METADATA, "AIO_HAS_METADATA" }
+ { IOCB_HAS_METADATA, "AIO_HAS_METADATA" }, \
+ { IOCB_NOSERIAL, "IOCB_NOSERIAL" }
struct kiocb {
struct file *ki_filp;
@@ -3499,6 +3501,12 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags,
ki->ki_flags &= ~IOCB_APPEND;
}
+ /*
+ * Currently, only writethrough supports noserial IO.
+ */
+ if ((flags & RWF_NOSERIAL) && !(flags & RWF_WRITETHROUGH))
+ return -EOPNOTSUPP;
+
ki->ki_flags |= kiocb_flags;
return 0;
}
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 67d8987b343d..b2ad2d8548ac 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -454,10 +454,14 @@ typedef int __bitwise __kernel_rwf_t;
/* buffered IO that is asynchronously written through to disk after write */
#define RWF_WRITETHROUGH ((__force __kernel_rwf_t)0x00000200)
+/* buffered IO writes that are non sequential because they use a shared lock */
+#define RWF_NOSERIAL ((__force __kernel_rwf_t)0x00000400)
+
/* mask of flags supported by the kernel */
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\
- RWF_DONTCACHE | RWF_NOSIGNAL | RWF_WRITETHROUGH)
+ RWF_DONTCACHE | RWF_NOSIGNAL | RWF_WRITETHROUGH |\
+ RWF_NOSERIAL)
#define PROCFS_IOCTL_MAGIC 'f'
diff --git a/tools/include/uapi/linux/fs.h b/tools/include/uapi/linux/fs.h
index 63ef6b126b8b..c7a1a1d238f0 100644
--- a/tools/include/uapi/linux/fs.h
+++ b/tools/include/uapi/linux/fs.h
@@ -347,10 +347,13 @@ typedef int __bitwise __kernel_rwf_t;
/* buffered IO that is asynchronously written through to disk after write */
#define RWF_WRITETHROUGH ((__force __kernel_rwf_t)0x00000200)
+/* buffered IO writes that are non sequential because they use a shared lock */
+#define RWF_NOSERIAL ((__force __kernel_rwf_t)0x00000400)
+
/* mask of flags supported by the kernel */
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\
- RWF_DONTCACHE | RWF_WRITETHROUGH)
+ RWF_DONTCACHE | RWF_WRITETHROUGH | RWF_NOSERIAL)
#define PROCFS_IOCTL_MAGIC 'f'
--
2.55.0