From: Jens Axboe <axboe@kernel.dk>
To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org
Cc: viro@ZenIV.linux.org.uk, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 8/8] io_uring: add io_uring_event cache hit information
Date: Thu, 14 Mar 2019 14:44:35 -0600 [thread overview]
Message-ID: <20190314204435.7692-9-axboe@kernel.dk> (raw)
In-Reply-To: <20190314204435.7692-1-axboe@kernel.dk>
Add hint on whether a read was served out of the page cache, or if it
hit media. This is useful for buffered async IO, O_DIRECT reads would
never have this set (for obvious reasons).
If the read hit page cache, cqe->flags will have IOCQE_FLAG_CACHEHIT
set.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
fs/io_uring.c | 6 +++++-
include/uapi/linux/io_uring.h | 5 +++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index b89f91ab6e32..3437f538b377 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -625,10 +625,14 @@ static void kiocb_end_write(struct kiocb *kiocb)
static void io_complete_rw(struct kiocb *kiocb, long res, long res2)
{
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw);
+ unsigned ev_flags = 0;
kiocb_end_write(kiocb);
- io_cqring_add_event(req->ctx, req->user_data, res, 0);
+ if (res > 0 && (req->flags & REQ_F_FORCE_NONBLOCK))
+ ev_flags = IOCQE_FLAG_CACHEHIT;
+
+ io_cqring_add_event(req->ctx, req->user_data, res, ev_flags);
io_put_req(req);
}
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index e23408692118..24906e99fdc7 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -69,6 +69,11 @@ struct io_uring_cqe {
__u32 flags;
};
+/*
+ * io_uring_event->flags
+ */
+#define IOCQE_FLAG_CACHEHIT (1U << 0) /* IO did not hit media */
+
/*
* Magic offsets for the application to mmap the data it needs
*/
--
2.17.1
prev parent reply other threads:[~2019-03-14 20:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-14 20:44 [PATCHSET 0/8] io_uring fixes Jens Axboe
2019-03-14 20:44 ` [PATCH 1/8] io_uring: use regular request ref counts Jens Axboe
2019-03-14 20:44 ` [PATCH 2/8] io_uring: make io_read/write return an integer Jens Axboe
2019-03-14 20:44 ` [PATCH 3/8] io_uring: add prepped flag Jens Axboe
2019-03-14 20:44 ` [PATCH 4/8] io_uring: fix fget/fput handling Jens Axboe
2019-03-14 20:44 ` [PATCH 5/8] io_uring: fix poll races Jens Axboe
2019-03-14 20:44 ` [PATCH 6/8] iov_iter: add ITER_BVEC_FLAG_NO_REF flag Jens Axboe
2019-03-14 20:44 ` [PATCH 7/8] block: add BIO_NO_PAGE_REF flag Jens Axboe
2019-03-14 20:44 ` Jens Axboe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190314204435.7692-9-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.