Skip to content

Commit d2fc0ed

Browse files
committed
Merge branch 'vfs-6.14.uncached_buffered_io'
Bring in the VFS changes for uncached buffered io. Signed-off-by: Christian Brauner <[email protected]>
2 parents ec052fa + af6505e commit d2fc0ed

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

include/linux/fs.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ struct readahead_control;
322322
#define IOCB_NOWAIT (__force int) RWF_NOWAIT
323323
#define IOCB_APPEND (__force int) RWF_APPEND
324324
#define IOCB_ATOMIC (__force int) RWF_ATOMIC
325+
#define IOCB_DONTCACHE (__force int) RWF_DONTCACHE
325326

326327
/* non-RWF related bits - start at 16 */
327328
#define IOCB_EVENTFD (1 << 16)
@@ -356,7 +357,8 @@ struct readahead_control;
356357
{ IOCB_SYNC, "SYNC" }, \
357358
{ IOCB_NOWAIT, "NOWAIT" }, \
358359
{ IOCB_APPEND, "APPEND" }, \
359-
{ IOCB_ATOMIC, "ATOMIC"}, \
360+
{ IOCB_ATOMIC, "ATOMIC" }, \
361+
{ IOCB_DONTCACHE, "DONTCACHE" }, \
360362
{ IOCB_EVENTFD, "EVENTFD"}, \
361363
{ IOCB_DIRECT, "DIRECT" }, \
362364
{ IOCB_WRITE, "WRITE" }, \
@@ -2138,6 +2140,8 @@ struct file_operations {
21382140
#define FOP_UNSIGNED_OFFSET ((__force fop_flags_t)(1 << 5))
21392141
/* Supports asynchronous lock callbacks */
21402142
#define FOP_ASYNC_LOCK ((__force fop_flags_t)(1 << 6))
2143+
/* File system supports uncached read/write buffered IO */
2144+
#define FOP_DONTCACHE ((__force fop_flags_t)(1 << 7))
21412145

21422146
/* Wrap a directory iterator that needs exclusive inode access */
21432147
int wrap_directory_iterator(struct file *, struct dir_context *,
@@ -3625,6 +3629,14 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags,
36253629
if (!(ki->ki_filp->f_mode & FMODE_CAN_ATOMIC_WRITE))
36263630
return -EOPNOTSUPP;
36273631
}
3632+
if (flags & RWF_DONTCACHE) {
3633+
/* file system must support it */
3634+
if (!(ki->ki_filp->f_op->fop_flags & FOP_DONTCACHE))
3635+
return -EOPNOTSUPP;
3636+
/* DAX mappings not supported */
3637+
if (IS_DAX(ki->ki_filp->f_mapping->host))
3638+
return -EOPNOTSUPP;
3639+
}
36283640
kiocb_flags |= (__force int) (flags & RWF_SUPPORTED);
36293641
if (flags & RWF_SYNC)
36303642
kiocb_flags |= IOCB_DSYNC;

include/uapi/linux/fs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,13 @@ typedef int __bitwise __kernel_rwf_t;
332332
/* Atomic Write */
333333
#define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040)
334334

335+
/* buffered IO that drops the cache after reading or writing data */
336+
#define RWF_DONTCACHE ((__force __kernel_rwf_t)0x00000080)
337+
335338
/* mask of flags supported by the kernel */
336339
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
337-
RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC)
340+
RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\
341+
RWF_DONTCACHE)
338342

339343
#define PROCFS_IOCTL_MAGIC 'f'
340344

0 commit comments

Comments
 (0)