From: Hao Xu <howeyxu@xxxxxxxxxxx> 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@xxxxxxxxxxx> --- 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