diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-09 13:52:01 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:30:22 -0400 |
commit | 2ba48ce513c4e545318d22b138861d5876edf906 (patch) | |
tree | 0e2a5130ead5c71f0b079b1acd620fba98f99256 /include/linux/fs.h | |
parent | 3309dd04cbcd2cdad168485af5cf3576b5051e49 (diff) |
mirror O_APPEND and O_DIRECT into iocb->ki_flags
... avoiding write_iter/fcntl races.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index b4aa400ac723..b1d7db28c13c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -315,6 +315,8 @@ struct address_space; | |||
315 | struct writeback_control; | 315 | struct writeback_control; |
316 | 316 | ||
317 | #define IOCB_EVENTFD (1 << 0) | 317 | #define IOCB_EVENTFD (1 << 0) |
318 | #define IOCB_APPEND (1 << 1) | ||
319 | #define IOCB_DIRECT (1 << 2) | ||
318 | 320 | ||
319 | struct kiocb { | 321 | struct kiocb { |
320 | struct file *ki_filp; | 322 | struct file *ki_filp; |
@@ -329,10 +331,13 @@ static inline bool is_sync_kiocb(struct kiocb *kiocb) | |||
329 | return kiocb->ki_complete == NULL; | 331 | return kiocb->ki_complete == NULL; |
330 | } | 332 | } |
331 | 333 | ||
334 | static inline int iocb_flags(struct file *file); | ||
335 | |||
332 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) | 336 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) |
333 | { | 337 | { |
334 | *kiocb = (struct kiocb) { | 338 | *kiocb = (struct kiocb) { |
335 | .ki_filp = filp, | 339 | .ki_filp = filp, |
340 | .ki_flags = iocb_flags(filp), | ||
336 | }; | 341 | }; |
337 | } | 342 | } |
338 | 343 | ||
@@ -2779,6 +2784,16 @@ static inline bool io_is_direct(struct file *filp) | |||
2779 | return (filp->f_flags & O_DIRECT) || IS_DAX(file_inode(filp)); | 2784 | return (filp->f_flags & O_DIRECT) || IS_DAX(file_inode(filp)); |
2780 | } | 2785 | } |
2781 | 2786 | ||
2787 | static inline int iocb_flags(struct file *file) | ||
2788 | { | ||
2789 | int res = 0; | ||
2790 | if (file->f_flags & O_APPEND) | ||
2791 | res |= IOCB_APPEND; | ||
2792 | if (io_is_direct(file)) | ||
2793 | res |= IOCB_DIRECT; | ||
2794 | return res; | ||
2795 | } | ||
2796 | |||
2782 | static inline ino_t parent_ino(struct dentry *dentry) | 2797 | static inline ino_t parent_ino(struct dentry *dentry) |
2783 | { | 2798 | { |
2784 | ino_t res; | 2799 | ino_t res; |