Descriptorless files for io_uring
Descriptorless files for io_uring
Posted Jul 19, 2021 20:30 UTC (Mon) by josh (subscriber, #17465)In reply to: Descriptorless files for io_uring by Cyberax
Parent article: Descriptorless files for io_uring
This is similar to how X Window System clients assign resource IDs: when you create an object like a window or pixmap, you assign the ID yourself from a range of valid IDs you were given, and you can then batch creation and usage of an object in the same batch.
If you then want to use the object outside of io_uring, you can always use an io_uring operation to link the fixed-file into a normal file descriptor, and then use it with normal syscalls. And if you want, you can assign a specific file descriptor yourself rather than relying on the kernel's "allocate the lowest unused number".
Posted Jul 20, 2021 0:46 UTC (Tue)
by Cyberax (✭ supporter ✭, #52523)
[Link] (9 responses)
How?!? This would help me a lot. I can't change all the read/write calls to use io_uring, but I can do that with opens.
Posted Jul 20, 2021 6:03 UTC (Tue)
by josh (subscriber, #17465)
[Link] (8 responses)
Posted Jul 20, 2021 6:44 UTC (Tue)
by Cyberax (✭ supporter ✭, #52523)
[Link] (7 responses)
I guess it can work, but it seems kinda hacky.
Posted Jul 20, 2021 7:08 UTC (Tue)
by josh (subscriber, #17465)
[Link] (6 responses)
If you're a library or otherwise have to cooperatively manage the file descriptor space, you have to take more care, but you could still let your caller tell you a range you can use. Or we could add operations to reserve a range of descriptors for future use.
But ultimately, the best way to have a private space of file descriptors you can allocate as you see fit is to use io_uring with your own private ring and allocate from its fixed file table.
Posted Jul 20, 2021 7:28 UTC (Tue)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
> If you're a program, you own the descriptor space; just pick a high base and allocate descriptors above that as you see fit.
I think I might be missing something, but as far as I understand, all syscalls that create file descriptors can't accept number ranges.
Posted Jul 20, 2021 8:43 UTC (Tue)
by NYKevin (subscriber, #129325)
[Link] (2 responses)
Posted Jul 22, 2021 7:44 UTC (Thu)
by taladar (subscriber, #68407)
[Link] (1 responses)
Posted Aug 3, 2021 20:33 UTC (Tue)
by tobin_baker (guest, #139557)
[Link]
Posted Jul 20, 2021 16:54 UTC (Tue)
by Wol (subscriber, #4433)
[Link] (1 responses)
Okay, you'd need a new open command, but first you'd call a routine to set up your io_uring, and then you have your private file descriptor space - iirc 1 was the tty, 2 might have been the tape drive, up to about 4, and then your program simply allocated file descriptors from 5 upwards. Can't remember the syntax but it was something like
OPEN( unit, filename, attributes)
I guess in C you'd end up doing something like "fd = open(unit, filename, attributes)" where "unit" would be your index into the ring, and "fd" would be whatever the linux file descriptor was, that your uring had block pre-allocated.
Cheers,
Posted Jul 22, 2021 12:18 UTC (Thu)
by ejr (subscriber, #51652)
[Link]
I've been watching this and similar things wondering how much it differs from old methods.
Descriptorless files for io_uring
Descriptorless files for io_uring
Descriptorless files for io_uring
Descriptorless files for io_uring
Descriptorless files for io_uring
A program mostly.
But how can I do that? Is it something that's still being planned?
Descriptorless files for io_uring
Descriptorless files for io_uring
Descriptorless files for io_uring
Descriptorless files for io_uring
Wol
Descriptorless files for io_uring
