Re: [PATCH v4 6/6] io_uring: add support for zone-append

From: hch@xxxxxxxxxxxxx
Date: Fri Jul 31 2020 - 09:08:16 EST


And FYI, this is what I'd do for a hacky aio-only prototype (untested):


diff --git a/fs/aio.c b/fs/aio.c
index 91e7cc4a9f179b..42b1934e38758b 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1438,7 +1438,10 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2)
}

iocb->ki_res.res = res;
- iocb->ki_res.res2 = res2;
+ if ((kiocb->ki_flags & IOCB_REPORT_OFFSET) && res > 0)
+ iocb->ki_res.res2 = kiocb->ki_pos - res;
+ else
+ iocb->ki_res.res2 = res2;
iocb_put(iocb);
}

@@ -1452,6 +1455,8 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
req->ki_flags = iocb_flags(req->ki_filp);
if (iocb->aio_flags & IOCB_FLAG_RESFD)
req->ki_flags |= IOCB_EVENTFD;
+ if (iocb->aio_flags & IOCB_FLAG_REPORT_OFFSET)
+ req->ki_flags |= IOCB_REPORT_OFFSET;
req->ki_hint = ki_hint_validate(file_write_hint(req->ki_filp));
if (iocb->aio_flags & IOCB_FLAG_IOPRIO) {
/*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f5abba86107d86..522b0a3437d420 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -316,6 +316,7 @@ enum rw_hint {
#define IOCB_WRITE (1 << 6)
#define IOCB_NOWAIT (1 << 7)
#define IOCB_NOIO (1 << 9)
+#define IOCB_REPORT_OFFSET (1 << 10)

struct kiocb {
struct file *ki_filp;
diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h
index 8387e0af0f768a..e4313d7aa3b7e7 100644
--- a/include/uapi/linux/aio_abi.h
+++ b/include/uapi/linux/aio_abi.h
@@ -55,6 +55,7 @@ enum {
*/
#define IOCB_FLAG_RESFD (1 << 0)
#define IOCB_FLAG_IOPRIO (1 << 1)
+#define IOCB_FLAG_REPORT_OFFSET (1 << 2)

/* read() from /dev/aio returns these structures. */
struct io_event {