Commit 1752f0ad authored by Pavel Begunkov's avatar Pavel Begunkov Committed by 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: default avatarPavel Begunkov <asml.silence@gmail.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment