@@ -1605,6 +1605,14 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
}
}
+ /* If the IOCB IOPRI is set then the aio_reqprio is interpreted
+ * as a IO scheduling class and priority value. This is then
+ * set on the bio that is created from this request, which
+ * enables the priority to be passed to device drivers
+ */
+ if (req->common.ki_flags & IOCB_IOPRI)
+ req->common.ki_ioprio = iocb->aio_reqprio;
+
ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
if (unlikely(ret)) {
pr_debug("EFAULT: aio_key\n");
@@ -360,6 +360,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
bio->bi_iter.bi_sector = pos >> 9;
bio->bi_private = dio;
bio->bi_end_io = blkdev_bio_end_io;
+ bio->bi_ioprio = iocb->ki_ioprio;
ret = bio_iov_iter_get_pages(bio, iter);
if (unlikely(ret)) {
@@ -269,6 +269,7 @@ struct writeback_control;
#define IOCB_SYNC (1 << 5)
#define IOCB_WRITE (1 << 6)
#define IOCB_NOWAIT (1 << 7)
+#define IOCB_IOPRI (1 << 8)
struct kiocb {
struct file *ki_filp;
@@ -276,6 +277,7 @@ struct kiocb {
void (*ki_complete)(struct kiocb *iocb, long ret, long ret2);
void *private;
int ki_flags;
+ u16 ki_ioprio; /* See linux/ioprio.h */
};
static inline bool is_sync_kiocb(struct kiocb *kiocb)
@@ -3061,7 +3063,8 @@ static inline int iocb_flags(struct file *file)
static inline int kiocb_set_rw_flags(struct kiocb *ki, int flags)
{
- if (unlikely(flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT)))
+ if (unlikely(flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC |
+ RWF_NOWAIT | RWF_IOPRI)))
return -EOPNOTSUPP;
if (flags & RWF_HIPRI)
@@ -3072,6 +3075,8 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, int flags)
ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
if (flags & RWF_NOWAIT)
ki->ki_flags |= IOCB_NOWAIT;
+ if (flags & RWF_IOPRI)
+ ki->ki_flags |= IOCB_IOPRI;
return 0;
}
@@ -356,10 +356,10 @@ struct fscrypt_key {
#define SYNC_FILE_RANGE_WRITE 2
#define SYNC_FILE_RANGE_WAIT_AFTER 4
-/* flags for preadv2/pwritev2: */
+/* flags for aio & preadv2/pwritev2: */
#define RWF_HIPRI 0x00000001 /* high priority request, poll if possible */
#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */
#define RWF_SYNC 0x00000004 /* per-IO O_SYNC */
#define RWF_NOWAIT 0x00000008 /* per-IO, return -EAGAIN if operation would block */
-
+#define RWF_IOPRI 0x00000010 /* per-IO, interpret aio iocb reqprio as ioprio */
#endif /* _UAPI_LINUX_FS_H */