From: Kanchan Joshi <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], Kanchan Joshi <[email protected]>
Subject: [PATCH v2 2/2] io_uring: add support for zone-append
Date: Thu, 25 Jun 2020 22:45:49 +0530 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
From: Selvakumar S <[email protected]>
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 <[email protected]>
Signed-off-by: Kanchan Joshi <[email protected]>
Signed-off-by: Nitesh Shetty <[email protected]>
Signed-off-by: Javier Gonzalez <[email protected]>
---
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
next prev parent reply other threads:[~2020-06-25 17:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200625171829epcas5p268486a0780571edb4999fc7b3caab602@epcas5p2.samsung.com>
2020-06-25 17:15 ` [PATCH v2 0/2] zone-append support in io-uring and aio Kanchan Joshi
[not found] ` <CGME20200625171834epcas5p226a24dfcb84cfa83fe29a2bd17795d85@epcas5p2.samsung.com>
2020-06-25 17:15 ` [PATCH v2 1/2] fs,block: Introduce RWF_ZONE_APPEND and handling in direct IO path Kanchan Joshi
2020-06-26 2:50 ` Damien Le Moal
2020-06-29 18:32 ` Kanchan Joshi
2020-06-30 0:37 ` Damien Le Moal
2020-06-30 7:40 ` Kanchan Joshi
2020-06-30 7:52 ` Damien Le Moal
2020-06-30 7:56 ` Damien Le Moal
2020-06-30 8:16 ` Kanchan Joshi
2020-06-26 8:58 ` Christoph Hellwig
2020-06-26 21:15 ` Kanchan Joshi
2020-06-27 6:51 ` Christoph Hellwig
[not found] ` <CGME20200625171838epcas5p449183e12770187142d8d55a9bf422a8d@epcas5p4.samsung.com>
2020-06-25 17:15 ` Kanchan Joshi [this message]
2020-06-25 19:40 ` [PATCH v2 2/2] io_uring: add support for zone-append Pavel Begunkov
2020-06-26 3:11 ` [PATCH v2 0/2] zone-append support in io-uring and aio Damien Le Moal
2020-06-26 6:37 ` javier.gonz
2020-06-26 6:56 ` Damien Le Moal
2020-06-26 7:03 ` [email protected]
2020-06-26 22:15 ` Kanchan Joshi
2020-06-30 12:46 ` Matthew Wilcox
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=1593105349-19270-3-git-send-email-joshi.k@samsung.com \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox