IO without entering kernel

0
3

diff –git a/fs/aio.c b/fs/aio.c

index 509d4d5..9f93a30 100644

— a/
fs/aio.c
+++ b/
fs/aio.c

@@ -1367,6 +1367,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;

@@ -1378,10 +1379,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

@@ -67,6 +67,12 @@ struct io_event {

};

/*

+ * 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

* proper padding and aio_error abstraction

Read More

This site uses Akismet to reduce spam. Learn how your comment data is processed.