linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hao Xu <hao.xu@linux.dev>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	linux-fsdevel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Subject: [PATCH 1/5] io_uring: move sp->len check up for splice and tee
Date: Tue,  7 Jun 2022 16:06:15 +0800	[thread overview]
Message-ID: <20220607080619.513187-2-hao.xu@linux.dev> (raw)
In-Reply-To: <20220607080619.513187-1-hao.xu@linux.dev>

From: Hao Xu <howeyxu@tencent.com>

The traditional sync splice code return 0 if len is 0 at the beginning
of syscall, similar thing for tee. So move up sp->len zero check so that
it reaches quick ending when len is 0.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
---
 io_uring/splice.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/io_uring/splice.c b/io_uring/splice.c
index 0e19d6330345..b2cd1044c3ee 100644
--- a/io_uring/splice.c
+++ b/io_uring/splice.c
@@ -53,6 +53,9 @@ int io_tee(struct io_kiocb *req, unsigned int issue_flags)
 	struct file *in;
 	long ret = 0;
 
+	if (unlikely(!sp->len))
+		goto done;
+
 	if (issue_flags & IO_URING_F_NONBLOCK)
 		return -EAGAIN;
 
@@ -65,8 +68,7 @@ int io_tee(struct io_kiocb *req, unsigned int issue_flags)
 		goto done;
 	}
 
-	if (sp->len)
-		ret = do_tee(in, out, sp->len, flags);
+	ret = do_tee(in, out, sp->len, flags);
 
 	if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
 		io_put_file(in);
@@ -95,6 +97,9 @@ int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 	struct file *in;
 	long ret = 0;
 
+	if (unlikely(!sp->len))
+		goto done;
+
 	if (issue_flags & IO_URING_F_NONBLOCK)
 		return -EAGAIN;
 
@@ -110,8 +115,7 @@ int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 	poff_in = (sp->off_in == -1) ? NULL : &sp->off_in;
 	poff_out = (sp->off_out == -1) ? NULL : &sp->off_out;
 
-	if (sp->len)
-		ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
+	ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
 
 	if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
 		io_put_file(in);
-- 
2.25.1


  reply	other threads:[~2022-06-07  8:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07  8:06 [RFC 0/5] support nonblock submission for splice pipe to pipe Hao Xu
2022-06-07  8:06 ` Hao Xu [this message]
2022-06-07  8:06 ` [PATCH 2/5] pipe: add trylock helpers for pipe lock Hao Xu
2022-06-07  8:06 ` [PATCH 3/5] splice: support nonblock for splice from pipe to pipe Hao Xu
2022-06-07  8:06 ` [PATCH 4/5] io_uring: support nonblock try for splicing " Hao Xu
2022-06-07 21:38   ` kernel test robot
2022-06-08 14:18   ` kernel test robot
2022-06-09  2:24   ` kernel test robot
2022-06-07  8:06 ` [PATCH 5/5] io_uring: add file_in in io_splice{} to avoid duplicate calculation Hao Xu
2022-06-07  8:13 ` [RFC 0/5] support nonblock submission for splice pipe to pipe Hao Xu
2022-06-07  9:27 ` Pavel Begunkov
2022-06-08  4:19   ` Hao Xu
2022-06-08  4:31     ` Jens Axboe
2022-06-08 11:33     ` Pavel Begunkov
2022-06-14 13:23 ` Hao Xu

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=20220607080619.513187-2-hao.xu@linux.dev \
    --to=hao.xu@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=kuniyu@amazon.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).