Re: [PATCH 3/4] io_uring: add IORING_OP_READ[WRITE]_SPLICE_BUF

Jens Axboe
2023-02-11T17:13:42Z

On 2/10/23 8:32?AM, Ming Lei wrote:

One more comment on this.

> +static int __io_prep_rw_splice_buf(struct io_kiocb *req,
> + struct io_rw_splice_buf_data *data,
> + struct file *splice_f,
> + size_t len,
> + loff_t splice_off)
> +{
> + unsigned flags = req->opcode == IORING_OP_READ_SPLICE_BUF ?
> + SPLICE_F_KERN_FOR_READ : SPLICE_F_KERN_FOR_WRITE;
> + struct splice_desc sd = {
> + .total_len = len,
> + .flags = flags | SPLICE_F_NONBLOCK | SPLICE_F_KERN_NEED_CONFIRM,
> + .pos = splice_off,
> + .u.data = data,
> + .ignore_sig = true,
> + };
> +
> + return splice_direct_to_actor(splice_f, &sd,
> + io_splice_buf_direct_actor);

Is this safe? We end up using current->splice_pipe here, which should be
fine as long as things are left in a sane state after every operation.
Which they should be, just like a syscall would. Just wanted to make
sure you've considered that part.

--
Jens Axboe