io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Subject: Re: [PATCH liburing v5 2/2] test/splice: add basic splice tests
Date: Mon, 24 Feb 2020 11:41:59 -0700	[thread overview]
Message-ID: <89272517-d4c4-1a0f-f955-af2b1c1a337f@kernel.dk> (raw)
In-Reply-To: <20e51d15-82d8-3e91-a1ca-36dccd9d30e7@gmail.com>

On 2/24/20 11:39 AM, Pavel Begunkov wrote:
> On 24/02/2020 21:33, Jens Axboe wrote:
>> On 2/24/20 11:26 AM, Pavel Begunkov wrote:
>>> On 24/02/2020 21:23, Jens Axboe wrote:
>>>> On 2/24/20 10:55 AM, Pavel Begunkov wrote:
>>>>> +static int copy_single(struct io_uring *ring,
>>>>> +			int fd_in, loff_t off_in,
>>>>> +			int fd_out, loff_t off_out,
>>>>> +			int pipe_fds[2],
>>>>> +			unsigned int len,
>>>>> +			unsigned flags1, unsigned flags2)
>>>>> +{
>>>>> +	struct io_uring_cqe *cqe;
>>>>> +	struct io_uring_sqe *sqe;
>>>>> +	int i, ret = -1;
>>>>> +
>>>>> +	sqe = io_uring_get_sqe(ring);
>>>>> +	if (!sqe) {
>>>>> +		fprintf(stderr, "get sqe failed\n");
>>>>> +		return -1;
>>>>> +	}
>>>>> +	io_uring_prep_splice(sqe, fd_in, off_in, pipe_fds[1], -1,
>>>>> +			     len, flags1);
>>>>> +	sqe->flags = IOSQE_IO_LINK;
>>>>> +
>>>>> +	sqe = io_uring_get_sqe(ring);
>>>>> +	if (!sqe) {
>>>>> +		fprintf(stderr, "get sqe failed\n");
>>>>> +		return -1;
>>>>> +	}
>>>>> +	io_uring_prep_splice(sqe, pipe_fds[0], -1, fd_out, off_out,
>>>>> +			     len, flags2);
>>>>> +
>>>>> +	ret = io_uring_submit(ring);
>>>>> +	if (ret <= 1) {
>>>>> +		fprintf(stderr, "sqe submit failed: %d\n", ret);
>>>>> +		return -1;
>>>>> +	}
>>>>
>>>> This seems wrong, you prep one and submit, the right return value would
>>>> be 1. This check should be < 1, not <= 1. I'll make the change, rest
>>>> looks good to me. Thanks!
>>>>
>>>
>>> There are 2 sqes, "fd_in -> pipe" and "pipe -> fd_out".
>>
>> I must be blind... I guess the failure case is that it doesn't work so well
>> on the kernels not supporting splice, as we'll return 1 there as the first
> 
> I've wanted for long to kill this weird behaviour, it should consume the whole
> link. Can't imagine any userspace app handling all edge-case errors right...

Yeah, for links it makes sense to error the chain, which would consume
the whole chain too.

>> submit fails. I'll clean up that bit.
> 
> ...I should have tested better. Thanks!

No worries, just trying to do better than we have in the best so we can
have some vague hope of having the test suite pass on older stable
kernels.

-- 
Jens Axboe


  reply	other threads:[~2020-02-24 18:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24 17:54 [PATCH v5 0/2] splice helpers + tests Pavel Begunkov
2020-02-24 17:55 ` [PATCH liburing v5 1/2] splice: add splice(2) helpers Pavel Begunkov
2020-02-24 17:55 ` [PATCH liburing v5 2/2] test/splice: add basic splice tests Pavel Begunkov
2020-02-24 18:23   ` Jens Axboe
2020-02-24 18:26     ` Pavel Begunkov
2020-02-24 18:33       ` Jens Axboe
2020-02-24 18:39         ` Pavel Begunkov
2020-02-24 18:41           ` Jens Axboe [this message]
2020-02-24 18:47             ` Pavel Begunkov
2020-02-24 19:30               ` Jens Axboe

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=89272517-d4c4-1a0f-f955-af2b1c1a337f@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    /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).