|
Goldwyn Rodrigues |
eff855 |
From 398a4738033b0842dd7e56fc263ad9f51994dc3d Mon Sep 17 00:00:00 2001
|
|
Goldwyn Rodrigues |
eff855 |
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
|
|
Goldwyn Rodrigues |
eff855 |
Date: Tue, 20 Jun 2017 07:05:43 -0500
|
|
Goldwyn Rodrigues |
eff855 |
Subject: [PATCH 04/11] fs: Introduce RWF_NOWAIT and FMODE_AIO_NOWAIT
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
Git-commit: b745fafaf70c0a98a2e1e7ac8cb14542889ceb0e
|
|
Goldwyn Rodrigues |
eff855 |
Patch-mainline: v4.13-rc1
|
|
Goldwyn Rodrigues |
eff855 |
References: FATE#321994
|
|
Goldwyn Rodrigues |
eff855 |
RWF_NOWAIT informs kernel to bail out if an AIO request will block
|
|
Goldwyn Rodrigues |
eff855 |
for reasons such as file allocations, or a writeback triggered,
|
|
Goldwyn Rodrigues |
eff855 |
or would block while allocating requests while performing
|
|
Goldwyn Rodrigues |
eff855 |
direct I/O.
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
RWF_NOWAIT is translated to IOCB_NOWAIT for iocb->ki_flags.
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
FMODE_AIO_NOWAIT is a flag which identifies the file opened is capable
|
|
Goldwyn Rodrigues |
eff855 |
of returning -EAGAIN if the AIO call will block. This must be set by
|
|
Goldwyn Rodrigues |
eff855 |
supporting filesystems in the ->open() call.
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
Filesystems xfs, btrfs and ext4 would be supported in the following patches.
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
|
Goldwyn Rodrigues |
eff855 |
Reviewed-by: Jan Kara <jack@suse.cz>
|
|
Goldwyn Rodrigues |
eff855 |
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
|
|
Goldwyn Rodrigues |
eff855 |
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
|
Goldwyn Rodrigues |
eff855 |
---
|
|
Goldwyn Rodrigues |
eff855 |
fs/aio.c | 6 ++++++
|
|
Goldwyn Rodrigues |
eff855 |
include/linux/fs.h | 9 +++++++++
|
|
Goldwyn Rodrigues |
eff855 |
include/uapi/linux/fs.h | 4 +++-
|
|
Goldwyn Rodrigues |
eff855 |
3 files changed, 18 insertions(+), 1 deletion(-)
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
diff --git a/fs/aio.c b/fs/aio.c
|
|
Goldwyn Rodrigues |
eff855 |
index 020fa0045e3c..34027b67e2f4 100644
|
|
Goldwyn Rodrigues |
eff855 |
--- a/fs/aio.c
|
|
Goldwyn Rodrigues |
eff855 |
+++ b/fs/aio.c
|
|
Goldwyn Rodrigues |
eff855 |
@@ -1592,6 +1592,12 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
|
|
Goldwyn Rodrigues |
eff855 |
goto out_put_req;
|
|
Goldwyn Rodrigues |
eff855 |
}
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
+ if ((req->common.ki_flags & IOCB_NOWAIT) &&
|
|
Goldwyn Rodrigues |
eff855 |
+ !(req->common.ki_flags & IOCB_DIRECT)) {
|
|
Goldwyn Rodrigues |
eff855 |
+ ret = -EOPNOTSUPP;
|
|
Goldwyn Rodrigues |
eff855 |
+ goto out_put_req;
|
|
Goldwyn Rodrigues |
eff855 |
+ }
|
|
Goldwyn Rodrigues |
eff855 |
+
|
|
Goldwyn Rodrigues |
eff855 |
ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
|
|
Goldwyn Rodrigues |
eff855 |
if (unlikely(ret)) {
|
|
Goldwyn Rodrigues |
eff855 |
pr_debug("EFAULT: aio_key\n");
|
|
Goldwyn Rodrigues |
eff855 |
diff --git a/include/linux/fs.h b/include/linux/fs.h
|
|
Goldwyn Rodrigues |
eff855 |
index 8b159244d696..c5b445456639 100644
|
|
Goldwyn Rodrigues |
eff855 |
--- a/include/linux/fs.h
|
|
Goldwyn Rodrigues |
eff855 |
+++ b/include/linux/fs.h
|
|
Goldwyn Rodrigues |
eff855 |
@@ -142,6 +142,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
|
|
Goldwyn Rodrigues |
eff855 |
/* File was opened by fanotify and shouldn't generate fanotify events */
|
|
Goldwyn Rodrigues |
eff855 |
#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
+/* File is capable of returning -EAGAIN if AIO will block */
|
|
Goldwyn Rodrigues |
eff855 |
+#define FMODE_AIO_NOWAIT ((__force fmode_t)0x8000000)
|
|
Goldwyn Rodrigues |
eff855 |
+
|
|
Goldwyn Rodrigues |
eff855 |
/*
|
|
Goldwyn Rodrigues |
eff855 |
* Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
|
|
Goldwyn Rodrigues |
eff855 |
* that indicates that they should check the contents of the iovec are
|
|
Goldwyn Rodrigues |
eff855 |
@@ -268,6 +271,7 @@ struct writeback_control;
|
|
Goldwyn Rodrigues |
eff855 |
#define IOCB_DSYNC (1 << 4)
|
|
Goldwyn Rodrigues |
eff855 |
#define IOCB_SYNC (1 << 5)
|
|
Goldwyn Rodrigues |
eff855 |
#define IOCB_WRITE (1 << 6)
|
|
Goldwyn Rodrigues |
eff855 |
+#define IOCB_NOWAIT (1 << 7)
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
struct kiocb {
|
|
Goldwyn Rodrigues |
eff855 |
struct file *ki_filp;
|
|
Goldwyn Rodrigues |
eff855 |
@@ -3078,6 +3082,11 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, int flags)
|
|
Goldwyn Rodrigues |
eff855 |
if (unlikely(flags & ~RWF_SUPPORTED))
|
|
Goldwyn Rodrigues |
eff855 |
return -EOPNOTSUPP;
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
+ if (flags & RWF_NOWAIT) {
|
|
Goldwyn Rodrigues |
eff855 |
+ if (!(ki->ki_filp->f_mode & FMODE_AIO_NOWAIT))
|
|
Goldwyn Rodrigues |
eff855 |
+ return -EOPNOTSUPP;
|
|
Goldwyn Rodrigues |
eff855 |
+ ki->ki_flags |= IOCB_NOWAIT;
|
|
Goldwyn Rodrigues |
eff855 |
+ }
|
|
Goldwyn Rodrigues |
eff855 |
if (flags & RWF_HIPRI)
|
|
Goldwyn Rodrigues |
eff855 |
ki->ki_flags |= IOCB_HIPRI;
|
|
Goldwyn Rodrigues |
eff855 |
if (flags & RWF_DSYNC)
|
|
Goldwyn Rodrigues |
eff855 |
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
|
|
Goldwyn Rodrigues |
eff855 |
index 937c3e39650a..27d8c36c04af 100644
|
|
Goldwyn Rodrigues |
eff855 |
--- a/include/uapi/linux/fs.h
|
|
Goldwyn Rodrigues |
eff855 |
+++ b/include/uapi/linux/fs.h
|
|
Goldwyn Rodrigues |
eff855 |
@@ -360,7 +360,9 @@ struct fscrypt_key {
|
|
Goldwyn Rodrigues |
eff855 |
#define RWF_HIPRI 0x00000001 /* high priority request, poll if possible */
|
|
Goldwyn Rodrigues |
eff855 |
#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */
|
|
Goldwyn Rodrigues |
eff855 |
#define RWF_SYNC 0x00000004 /* per-IO O_SYNC */
|
|
Goldwyn Rodrigues |
eff855 |
+#define RWF_NOWAIT 0x00000008 /* per-IO, return -EAGAIN if operation would block */
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
-#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC)
|
|
Goldwyn Rodrigues |
eff855 |
+#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC |\
|
|
Goldwyn Rodrigues |
eff855 |
+ RWF_NOWAIT)
|
|
Goldwyn Rodrigues |
eff855 |
|
|
Goldwyn Rodrigues |
eff855 |
#endif /* _UAPI_LINUX_FS_H */
|
|
Goldwyn Rodrigues |
eff855 |
--
|
|
Goldwyn Rodrigues |
eff855 |
2.12.3
|
|
Goldwyn Rodrigues |
eff855 |
|