Re: [RFC PATCH] io_uring: add support for IORING_OP_IOCTL
From: Stefan Metzmacher
Date: Wed Jan 08 2020 - 08:55:24 EST
Hi Jens,
> While the ioctl approach is tempting, for the use cases where it makes
> sense, I think we should just add a ioctl type opcode and have the
> sub-opcode be somewhere else in the sqe. Because I do think there's
> a large opportunity to expose a fast API that works with ioctl like
> mechanisms. If we have
>
> IORING_OP_IOCTL
>
> and set aside an sqe field for the per-driver (or per-user) and
> add a file_operations method for sending these to the fd, then we'll
> have a much better (and faster + async) API than ioctls. We could
> add fops->uring_issue() or something, and that passes the io_kiocb.
> When it completes, the ->io_uring_issue() posts a completion by
> calling io_uring_complete_req() or something.
>
> Outside of the issues that Jann outlined, ioctls are also such a
> decade old mess that we have to do the -EAGAIN punt for all of them
> like you did in your patch. If it's opt-in like ->uring_issue(), then
> care could be taken to do this right and just have it return -EAGAIN
> if it does need async context.
>
> ret = fops->uring_issue(req, force_nonblock);
> if (ret == -EAGAIN) {
> ... usual punt ...
> }
>
> I think working on this would be great, and some of the more performance
> sensitive ioctl cases should flock to it.
I could use also use a generic way for an async fd-based syscall.
I thought about using sendmsg() with special CMSG_ elements, but
currently it's not possible with IORING_OP_SENDMSG to do an async
io_kiocb based completion, using msg_iocb.
My use case would be samba triggering async sendfile-like io for
the SMB-Direct protocol, doing multiple async file io operations
followed by RDMA-WRITE operations as a single async syscall from userspace.
Thanks!
metze