[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1593105349-19270-3-git-send-email-joshi.k@samsung.com>
Date: Thu, 25 Jun 2020 22:45:49 +0530
From: Kanchan Joshi <joshi.k@...sung.com>
To: axboe@...nel.dk, viro@...iv.linux.org.uk, bcrl@...ck.org
Cc: asml.silence@...il.com, Damien.LeMoal@....com, hch@...radead.org,
linux-fsdevel@...r.kernel.org, mb@...htnvm.io,
linux-kernel@...r.kernel.org, linux-aio@...ck.org,
io-uring@...r.kernel.org, linux-block@...r.kernel.org,
selvakuma.s1@...sung.com, nj.shetty@...sung.com,
javier.gonz@...sung.com, Kanchan Joshi <joshi.k@...sung.com>
Subject: [PATCH v2 2/2] io_uring: add support for zone-append
From: Selvakumar S <selvakuma.s1@...sung.com>
For zone-append, block-layer will return zone-relative offset via ret2
of ki_complete interface. Make changes to collect it, and send to
user-space using ceq->flags.
Detect and report early error if zone-append is requested with
fixed-buffers.
Signed-off-by: Selvakumar S <selvakuma.s1@...sung.com>
Signed-off-by: Kanchan Joshi <joshi.k@...sung.com>
Signed-off-by: Nitesh Shetty <nj.shetty@...sung.com>
Signed-off-by: Javier Gonzalez <javier.gonz@...sung.com>
---
fs/io_uring.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 155f3d8..31a9da58 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -402,6 +402,8 @@ struct io_rw {
struct kiocb kiocb;
u64 addr;
u64 len;
+ /* zone-relative offset for append, in sectors */
+ u32 append_offset;
};
struct io_connect {
@@ -541,6 +543,7 @@ enum {
REQ_F_NO_FILE_TABLE_BIT,
REQ_F_QUEUE_TIMEOUT_BIT,
REQ_F_WORK_INITIALIZED_BIT,
+ REQ_F_ZONE_APPEND_BIT,
/* not a real bit, just to check we're not overflowing the space */
__REQ_F_LAST_BIT,
@@ -598,6 +601,8 @@ enum {
REQ_F_QUEUE_TIMEOUT = BIT(REQ_F_QUEUE_TIMEOUT_BIT),
/* io_wq_work is initialized */
REQ_F_WORK_INITIALIZED = BIT(REQ_F_WORK_INITIALIZED_BIT),
+ /* to return zone relative offset for zone append*/
+ REQ_F_ZONE_APPEND = BIT(REQ_F_ZONE_APPEND_BIT),
};
struct async_poll {
@@ -1745,6 +1750,8 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
if (req->flags & REQ_F_BUFFER_SELECTED)
cflags = io_put_kbuf(req);
+ if (req->flags & REQ_F_ZONE_APPEND)
+ cflags = req->rw.append_offset;
__io_cqring_fill_event(req, req->result, cflags);
(*nr_events)++;
@@ -1943,7 +1950,7 @@ static inline void req_set_fail_links(struct io_kiocb *req)
req->flags |= REQ_F_FAIL_LINK;
}
-static void io_complete_rw_common(struct kiocb *kiocb, long res)
+static void io_complete_rw_common(struct kiocb *kiocb, long res, long res2)
{
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
int cflags = 0;
@@ -1953,8 +1960,14 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res)
if (res != req->result)
req_set_fail_links(req);
+
if (req->flags & REQ_F_BUFFER_SELECTED)
cflags = io_put_kbuf(req);
+
+ /* use cflags to return zone append completion result */
+ if (req->flags & REQ_F_ZONE_APPEND)
+ cflags = res2;
+
__io_cqring_add_event(req, res, cflags);
}
@@ -1962,7 +1975,7 @@ static void io_complete_rw(struct kiocb *kiocb, long res, long res2)
{
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
- io_complete_rw_common(kiocb, res);
+ io_complete_rw_common(kiocb, res, res2);
io_put_req(req);
}
@@ -1975,6 +1988,9 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)
if (res != req->result)
req_set_fail_links(req);
+ if (req->flags & REQ_F_ZONE_APPEND)
+ req->rw.append_offset = res2;
+
req->result = res;
if (res != -EAGAIN)
WRITE_ONCE(req->iopoll_completed, 1);
@@ -2127,6 +2143,9 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (kiocb->ki_flags & IOCB_NOWAIT)
req->flags |= REQ_F_NOWAIT;
+ if (kiocb->ki_flags & IOCB_ZONE_APPEND)
+ req->flags |= REQ_F_ZONE_APPEND;
+
if (force_nonblock)
kiocb->ki_flags |= IOCB_NOWAIT;
@@ -2409,6 +2428,14 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
opcode = req->opcode;
if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) {
+ /*
+ * fixed-buffers not supported for zone-append.
+ * This check can be removed when block-layer starts
+ * supporting append with iov_iter of bvec type
+ */
+ if (req->flags == REQ_F_ZONE_APPEND)
+ return -EINVAL;
+
*iovec = NULL;
return io_import_fixed(req, rw, iter);
}
@@ -2704,6 +2731,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock)
req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;
req->result = 0;
+
io_size = ret;
if (req->flags & REQ_F_LINK_HEAD)
req->result = io_size;
--
2.7.4
Powered by blists - more mailing lists