[PATCH 21/22] aio: utilize io_event->res2 for CQ ring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We don't use this at all, grab it to provide hints about the data.
The first hint we add is IORING_RES2_CACHEHIT, whether a read was
served out of the page cache, or if it hit media. This is useful
for buffered aio, O_DIRECT reads would never have this set (for
obvious reasons).

Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
 fs/aio.c                     | 7 +++++--
 include/uapi/linux/aio_abi.h | 6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index b6002d7cccb7..b194f0b1f2f8 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1369,6 +1369,7 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2)
 	struct kioctx *ctx = iocb->ki_ctx;
 
 	if (ctx->flags & IOCTX_FLAG_SCQRING) {
+		int nowait = test_bit(KIOCB_F_FORCE_NONBLOCK, &iocb->ki_flags);
 		unsigned long flags;
 		struct io_event *ev;
 		unsigned int tail;
@@ -1380,10 +1381,12 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2)
 		 * see it and punt to workqueue. This is just for buffered
 		 * aio reads.
 		 */
-		if (res == -EAGAIN &&
-		    test_bit(KIOCB_F_FORCE_NONBLOCK, &iocb->ki_flags)) {
+		if (res == -EAGAIN && nowait) {
 			ctx->submit_eagain = 1;
 		} else {
+			if (nowait)
+				res2 = IOEV_RES2_CACHEHIT;
+
 			/*
 			 * If we can't get a cq entry, userspace overflowed the
 			 * submission (by quite a lot). Flag it as an overflow
diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h
index 26173de01fee..809c6f33f5e6 100644
--- a/include/uapi/linux/aio_abi.h
+++ b/include/uapi/linux/aio_abi.h
@@ -66,6 +66,12 @@ struct io_event {
 	__s64		res2;		/* secondary result */
 };
 
+/*
+ * aio CQ ring commandeers the otherwise unused ev->res2 to provide
+ * metadata about the IO.
+ */
+#define IOEV_RES2_CACHEHIT	(1 << 0)	/* IO did not hit media */
+
 /*
  * we always use a 64bit off_t when communicating
  * with userland.  its up to libraries to do the
-- 
2.17.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux