From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-f68.google.com ([209.85.166.68]:38368 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391685AbeLUTXP (ORCPT ); Fri, 21 Dec 2018 14:23:15 -0500 Received: by mail-io1-f68.google.com with SMTP id l14so4487584ioj.5 for ; Fri, 21 Dec 2018 11:23:14 -0800 (PST) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-block@vger.kernel.org Cc: hch@lst.de, viro@zeniv.linux.org.uk, Jens Axboe Subject: [PATCH 21/22] aio: utilize io_event->res2 for CQ ring Date: Fri, 21 Dec 2018 12:22:35 -0700 Message-Id: <20181221192236.12866-22-axboe@kernel.dk> In-Reply-To: <20181221192236.12866-1-axboe@kernel.dk> References: <20181221192236.12866-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- 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 8894c9299b39..a433503a2dc3 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1361,6 +1361,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; @@ -1372,10 +1373,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