[<prev] [next>] [day] [month] [year] [list]
Message-ID: <87c31730ece341b0bdf29745b9411ab8@AcuMS.aculab.com>
Date: Tue, 31 Mar 2020 13:52:29 +0000
From: David Laight <David.Laight@...LAB.COM>
To: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 02/12] fs/io_uring Don't use the return value from
import_iovec().
This is the only code that relies on import_iovec() returning
iter.count on success.
Not using the value actually saves passing it through to functions
that are also passed the 'iter'.
This allows a better interface to import_iovec().
Signed-off-by: David Laight <david.laight@...lab.com>
---
fs/io_uring.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3affd96..d8dc2e2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2153,12 +2153,11 @@ static ssize_t loop_rw_iter(int rw, struct file *file, struct kiocb *kiocb,
return ret;
}
-static void io_req_map_rw(struct io_kiocb *req, ssize_t io_size,
- struct iovec *iovec, struct iovec *fast_iov,
- struct iov_iter *iter)
+static void io_req_map_rw(struct io_kiocb *req, struct iovec *iovec,
+ struct iovec *fast_iov, struct iov_iter *iter)
{
req->io->rw.nr_segs = iter->nr_segs;
- req->io->rw.size = io_size;
+ req->io->rw.size = iter->count;
req->io->rw.iov = iovec;
if (!req->io->rw.iov) {
req->io->rw.iov = req->io->rw.fast_iov;
@@ -2177,9 +2176,8 @@ static int io_alloc_async_ctx(struct io_kiocb *req)
return req->io == NULL;
}
-static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
- struct iovec *iovec, struct iovec *fast_iov,
- struct iov_iter *iter)
+static int io_setup_async_rw(struct io_kiocb *req, struct iovec *iovec,
+ struct iovec *fast_iov, struct iov_iter *iter)
{
if (!io_op_defs[req->opcode].async_ctx)
return 0;
@@ -2187,7 +2185,7 @@ static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
if (io_alloc_async_ctx(req))
return -ENOMEM;
- io_req_map_rw(req, io_size, iovec, fast_iov, iter);
+ io_req_map_rw(req, iovec, fast_iov, iter);
}
return 0;
}
@@ -2218,7 +2216,7 @@ static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0)
return ret;
- io_req_map_rw(req, ret, io->rw.iov, io->rw.fast_iov, &iter);
+ io_req_map_rw(req, io->rw.iov, io->rw.fast_iov, &iter);
return 0;
}
@@ -2229,7 +2227,7 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
struct kiocb *kiocb = &req->rw.kiocb;
struct iov_iter iter;
size_t iov_count;
- ssize_t io_size, ret;
+ ssize_t ret;
ret = io_import_iovec(READ, req, &iovec, &iter);
if (ret < 0)
@@ -2240,9 +2238,8 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;
req->result = 0;
- io_size = ret;
if (req->flags & REQ_F_LINK)
- req->result = io_size;
+ req->result = iter.count;
/*
* If the file doesn't support async, mark it as REQ_F_MUST_PUNT so
@@ -2268,8 +2265,7 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
kiocb_done(kiocb, ret2, nxt, req->in_async);
} else {
copy_iov:
- ret = io_setup_async_rw(req, io_size, iovec,
- inline_vecs, &iter);
+ ret = io_setup_async_rw(req, iovec, inline_vecs, &iter);
if (ret)
goto out_free;
return -EAGAIN;
@@ -2307,7 +2303,7 @@ static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0)
return ret;
- io_req_map_rw(req, ret, io->rw.iov, io->rw.fast_iov, &iter);
+ io_req_map_rw(req, io->rw.iov, io->rw.fast_iov, &iter);
return 0;
}
@@ -2318,7 +2314,7 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
struct kiocb *kiocb = &req->rw.kiocb;
struct iov_iter iter;
size_t iov_count;
- ssize_t ret, io_size;
+ ssize_t ret;
ret = io_import_iovec(WRITE, req, &iovec, &iter);
if (ret < 0)
@@ -2329,9 +2325,8 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;
req->result = 0;
- io_size = ret;
if (req->flags & REQ_F_LINK)
- req->result = io_size;
+ req->result = iter.count;
/*
* If the file doesn't support async, mark it as REQ_F_MUST_PUNT so
@@ -2381,8 +2376,7 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
kiocb_done(kiocb, ret2, nxt, req->in_async);
} else {
copy_iov:
- ret = io_setup_async_rw(req, io_size, iovec,
- inline_vecs, &iter);
+ ret = io_setup_async_rw(req, iovec, inline_vecs, &iter);
if (ret)
goto out_free;
return -EAGAIN;
--
1.8.1.2
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists