io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring: kill extra checks in io_write()
@ 2021-09-24 16:14 Pavel Begunkov
  2021-09-24 16:26 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-09-24 16:14 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: Dave Jones

We don't retry short writes and so we would never get to async setup in
io_write() in that case. Thus ret2 > 0 is always false and
iov_iter_advance() is never used. Apparently, the same is found by
Coverity, which complains on the code.

Reported-by: Dave Jones <davej@codemonkey.org.uk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7bfd2d00d4fc..d7888bb78cbf 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3604,7 +3604,6 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
 		iov_iter_save_state(iter, state);
 	}
 	req->result = iov_iter_count(iter);
-	ret2 = 0;
 
 	/* Ensure we clear previously set non-block flag */
 	if (!force_nonblock)
@@ -3669,8 +3668,6 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
 	} else {
 copy_iov:
 		iov_iter_restore(iter, state);
-		if (ret2 > 0)
-			iov_iter_advance(iter, ret2);
 		ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
 		return ret ?: -EAGAIN;
 	}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io_uring: kill extra checks in io_write()
  2021-09-24 16:14 [PATCH] io_uring: kill extra checks in io_write() Pavel Begunkov
@ 2021-09-24 16:26 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-09-24 16:26 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring; +Cc: Dave Jones

On 9/24/21 10:14 AM, Pavel Begunkov wrote:
> We don't retry short writes and so we would never get to async setup in
> io_write() in that case. Thus ret2 > 0 is always false and
> iov_iter_advance() is never used. Apparently, the same is found by
> Coverity, which complains on the code.

Thanks, applied. Should have a:

Fixes: cd65869512ab ("io_uring: use iov_iter state save/restore helpers")

which I added.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-24 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 16:14 [PATCH] io_uring: kill extra checks in io_write() Pavel Begunkov
2021-09-24 16:26 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).