@@ -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 */
21432147int 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 ;
0 commit comments