提交 fdd2f5b7 编写于 作者: G Goldwyn Rodrigues 提交者: Jens Axboe

fs: Separate out kiocb flags setup based on RWF_* flags

Also added RWF_SUPPORTED to encompass all flags.
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NJan Kara <jack@suse.cz>
Signed-off-by: NGoldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 443bd90f
...@@ -678,16 +678,10 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, ...@@ -678,16 +678,10 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
struct kiocb kiocb; struct kiocb kiocb;
ssize_t ret; ssize_t ret;
if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC))
return -EOPNOTSUPP;
init_sync_kiocb(&kiocb, filp); init_sync_kiocb(&kiocb, filp);
if (flags & RWF_HIPRI) ret = kiocb_set_rw_flags(&kiocb, flags);
kiocb.ki_flags |= IOCB_HIPRI; if (ret)
if (flags & RWF_DSYNC) return ret;
kiocb.ki_flags |= IOCB_DSYNC;
if (flags & RWF_SYNC)
kiocb.ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
kiocb.ki_pos = *ppos; kiocb.ki_pos = *ppos;
if (type == READ) if (type == READ)
......
...@@ -3057,6 +3057,20 @@ static inline int iocb_flags(struct file *file) ...@@ -3057,6 +3057,20 @@ static inline int iocb_flags(struct file *file)
return res; return res;
} }
static inline int kiocb_set_rw_flags(struct kiocb *ki, int flags)
{
if (unlikely(flags & ~RWF_SUPPORTED))
return -EOPNOTSUPP;
if (flags & RWF_HIPRI)
ki->ki_flags |= IOCB_HIPRI;
if (flags & RWF_DSYNC)
ki->ki_flags |= IOCB_DSYNC;
if (flags & RWF_SYNC)
ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
return 0;
}
static inline ino_t parent_ino(struct dentry *dentry) static inline ino_t parent_ino(struct dentry *dentry)
{ {
ino_t res; ino_t res;
......
...@@ -361,4 +361,6 @@ struct fscrypt_key { ...@@ -361,4 +361,6 @@ struct fscrypt_key {
#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */ #define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */
#define RWF_SYNC 0x00000004 /* per-IO O_SYNC */ #define RWF_SYNC 0x00000004 /* per-IO O_SYNC */
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC)
#endif /* _UAPI_LINUX_FS_H */ #endif /* _UAPI_LINUX_FS_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册