提交 1752f0ad 编写于 作者: P Pavel Begunkov 提交者: Jens Axboe

fs: optimise kiocb_set_rw_flags()

Use a local var to collect flags in kiocb_set_rw_flags(). That spares
some memory writes and allows to replace most of the jumps with MOVEcc.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Reviewed-by: NMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 d1719f70
...@@ -3446,22 +3446,28 @@ static inline int iocb_flags(struct file *file) ...@@ -3446,22 +3446,28 @@ static inline int iocb_flags(struct file *file)
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
{ {
int kiocb_flags = 0;
if (!flags)
return 0;
if (unlikely(flags & ~RWF_SUPPORTED)) if (unlikely(flags & ~RWF_SUPPORTED))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (flags & RWF_NOWAIT) { if (flags & RWF_NOWAIT) {
if (!(ki->ki_filp->f_mode & FMODE_NOWAIT)) if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ki->ki_flags |= IOCB_NOWAIT; kiocb_flags |= IOCB_NOWAIT;
} }
if (flags & RWF_HIPRI) if (flags & RWF_HIPRI)
ki->ki_flags |= IOCB_HIPRI; kiocb_flags |= IOCB_HIPRI;
if (flags & RWF_DSYNC) if (flags & RWF_DSYNC)
ki->ki_flags |= IOCB_DSYNC; kiocb_flags |= IOCB_DSYNC;
if (flags & RWF_SYNC) if (flags & RWF_SYNC)
ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC); kiocb_flags |= (IOCB_DSYNC | IOCB_SYNC);
if (flags & RWF_APPEND) if (flags & RWF_APPEND)
ki->ki_flags |= IOCB_APPEND; kiocb_flags |= IOCB_APPEND;
ki->ki_flags |= kiocb_flags;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册