io_uring_register_files(3) | liburing Manual | io_uring_register_files(3) |
io_uring_register_files - register file descriptors
#include <liburing.h>
int io_uring_register_files(struct io_uring *ring, const int *files, unsigned nr_files);
int io_uring_register_files_sparse(struct io_uring *ring, unsigned nr_files);
The io_uring_register_files(3) function registers nr_files number of file descriptors defined by the array files belonging to the ring for subsequent operations.
The io_uring_register_files_sparse(3) function registers an empty file table of nr_files number of file descriptors. The sparse variant is available in kernels 5.19 and later.
Registering a file table is a prerequisite for using any request that uses direct descriptors.
Registered files have less overhead per operation than normal files. This is due to the kernel grabbing a reference count on a file when an operation begins, and dropping it when it's done. When the process file table is shared, for example if the process has ever created any threads, then this cost goes up even more. Using registered files reduces the overhead of file reference management across requests that operate on a file.
On success io_uring_register_files(3) and io_uring_register_files_sparse(3) return 0. On failure they return -errno.
November 15, 2021 | liburing-2.1 |