vfs: add the RWF_HIPRI flag for preadv2/pwritev2
authorChristoph Hellwig <hch@lst.de>
Thu, 3 Mar 2016 15:04:01 +0000 (16:04 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 4 Mar 2016 17:20:10 +0000 (12:20 -0500)
This adds a flag that tells the file system that this is a high priority
request for which it's worth to poll the hardware.  The flag is purely
advisory and can be ignored if not supported.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Stephen Bates <stephen.bates@pmcs.com>
Tested-by: Stephen Bates <stephen.bates@pmcs.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/read_write.c
include/linux/fs.h
include/uapi/linux/fs.h

index e9c9e2a667ce88c8bed09cc7747c653aca9d1698..07c53db04ec1ead8135f64ba0c456cd49a72078a 100644 (file)
@@ -697,10 +697,12 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
        struct kiocb kiocb;
        ssize_t ret;
 
-       if (flags)
+       if (flags & ~RWF_HIPRI)
                return -EOPNOTSUPP;
 
        init_sync_kiocb(&kiocb, filp);
+       if (flags & RWF_HIPRI)
+               kiocb.ki_flags |= IOCB_HIPRI;
        kiocb.ki_pos = *ppos;
 
        ret = fn(&kiocb, iter);
@@ -715,7 +717,7 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
 {
        ssize_t ret = 0;
 
-       if (flags)
+       if (flags & ~RWF_HIPRI)
                return -EOPNOTSUPP;
 
        while (iov_iter_count(iter)) {
index 6ec87964644f7c21a26d7821e69e73851de9b861..337de88ff50f2b0a736f4f965305328f2a5237dd 100644 (file)
@@ -320,6 +320,7 @@ struct writeback_control;
 #define IOCB_EVENTFD           (1 << 0)
 #define IOCB_APPEND            (1 << 1)
 #define IOCB_DIRECT            (1 << 2)
+#define IOCB_HIPRI             (1 << 3)
 
 struct kiocb {
        struct file             *ki_filp;
index 41e0433b4a8398b3dc3da6d2d6aacb8e46287150..847c656729f8c1a49fe1d9049f018a4716b681f7 100644 (file)
@@ -305,4 +305,7 @@ struct fsxattr {
 #define SYNC_FILE_RANGE_WRITE          2
 #define SYNC_FILE_RANGE_WAIT_AFTER     4
 
+/* flags for preadv2/pwritev2: */
+#define RWF_HIPRI                      0x00000001 /* high priority request, poll if possible */
+
 #endif /* _UAPI_LINUX_FS_H */