Re: [PATCH 13/18] io_uring: add file set registration
From: Al Viro <viro@zeniv.linux.org.uk>
Date: 2019-02-07 16:30:51
Also in:
linux-block, linux-fsdevel
On Thu, Feb 07, 2019 at 09:14:41AM -0700, Jens Axboe wrote:
I created a small app to do just that, and ran it and verified that ->release() is called and the io_uring is released as expected. This is run on the current -git branch, which has a socket backing for the io_uring fd itself, but not for the registered files. What am I missing here? Attaching the program as a reference.
int main(int argc, char *argv[])
{
int sp[2], pid, ring_fd, ret;
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sp) != 0) {
perror("Failed to create Unix-domain socket pair\n");
return 1;
}
ring_fd = get_ring_fd();
if (ring_fd < 0)
return 1;
ret = io_uring_register_files(ring_fd, sp[0], sp[1]);
if (ret < 0) {
perror("register files");
return 1;
}
pid = fork();
if (pid) {
printf("Sending fd %d\n", ring_fd);
send_fd(sp[0], ring_fd);
} else {
int fd;
fd = recv_fd(sp[1]);Well, yes - once you receive it, you obviously have no references sitting in SCM_RIGHTS anymore. Get rid of recv_fd() there (along with fork(), while we are at it - what's it for?) and just do send_fd + these 3 close (or just exit, for that matter). -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>