fs/io_uring Don't use the return value from import_iovec().
Subsystems (4)
PATCH 4/9 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.
This allows a better interface to import_iovec().
--- fs/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/io_uring.c +4 -4
@@ -2824,7 +2824,7 @@ static ssize_t __io_import_iovec(int rw, struct io_kiocb *req, ret =import_single_range (rw, buf, sqe_len, *iovec, iter); *iovec =NULL ; -return ret <0 ? ret : sqe_len; +return ret; }if (req->flags &REQ_F_BUFFER_SELECT ) {
@@ -2853,7 +2853,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,if (!req->io)return __io_import_iovec (rw, req, iovec, iter, needs_lock); *iovec =NULL ; -return iov_iter_count (&req->io->rw.iter); +return 0 ; }static inline loff_t *io_kiocb_ppos (struct kiocb *kiocb)
@@ -3123,7 +3123,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size; ret =0 ;
@@ -3246,7 +3246,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size;/* Ensure we clear previously set non-block flag */
Signature · 5 lines
2.25.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Quoted 4 lines · David Laight
This is the only code that relies on
import_iovec()returning iter.count on success.
This allows a better interface toimport_iovec().
This looks generall sane, but a comment below:
Quoted 10 lines
fs/io_uring.c +1
-1@@ -3123,7 +3123,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size; ret =0 ;
fs/io_uring.c static int io_write(struct io_kiocb *req, bool force_nonblock, · line 3250
Quoted 6 lines
fs/io_uring.c +1
-1@@ -3246,7 +3246,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size;
I tink the local iov_count variable can go away in both functions, as io_size only changes after the last use of iov_count (io_read) or not at all (io_write).
From: Christoph Hellwig
Quoted 19 lines
Sent: 21 September 2020 15:15
Quoted 4 lines · David Laight
This is the only code that relies on
import_iovec()returning iter.count on success.
This allows a better interface toimport_iovec().This looks generall sane, but a comment below:
Quoted 9 lines
fs/io_uring.c +1
-1@@ -3123,7 +3123,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size; ret =0 ;
Quoted 11 lines
fs/io_uring.c static int io_write(struct io_kiocb *req, bool force_nonblock, · line 3250
Quoted 7 lines
fs/io_uring.c +1
-1@@ -3246,7 +3246,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size;I tink the local
iov_countvariable can go away in both functions, asio_sizeonly changes after the last use ofiov_count(io_read) or not at all (io_write).
Yes, the compiler will probably make that optimisation.
I did a minimal change because my head hurts whenever I look at io_uring.c.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Pavel Begunkov
Reviewed-byQuoted 8 lines · David Laight
From: Christoph Hellwig
Quoted 7 lines
Sent: 21 September 2020 15:15
Quoted 4 lines · David Laight
This is the only code that relies on
import_iovec()returning iter.count on success.
This allows a better interface toimport_iovec().
Quoted 12 lines
Quoted 12 lines
This looks generall sane, but a comment below:
Quoted 9 lines
fs/io_uring.c +1
-1@@ -3123,7 +3123,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size; ret =0 ;
Quoted 11 lines
Quoted 11 lines
fs/io_uring.c static int io_write(struct io_kiocb *req, bool force_nonblock, · line 3250
Quoted 7 lines
fs/io_uring.c +1
-1@@ -3246,7 +3246,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size;I tink the local
iov_countvariable can go away in both functions, asio_sizeonly changes after the last use ofiov_count(io_read) or not at all (io_write).
Yes, iov_count should be killed, now or later.
Quoted 10 lines
Yes, the compiler will probably make that optimisation.
I did a minimal change because my head hurts whenever I look atio_uring.c.David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Signature · 1 line
Pavel Begunkov
Quoted 4 lines · David Laight
This is the only code that relies on
import_iovec()returning iter.count on success.
This allows a better interface toimport_iovec().
Seems this got nowhere. I'll pick it and send with some other patches to Jens.
Quoted 46 lines
Signed-off-by David Laight <[email protected]>--- fs/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/io_uring.c +4
-4@@ -2824,7 +2824,7 @@ static ssize_t __io_import_iovec(int rw, struct io_kiocb *req, ret =import_single_range (rw, buf, sqe_len, *iovec, iter); *iovec =NULL ; -return ret <0 ? ret : sqe_len; +return ret; }if (req->flags &REQ_F_BUFFER_SELECT ) {@@ -2853,7 +2853,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,if (!req->io)return __io_import_iovec (rw, req, iovec, iter, needs_lock); *iovec =NULL ; -return iov_iter_count (&req->io->rw.iter); +return 0 ; }static inline loff_t *io_kiocb_ppos (struct kiocb *kiocb)@@ -3123,7 +3123,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size; ret =0 ;@@ -3246,7 +3246,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,if (ret <0 )return ret; iov_count =iov_iter_count (iter); - io_size = ret; + io_size = iov_count; req->result = io_size;/* Ensure we clear previously set non-block flag */
Signature · 1 line
Pavel Begunkov