From d9a08a9e616beeccdbd0e7262b7225ffdfa49e92 Mon Sep 17 00:00:00 2001 From: Adam Manzanares Date: Tue, 22 May 2018 10:52:19 -0700 Subject: fs: Add aio iopriority support This is the per-I/O equivalent of the ioprio_set system call. When IOCB_FLAG_IOPRIO is set on the iocb aio_flags field, then we set the newly added kiocb ki_ioprio field to the value in the iocb aio_reqprio field. This patch depends on block: add ioprio_check_cap function. Signed-off-by: Adam Manzanares Reviewed-by: Jeff Moyer Reviewed-by: Christoph Hellwig Signed-off-by: Al Viro --- fs/aio.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'fs/aio.c') diff --git a/fs/aio.c b/fs/aio.c index 33299ece7540a8..9527ededa66929 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1435,6 +1435,22 @@ static int aio_prep_rw(struct kiocb *req, struct iocb *iocb) if (iocb->aio_flags & IOCB_FLAG_RESFD) req->ki_flags |= IOCB_EVENTFD; req->ki_hint = ki_hint_validate(file_write_hint(req->ki_filp)); + if (iocb->aio_flags & IOCB_FLAG_IOPRIO) { + /* + * If the IOCB_FLAG_IOPRIO flag of aio_flags is set, then + * aio_reqprio is interpreted as an I/O scheduling + * class and priority. + */ + ret = ioprio_check_cap(iocb->aio_reqprio); + if (ret) { + pr_debug("aio ioprio check cap error\n"); + return -EINVAL; + } + + req->ki_ioprio = iocb->aio_reqprio; + } else + req->ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); + ret = kiocb_set_rw_flags(req, iocb->aio_rw_flags); if (unlikely(ret)) fput(req->ki_filp); -- cgit 1.2.3-korg