From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Subject: Re: [PATCH v4 2/6] io_uring/mock: add cmd using vectored regbufs
Date: Fri, 30 May 2025 14:40:23 +0100 [thread overview]
Message-ID: <4207774d-5f78-46d6-9829-4feb24c81799@gmail.com> (raw)
In-Reply-To: <bd72b25d-b809-4743-a857-7744a3586bea@kernel.dk>
On 5/30/25 14:25, Jens Axboe wrote:
> On 5/30/25 6:51 AM, Pavel Begunkov wrote:
>> +static int io_copy_regbuf(struct iov_iter *reg_iter, void __user *ubuf)
>> +{
>> + size_t ret, copied = 0;
>> + size_t buflen = PAGE_SIZE;
>> + void *tmp_buf;
>> +
>> + tmp_buf = kzalloc(buflen, GFP_KERNEL);
>> + if (!tmp_buf)
>> + return -ENOMEM;
>> +
>> + while (iov_iter_count(reg_iter)) {
>> + size_t len = min(iov_iter_count(reg_iter), buflen);
>> +
>> + if (iov_iter_rw(reg_iter) == ITER_SOURCE) {
>> + ret = copy_from_iter(tmp_buf, len, reg_iter);
>> + if (ret <= 0)
>> + break;
>> + if (copy_to_user(ubuf, tmp_buf, ret))
>> + break;
>> + } else {
>> + if (copy_from_user(tmp_buf, ubuf, len))
>> + break;
>> + ret = copy_to_iter(tmp_buf, len, reg_iter);
>> + if (ret <= 0)
>> + break;
>> + }
>
> Do copy_{to,from}_iter() not follow the same "bytes not copied" return
> value that the copy_{to,from}_user() do? From a quick look, looks like
> they do.
>
> Minor thing, no need for a respin just for that.
One returns 0 on success the other the number of processed bytes.
--
Pavel Begunkov
next prev parent reply other threads:[~2025-05-30 13:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-30 12:51 [PATCH v4 0/6] io_uring/mock: add basic infra for test mock files Pavel Begunkov
2025-05-30 12:51 ` [PATCH v4 1/6] " Pavel Begunkov
2025-05-30 13:28 ` Jens Axboe
2025-05-30 13:57 ` Pavel Begunkov
2025-05-30 14:36 ` Jens Axboe
2025-05-30 14:09 ` Pavel Begunkov
2025-05-30 14:12 ` Pavel Begunkov
2025-05-30 14:26 ` Pavel Begunkov
2025-05-30 14:41 ` Jens Axboe
2025-05-30 15:11 ` Pavel Begunkov
2025-05-30 15:30 ` Jens Axboe
2025-05-30 18:14 ` Pavel Begunkov
2025-06-02 15:19 ` Jens Axboe
2025-06-02 15:31 ` Pavel Begunkov
2025-06-02 15:41 ` Jens Axboe
2025-05-30 18:04 ` Keith Busch
2025-05-30 18:21 ` Pavel Begunkov
2025-06-02 13:44 ` Jens Axboe
2025-05-30 12:51 ` [PATCH v4 2/6] io_uring/mock: add cmd using vectored regbufs Pavel Begunkov
2025-05-30 13:25 ` Jens Axboe
2025-05-30 13:40 ` Pavel Begunkov [this message]
2025-05-30 14:37 ` Jens Axboe
2025-05-30 14:53 ` Pavel Begunkov
2025-05-30 15:34 ` Jens Axboe
2025-05-30 12:52 ` [PATCH v4 3/6] io_uring/mock: add sync read/write Pavel Begunkov
2025-05-30 12:52 ` [PATCH v4 4/6] io_uring/mock: allow to choose FMODE_NOWAIT Pavel Begunkov
2025-05-30 12:52 ` [PATCH v4 5/6] io_uring/mock: support for async read/write Pavel Begunkov
2025-05-30 13:27 ` Jens Axboe
2025-05-30 13:49 ` Pavel Begunkov
2025-05-30 14:38 ` Jens Axboe
2025-05-30 12:52 ` [PATCH v4 6/6] io_uring/mock: add trivial poll handler Pavel Begunkov
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=4207774d-5f78-46d6-9829-4feb24c81799@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--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