1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
.\" Copyright (C) 2021 Stefan Roesch <shr@fb.com>
.\"
.\" SPDX-License-Identifier: LGPL-2.0-or-later
.\"
.TH io_uring_register_files 3 "November 15, 2021" "liburing-2.1" "liburing Manual"
.SH NAME
io_uring_register_files \- register file descriptors
.SH SYNOPSIS
.nf
.B #include <liburing.h>
.PP
.BI "int io_uring_register_files(struct io_uring *" ring ","
.BI " const int *" files ","
.BI " unsigned " nr_files ");"
.PP
.BI "int io_uring_register_files_tags(struct io_uring *" ring ","
.BI " const int *" files ","
.BI " const __u64 *" tags ","
.BI " unsigned " nr ");"
.PP
.BI "int io_uring_register_files_sparse(struct io_uring *" ring ","
.BI " unsigned " nr_files ");"
.PP
.BI "int io_uring_register_files_update(struct io_uring *" ring ","
.BI " unsigned " off ","
.BI " const int *" files ","
.BI " unsigned " nr_files ");"
.PP
.BI "int io_uring_register_files_update_tag(struct io_uring *" ring ","
.BI " unsigned " off ","
.BI " const int *" files ","
.BI " const __u64 *" tags ","
.BI " unsigned " nr_files ");"
.fi
.SH DESCRIPTION
.PP
The
.BR io_uring_register_files (3)
function registers
.I nr_files
number of file descriptors defined by the array
.I files
belonging to the
.I ring
for subsequent operations.
The
.BR io_uring_register_files_tags (3)
function behaves the same as
.BR io_uring_register_files (3)
function but additionally takes
.I tags
parameter. See
.B IORING_REGISTER_BUFFERS2
for the resource tagging description.
The
.BR io_uring_register_files_sparse (3)
function registers an empty file table of
.I nr_files
number of file descriptors. These files must be updated before use, using eg
.BR io_uring_register_files_update_tag (3).
Note that if the size of the sparse table exceeds what
.B RLIMIT_NOFILE
allows, then
.BR io_uring_register_files_sparse (3)
will attempt to raise the limit using
.B setrlimit (2)
and retry the operation. If the registration fails after doing that, then an
error will be returned.
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.
The
.BR io_uring_register_files_update (3)
function updates existing registered files. The
.I off
is offset on which to start the update
.I nr_files
number of files defined by the array
.I files
belonging to the
.IR ring .
The
.BR io_uring_register_files_update_tag (3)
function behaves the same as
.BR io_uring_register_files_update (3)
function but additionally takes
.I tags
parameter. See
.B IORING_REGISTER_BUFFERS2
for the resource tagging description.
.SH RETURN VALUE
On success
.BR io_uring_register_files (3),
.BR io_uring_register_files_tags (3)
and
.BR io_uring_register_files_sparse (3)
return 0.
.BR io_uring_register_files_update (3)
and
.BR io_uring_register_files_update_tag (3)
return number of files updated.
On failure they return
.BR -errno .
.SH SEE ALSO
.BR io_uring_register (2),
.BR io_uring_get_sqe (3),
.BR io_uring_unregister_files (3)
|