public inbox for [email protected]
 help / color / mirror / Atom feed
From: David Laight <[email protected]>
To: "[email protected]" <[email protected]>
Subject: FW: [RFC PATCH 02/12] fs/io_uring Don't use the return value from import_iovec().
Date: Tue, 31 Mar 2020 15:10:15 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>



> -----Original Message-----
> From: David Laight
> Sent: 31 March 2020 14:52
> To: Linux Kernel Mailing List <[email protected]>
> 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 <[email protected]>
> ---
>  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)


           reply	other threads:[~2020-03-31 15:10 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <[email protected]>]

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 \
    [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