io_uring_register_files(3)
β¨ io_uring_register_files β register file descriptors β¨
okay bestie, welcome to the liburing Manual π«Ά this is the page for io_uring_register_files(3) and its little squad of file-table-registering besties, and honestly? it's giving β¨kernel-level efficiencyβ¨. let's get into it.
πΈ NAME πΈ
io_uring_register_files β register file descriptors π
π SYNOPSIS π
#include <liburing.h>
int io_uring_register_files(struct io_uring *ring,
const int *files,
unsigned nr_files);
int io_uring_register_files_tags(struct io_uring *ring,
const int *files,
const __u64 *tags,
unsigned nr);
int io_uring_register_files_sparse(struct io_uring *ring,
unsigned nr_files);
int io_uring_register_files_update(struct io_uring *ring,
unsigned off,
const int *files,
unsigned nr_files);
int io_uring_register_files_update_tag(struct io_uring *ring,
unsigned off,
const int *files,
const __u64 *tags,
unsigned nr_files);
π DESCRIPTION π
so. the main character: io_uring_register_files(3). she registers nr_files number of file descriptors, defined by the array files, and those belong to the ring for all the operations that come after. registering them = they're officially part of the ring's roster now π
then there's io_uring_register_files_tags(3), which literally behaves the same as io_uring_register_files(3) except it also takes a tags parameter. the resource tagging deets live over in IORING_REGISTER_BUFFERS2, so go peek at that if you need the lore π
and io_uring_register_files_sparse(3)? she registers an empty file table of nr_files number of file descriptors. those files have to be updated before you actually use them, like, for example with io_uring_register_files_update_tag(3). no cap, an empty table is an empty table. π
real talk though: if the size of that sparse table exceeds whatRLIMIT_NOFILEallows, thenio_uring_register_files_sparse(3)will attempt to raise the limit usingsetrlimit(2) and then retry the operation. and if the registration still fails after all that effort? an error gets returned. periodt. π
also the sparse variant is only available in kernels 5.19 and later β so check your kernel before you get attached.
registering a file table is a prerequisite for using any request that uses direct descriptors. like, you cannot skip this step, bestie, it's the vibe check for direct descriptors β¨
okay now the fun part β why even bother? registered files have less overhead per operation than normal files. here's the tea: the kernel grabs a reference count on a file when an operation begins, and drops it when it's done. and when the process file table is shared β for example, if the process has ever created any threads β that cost goes up even more. so using registered files reduces the overhead of file reference management across requests that operate on a file. efficiency slay π₯
moving on to updates:
io_uring_register_files_update(3) updates existing registered files. off is the offset on which to start the update, and it updates nr_files number of files defined by the array files belonging to the ring. it's giving "we're editing the roster, not rewriting it" π
and io_uring_register_files_update_tag(3)? behaves the same as io_uring_register_files_update(3) but additionally takes a tags parameter. again β see IORING_REGISTER_BUFFERS2 for the resource tagging description. iykyk π¦
β RETURN VALUE β
- on success,
io_uring_register_files(3),io_uring_register_files_tags(3)andio_uring_register_files_sparse(3)return0. clean, iconic, no drama π io_uring_register_files_update(3)andio_uring_register_files_update_tag(3)return the number of files updated π- on failure, all of them return
-errno. π
π SEE ALSO π
and that's the whole page bestie π«Ά this was liburing-2.1, dated November 15, 2021 β go forth and register those files, you absolute main character ππ
β¨
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2021 Stefan Roesch <shr@fb.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms