summaryrefslogtreecommitdiff
path: root/man/io_uring_enter.2
blob: 6ccbeb48cc3b38cc5edae2dfb9381f0ccf959148 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
.\" Copyright (C) 2019 Jens Axboe <axboe@kernel.dk>
.\" Copyright (C) 2019 Red Hat, Inc.
.\"
.\" SPDX-License-Identifier: LGPL-2.0-or-later
.\"
.TH io_uring_enter 2 2019-01-22 "Linux" "Linux Programmer's Manual"
.SH NAME
io_uring_enter \- initiate and/or complete asynchronous I/O
.SH SYNOPSIS
.nf
.BR "#include <liburing.h>"
.PP
.BI "int io_uring_enter(unsigned int " fd ", unsigned int " to_submit ,
.BI "                   unsigned int " min_complete ", unsigned int " flags ,
.BI "                   sigset_t *" sig );
.PP
.BI "int io_uring_enter2(unsigned int " fd ", unsigned int " to_submit ,
.BI "                    unsigned int " min_complete ", unsigned int " flags ,
.BI "                    sigset_t *" sig ", size_t " sz );
.fi
.PP
.SH DESCRIPTION
.PP
.BR io_uring_enter (2)
is used to initiate and complete I/O using the shared submission and
completion queues setup by a call to
.BR io_uring_setup (2).
A single call can both submit new I/O and wait for completions of I/O
initiated by this call or previous calls to
.BR io_uring_enter (2).

.I fd
is the file descriptor returned by
.BR io_uring_setup (2).
.I to_submit
specifies the number of I/Os to submit from the submission queue.
.I flags
is a bitmask of the following values:
.TP
.B IORING_ENTER_GETEVENTS
If this flag is set, then the system call will wait for the specified
number of events in
.I min_complete
before returning. This flag can be set along with
.I to_submit
to both submit and complete events in a single system call.
If this flag is set either the flag
.B IORING_SETUP_DEFER_TASKRUN
must not be set or the thread issuing the syscall must be the thread that
created the io_uring associated with
.I fd,
or be the thread that enabled the ring originally created with
.B IORING_SETUP_R_DISABLED
via
.BR io_uring_register (2)
or
.BR io_uring_enable_rings (3).
.TP
.B IORING_ENTER_SQ_WAKEUP
If the ring has been created with
.B IORING_SETUP_SQPOLL,
then this flag asks the kernel to wakeup the SQ kernel thread to submit IO.
.TP
.B IORING_ENTER_SQ_WAIT
If the ring has been created with
.B IORING_SETUP_SQPOLL,
then the application has no real insight into when the SQ kernel thread has
consumed entries from the SQ ring. This can lead to a situation where the
application can no longer get a free SQE entry to submit, without knowing
when one will become available as the SQ kernel thread consumes them. If
the system call is used with this flag set, then it will wait until at least
one entry is free in the SQ ring.
.TP
.B IORING_ENTER_EXT_ARG
Since kernel 5.11, the system calls arguments have been modified to look like
the following:

.nf
.BI "int io_uring_enter2(unsigned int " fd ", unsigned int " to_submit ,
.BI "                    unsigned int " min_complete ", unsigned int " flags ,
.BI "                    const void *" arg ", size_t " argsz );
.fi

which behaves just like the original definition by default. However, if
.B IORING_ENTER_EXT_ARG
is set, then instead of a
.I sigset_t
being passed in, a pointer to a
.I struct io_uring_getevents_arg
is used instead and
.I argsz
must be set to the size of this structure. The definition is as follows:

.nf
.BI "struct io_uring_getevents_arg {
.BI "        __u64   sigmask;
.BI "        __u32   sigmask_sz;
.BI "        __u32   pad;
.BI "        __u64   ts;
.BI "};
.fi

which allows passing in both a signal mask as well as pointer to a
.I struct __kernel_timespec
timeout value. If
.I ts
is set to a valid pointer, then this time value indicates the timeout for
waiting on events. If an application is waiting on events and wishes to
stop waiting after a specified amount of time, then this can be accomplished
directly in version 5.11 and newer by using this feature.
.TP
.B IORING_ENTER_REGISTERED_RING
If the ring file descriptor has been registered through use of
.BR IORING_REGISTER_RING_FDS ,
then setting this flag will tell the kernel that the
.I ring_fd
passed in is the registered ring offset rather than a normal file descriptor.

.TP
.B IORING_ENTER_ABS_TIMER

When this flag is set, the timeout argument passed in
.I struct io_uring_getevents_arg
will be interpreted as an absolute
time of the registered clock (see
.BR IORING_REGISTER_CLOCK)
until which the waiting should end.

Available since 6.12

.PP
.PP
If the io_uring instance was configured for polling, by specifying
.B IORING_SETUP_IOPOLL
in the call to
.BR io_uring_setup (2),
then min_complete has a slightly different meaning.  Passing a value
of 0 instructs the kernel to return any events which are already complete,
without blocking.  If
.I min_complete
is a non-zero value, the kernel will still return immediately if any
completion events are available.  If no event completions are
available, then the call will poll either until one or more
completions become available, or until the process has exceeded its
scheduler time slice.

Note that, for interrupt driven I/O (where
.B IORING_SETUP_IOPOLL
was not specified in the call to
.BR io_uring_setup (2)),
an application may check the completion queue for event completions
without entering the kernel at all.
.PP
When the system call returns that a certain amount of SQEs have been
consumed and submitted, it's safe to reuse SQE entries in the ring. This is
true even if the actual IO submission had to be punted to async context,
which means that the SQE may in fact not have been submitted yet. If the
kernel requires later use of a particular SQE entry, it will have made a
private copy of it.

.I sig
is a pointer to a signal mask (see
.BR sigprocmask (2));
if
.I sig
is not NULL,
.BR io_uring_enter (2)
first replaces the current signal mask by the one pointed to by
.IR sig ,
then waits for events to become available in the completion queue, and
then restores the original signal mask.  The following
.BR io_uring_enter (2)
call:
.PP
.in +4n
.EX
ret = io_uring_enter(fd, 0, 1, IORING_ENTER_GETEVENTS, &sig);
.EE
.in
.PP
is equivalent to
.I atomically
executing the following calls:
.PP
.in +4n
.EX
pthread_sigmask(SIG_SETMASK, &sig, &orig);
ret = io_uring_enter(fd, 0, 1, IORING_ENTER_GETEVENTS, NULL);
pthread_sigmask(SIG_SETMASK, &orig, NULL);
.EE
.in
.PP
See the description of
.BR pselect (2)
for an explanation of why the
.I sig
parameter is necessary.

Submission queue entries are represented using the following data
structure:
.PP
.in +4n
.EX
/*
 * IO submission data structure (Submission Queue Entry)
 */
struct io_uring_sqe {
	__u8	opcode;		/* type of operation for this sqe */
	__u8	flags;		/* IOSQE_ flags */
	__u16	ioprio;		/* ioprio for the request */
	__s32	fd;		/* file descriptor to do IO on */
	union {
		__u64	off;	/* offset into file */
		__u64	addr2;
		struct {
			__u32	cmd_op;
			__u32	__pad1;
		};
	};
	union {
		__u64	addr;	/* pointer to buffer or iovecs */
		__u64	splice_off_in;
		struct {
			__u32	level;
			__u32	optname;
		};
	};
	__u32	len;		/* buffer size or number of iovecs */
	union {
		__kernel_rwf_t	rw_flags;
		__u32		fsync_flags;
		__u16		poll_events;	/* compatibility */
		__u32		poll32_events;	/* word-reversed for BE */
		__u32		sync_range_flags;
		__u32		msg_flags;
		__u32		timeout_flags;
		__u32		accept_flags;
		__u32		cancel_flags;
		__u32		open_flags;
		__u32		statx_flags;
		__u32		fadvise_advice;
		__u32		splice_flags;
		__u32		rename_flags;
		__u32		unlink_flags;
		__u32		hardlink_flags;
		__u32		xattr_flags;
		__u32		msg_ring_flags;
		__u32		uring_cmd_flags;
		__u32		waitid_flags;
		__u32		futex_flags;
		__u32		install_fd_flags;
		__u32		nop_flags;
	};
	__u64	user_data;	/* data to be passed back at completion time */
	/* pack this to avoid bogus arm OABI complaints */
	union {
		/* index into fixed buffers, if used */
		__u16	buf_index;
		/* for grouped buffer selection */
		__u16	buf_group;
	} __attribute__((packed));
	/* personality to use, if used */
	__u16	personality;
	union {
		__s32	splice_fd_in;
		__u32	file_index;
		__u32	optlen;
		struct {
			__u16	addr_len;
			__u16	__pad3[1];
		};
	};
	union {
		struct {
			__u64	addr3;
			__u64	__pad2[1];
		};
		__u64	optval;
		/*
		 * If the ring is initialized with IORING_SETUP_SQE128, then
		 * this field is used for 80 bytes of arbitrary command data
		 */
		__u8	cmd[0];
	};
};
.EE
.in
.PP
The
.I opcode
describes the operation to be performed.  It can be one of:
.TP
.B IORING_OP_NOP
Do not perform any I/O.  This is useful for testing the performance of
the io_uring implementation itself.
.TP
.B IORING_OP_READV
.TP
.B IORING_OP_WRITEV
Vectored read and write operations, similar to
.BR preadv2 (2)
and
.BR pwritev2 (2).
If the file is not seekable,
.I off
must be set to zero or -1.

.TP
.B IORING_OP_READ_FIXED
.TP
.B IORING_OP_WRITE_FIXED
Read from or write to pre-mapped buffers.  See
.BR io_uring_register (2)
for details on how to setup a context for fixed reads and writes.

.TP
.B IORING_OP_FSYNC
File sync.  See also
.BR fsync (2).
Optionally
.I off
and
.I len
can be used to specify a range within the file to be synced rather than
syncing the entire file, which is the default behavior.
Note that, while I/O is initiated in the order in which it appears in
the submission queue, completions are unordered.  For example, an
application which places a write I/O followed by an fsync in the
submission queue cannot expect the fsync to apply to the write.  The
two operations execute in parallel, so the fsync may complete before
the write is issued to the storage.  The same is also true for
previously issued writes that have not completed prior to the fsync.
To enforce ordering one may utilize linked SQEs,
.B IOSQE_IO_DRAIN
or wait for the arrival of CQEs of requests which have to be ordered
before a given request before submitting its SQE.

.TP
.B IORING_OP_POLL_ADD
Poll the
.I fd
specified in the submission queue entry for the events
specified in the
.I poll_events
field.  Unlike poll or epoll without
.BR EPOLLONESHOT ,
by default this interface always works in one shot mode.  That is, once the poll
operation is completed, it will have to be resubmitted.

If
.B IORING_POLL_ADD_MULTI
is set in the SQE
.I len
field, then the poll will work in multi shot mode instead. That means it'll
repatedly trigger when the requested event becomes true, and hence multiple
CQEs can be generated from this single SQE. The CQE
.I flags
field will have
.B IORING_CQE_F_MORE
set on completion if the application should expect further CQE entries from
the original request. If this flag isn't set on completion, then the poll
request has been terminated and no further events will be generated. This mode
is available since 5.13.

This command works like
an async
.BR poll(2)
and the completion event result is the returned mask of events.

Without
.B IORING_POLL_ADD_MULTI
and the initial poll operation with
.B IORING_POLL_ADD_MULTI
the operation is level triggered, i.e. if there is data ready or events
pending etc. at the time of submission a corresponding CQE will be posted.
Potential further completions beyond the first caused by a
.B IORING_POLL_ADD_MULTI
are edge triggered.

.TP
.B IORING_OP_POLL_REMOVE
Remove or update an existing poll request.  If found, the
.I res
field of the
.I "struct io_uring_cqe"
will contain 0.  If not found,
.I res
will contain
.B -ENOENT,
or
.B -EALREADY
if the poll request was in the process of completing already.

If
.B IORING_POLL_UPDATE_EVENTS
is set in the SQE
.I len
field, then the request will update an existing poll request with the mask of
events passed in with this request. The lookup is based on the
.I user_data
field of the original SQE submitted, and this values is passed in the
.I addr
field of the SQE.
If
.B IORING_POLL_UPDATE_USER_DATA
is set in the SQE
.I len
field, then the request will update the
.I user_data
of an existing poll request based on the value passed in the
.I off
field. Updating an existing poll is available since 5.13.

.TP
.B IORING_OP_EPOLL_CTL
Add, remove or modify entries in the interest list of
.BR epoll (7).
See
.BR epoll_ctl (2)
for details of the system call.
.I fd
holds the file descriptor that represents the epoll instance,
.I off
holds the file descriptor to add, remove or modify,
.I len
holds the operation (
.BR EPOLL_CTL_ADD ,
.BR EPOLL_CTL_DEL ,
.BR EPOLL_CTL_MOD )
to perform and,
.I addr
holds a pointer to the
.I epoll_event
structure. Available since 5.6.

.TP
.B IORING_OP_SYNC_FILE_RANGE
Issue the equivalent of a \fBsync_file_range\fR (2) on the file descriptor. The
.I fd
field is the file descriptor to sync, the
.I off
field holds the offset in bytes, the
.I len
field holds the length in bytes, and the
.I sync_range_flags
field holds the flags for the command. See also
.BR sync_file_range (2)
for the general description of the related system call. Available since 5.2.

.TP
.B IORING_OP_SENDMSG
Issue the equivalent of a
.BR sendmsg(2)
system call.
.I fd
must be set to the socket file descriptor,
.I addr
must contain a pointer to the msghdr structure, and
.I msg_flags
holds the flags associated with the system call. See also
.BR sendmsg (2)
for the general description of the related system call. Available since 5.3.

This command also supports the following modifiers in
.I ioprio:

.PP
.in +12
.B IORING_RECVSEND_POLL_FIRST
If set, io_uring will assume the socket is currently full and attempting to
send data will be unsuccessful. For this case, io_uring will arm internal
poll and trigger a send of the data when there is enough space available.
This initial send attempt can be wasteful for the case where the socket
is expected to be full, setting this flag will bypass the initial send
attempt and go straight to arming poll. If poll does indicate that data can
be sent, the operation will proceed.
.EE
.in
.PP

.TP
.B IORING_OP_RECVMSG
Works just like IORING_OP_SENDMSG, except for
.BR recvmsg(2)
instead. See the description of IORING_OP_SENDMSG. Available since 5.3.

This command also supports the following modifiers in
.I ioprio:

.PP
.in +12
.B IORING_RECVSEND_POLL_FIRST
If set, io_uring will assume the socket is currently empty and attempting to
receive data will be unsuccessful. For this case, io_uring will arm internal
poll and trigger a receive of the data when the socket has data to be read.
This initial receive attempt can be wasteful for the case where the socket
is expected to be empty, setting this flag will bypass the initial receive
attempt and go straight to arming poll. If poll does indicate that data is
ready to be received, the operation will proceed.
.EE
.in
.PP

.TP
.B IORING_OP_SEND
Issue the equivalent of a
.BR send(2)
system call.
.I fd
must be set to the socket file descriptor,
.I addr
must contain a pointer to the buffer,
.I len
denotes the length of the buffer to send, and
.I msg_flags
holds the flags associated with the system call. See also
.BR send(2)
for the general description of the related system call. Available since 5.6.

This command also supports the following modifiers in
.I ioprio:

.PP
.in +12
.B IORING_RECVSEND_POLL_FIRST
If set, io_uring will assume the socket is currently full and attempting to
send data will be unsuccessful. For this case, io_uring will arm internal
poll and trigger a send of the data when there is enough space available.
This initial send attempt can be wasteful for the case where the socket
is expected to be full, setting this flag will bypass the initial send
attempt and go straight to arming poll. If poll does indicate that data can
be sent, the operation will proceed.
.EE
.in
.PP

.TP
.B IORING_OP_RECV
Works just like IORING_OP_SEND, except for
.BR recv(2)
instead. See the description of IORING_OP_SEND. Available since 5.6.

This command also supports the following modifiers in
.I ioprio:

.PP
.in +12
.B IORING_RECVSEND_POLL_FIRST
If set, io_uring will assume the socket is currently empty and attempting to
receive data will be unsuccessful. For this case, io_uring will arm internal
poll and trigger a receive of the data when the socket has data to be read.
This initial receive attempt can be wasteful for the case where the socket
is expected to be empty, setting this flag will bypass the initial receive
attempt and go straight to arming poll. If poll does indicate that data is
ready to be received, the operation will proceed.
.EE
.in
.PP

.TP
.B IORING_OP_TIMEOUT
This command will register a timeout operation. The
.I addr
field must contain a pointer to a struct __kernel_timespec structure,
.I len
must contain 1 to signify one __kernel_timespec structure,
.I timeout_flags
may contain
.B IORING_TIMEOUT_ABS
for an absolute timeout value, or 0 for a relative timeout.
.I off
may contain a completion event count. A timeout
will trigger a wakeup event on the completion ring for anyone waiting for
events. A timeout condition is met when either the specified timeout expires,
or the specified number of events have completed. Either condition will
trigger the event. If set to 0, completed events are not counted, which
effectively acts like a timer. io_uring timeouts use the
.B CLOCK_MONOTONIC
as the default clock source. The request will complete with
.B -ETIME
if the timeout got completed through expiration of the timer, or
.I 0
if the timeout got completed through requests completing on their own. If
the timeout was canceled before it expired, the request will complete with
.B -ECANCELED.
Available since 5.4.

Since 5.15, this command also supports the following modifiers in
.I timeout_flags:

.PP
.in +12
.B IORING_TIMEOUT_BOOTTIME
If set, then the clocksource used is
.B CLOCK_BOOTTIME
instead of
.BR CLOCK_MONOTONIC .
This clocksource differs in that it includes time elapsed if the system was
suspend while having a timeout request in-flight.

.B IORING_TIMEOUT_REALTIME
If set, then the clocksource used is
.B CLOCK_REALTIME
instead of
.BR CLOCK_MONOTONIC .
.EE
.in
.PP

.PP
.in +7
Since 5.16,
.B IORING_TIMEOUT_ETIME_SUCCESS
can be set in
.IR timeout_flags ,
which will result in the expiration of the timer and subsequent completion
with
.B -ETIME
not being interpreted as an error. This is mostly relevant for linked SQEs, as
subsequent requests in the chain would not get canceled by the timeout, if
this flag is set. See
.B IOSQE_IO_LINK
for more details on linked SQEs.
.in
.PP

.PP
.in +7
Since 6.4,
.B IORING_TIMEOUT_MULTISHOT
can be set in
.IR timeout_flags ,
which will result in the timer producing multiple consecutive completions
like other multi shot operations e.g.
.B IORING_OP_READ_MULTISHOT
or
.BR IORING_POLL_ADD_MULTI .
.I off
must be set to the amount of desired completions.
.B IORING_TIMEOUT_MULTISHOT
must not be used with
.BR IORING_TIMEOUT_ABS .
.in
.PP

.TP
.B IORING_OP_TIMEOUT_REMOVE
If
.I timeout_flags
are zero, then it attempts to remove an existing timeout operation.
.I addr
must contain the
.I user_data
field of the previously issued timeout operation. If the specified timeout
request is found and canceled successfully, this request will terminate
with a result value of
.I 0
If the timeout request was found but expiration was already in progress,
this request will terminate with a result value of
.B -EBUSY
If the timeout request wasn't found, the request will terminate with a result
value of
.B -ENOENT
Available since 5.5.

If
.I timeout_flags
contain
.BR IORING_TIMEOUT_UPDATE ,
instead of removing an existing operation, it updates it.
.I addr
and return values are same as before.
.I addr2
field must contain a pointer to a struct __kernel_timespec structure.
.I timeout_flags
may also contain IORING_TIMEOUT_ABS, in which case the value given is an
absolute one, not a relative one.
Available since 5.11.

.TP
.B IORING_OP_ACCEPT
Issue the equivalent of an
.BR accept4 (2)
system call.
.I fd
must be set to the socket file descriptor,
.I addr
must contain the pointer to the sockaddr structure, and
.I addr2
must contain a pointer to the socklen_t addrlen field. Flags can be passed using
the
.I accept_flags
field. See also
.BR accept4 (2)
for the general description of the related system call. Available since 5.5.

If the
.I file_index
field is set to a positive number, the file won't be installed into the
normal file table as usual but will be placed into the fixed file table at index
.I file_index
- 1.
In this case, instead of returning a file descriptor, the result will contain
either 0 on success or an error. If the index points to a valid empty slot, the
installation is guaranteed to not fail. If there is already a file in the slot,
it will be replaced, similar to
.B IORING_OP_FILES_UPDATE.
Please note that only io_uring has access to such files and no other syscall
can use them. See
.B IOSQE_FIXED_FILE
and
.BR IORING_REGISTER_FILES .

Available since 5.5.

.TP
.B IORING_OP_ASYNC_CANCEL
Attempt to cancel an already issued request.
.I addr
must contain the
.I user_data
field of the request that should be canceled. The cancelation request will
complete with one of the following results codes. If found, the
.I res
field of the cqe will contain 0. If not found,
.I res
will contain
.BR -ENOENT .
If found and attempted canceled, the
.I res
field will contain
.BR -EALREADY .
In this case, the request may or may not
terminate. In general, requests that are interruptible (like socket IO) will
get canceled, while disk IO requests cannot be canceled if already started.
Available since 5.5.

.TP
.B IORING_OP_LINK_TIMEOUT
This request must be linked with another request through
.B IOSQE_IO_LINK
which is described below. Unlike
.BR IORING_OP_TIMEOUT ,
.B IORING_OP_LINK_TIMEOUT
acts on the linked request, not the completion queue. The format of the command
is otherwise like
.BR IORING_OP_TIMEOUT ,
except there's no completion event count as it's tied to a specific request.
If used, the timeout specified in the command will cancel the linked command,
unless the linked command completes before the timeout. The timeout will
complete with
.B -ETIME
if the timer expired and the linked request was attempted canceled, or
.B -ECANCELED
if the timer got canceled because of completion of the linked request. Like
.B IORING_OP_TIMEOUT
the clock source used is
.B CLOCK_MONOTONIC
Available since 5.5.


.TP
.B IORING_OP_CONNECT
Issue the equivalent of a
.BR connect (2)
system call.
.I fd
must be set to the socket file descriptor,
.I addr
must contain the const pointer to the sockaddr structure, and
.I off
must contain the socklen_t addrlen field. See also
.BR connect (2)
for the general description of the related system call. Available since 5.5.

.TP
.B IORING_OP_FALLOCATE
Issue the equivalent of a
.BR fallocate (2)
system call.
.I fd
must be set to the file descriptor,
.I len
must contain the mode associated with the operation,
.I off
must contain the offset on which to operate, and
.I addr
must contain the length. See also
.BR fallocate (2)
for the general description of the related system call. Available since 5.6.

.TP
.B IORING_OP_FADVISE
Issue the equivalent of a
.BR posix_fadvise (2)
system call.
.I fd
must be set to the file descriptor,
.I off
must contain the offset on which to operate,
.I len
must contain the length, and
.I fadvise_advice
must contain the advice associated with the operation. See also
.BR posix_fadvise (2)
for the general description of the related system call. Available since 5.6.

.TP
.B IORING_OP_MADVISE
Issue the equivalent of a
.BR madvise (2)
system call.
.I addr
must contain the address to operate on,
.I len
must contain the length on which to operate,
and
.I fadvise_advice
must contain the advice associated with the operation. See also
.BR madvise (2)
for the general description of the related system call. Available since 5.6.

.TP
.B IORING_OP_OPENAT
Issue the equivalent of a
.BR openat (2)
system call.
.I fd
is the
.I dirfd
argument,
.I addr
must contain a pointer to the
.I *pathname
argument,
.I open_flags
should contain any flags passed in, and
.I len
is access mode of the file. See also
.BR openat (2)
for the general description of the related system call. Available since 5.6.

If the
.I file_index
field is set to a positive number, the file won't be installed into the
normal file table as usual but will be placed into the fixed file table at index
.I file_index - 1.
In this case, instead of returning a file descriptor, the result will contain
either 0 on success or an error. If the index points to a valid empty slot, the
installation is guaranteed to not fail. If there is already a file in the slot,
it will be replaced, similar to
.B IORING_OP_FILES_UPDATE.
Please note that only io_uring has access to such files and no other syscall
can use them. See
.B IOSQE_FIXED_FILE
and
.BR IORING_REGISTER_FILES .

Available since 5.15.

.TP
.B IORING_OP_OPENAT2
Issue the equivalent of a
.BR openat2 (2)
system call.
.I fd
is the
.I dirfd
argument,
.I addr
must contain a pointer to the
.I *pathname
argument,
.I len
should contain the size of the open_how structure, and
.I off
should be set to the address of the open_how structure. See also
.BR openat2 (2)
for the general description of the related system call. Available since 5.6.

If the
.I file_index
field is set to a positive number, the file won't be installed into the
normal file table as usual but will be placed into the fixed file table at index
.I file_index - 1.
In this case, instead of returning a file descriptor, the result will contain
either 0 on success or an error. If the index points to a valid empty slot, the
installation is guaranteed to not fail. If there is already a file in the slot,
it will be replaced, similar to
.BR IORING_OP_FILES_UPDATE .
Please note that only io_uring has access to such files and no other syscall
can use them. See
.B IOSQE_FIXED_FILE
and
.BR IORING_REGISTER_FILES .

Available since 5.15.

.TP
.B IORING_OP_CLOSE
Issue the equivalent of a
.BR close (2)
system call.
.I fd
is the file descriptor to be closed. See also
.BR close (2)
for the general description of the related system call. Available since 5.6.
If the
.I file_index
field is set to a positive number, this command can be used to close files
that were direct opened through
.BR IORING_OP_OPENAT ,
.BR IORING_OP_OPENAT2 ,
or
.B IORING_OP_ACCEPT
using the io_uring specific direct descriptors. Note that only one of the
descriptor fields may be set. The direct close feature is available since
the 5.15 kernel, where direct descriptors were introduced.

.TP
.B IORING_OP_STATX
Issue the equivalent of a
.BR statx (2)
system call.
.I fd
is the
.I dirfd
argument,
.I addr
must contain a pointer to the
.I *pathname
string,
.I statx_flags
is the
.I flags
argument,
.I len
should be the
.I mask
argument, and
.I off
must contain a pointer to the
.I statxbuf
to be filled in. See also
.BR statx (2)
for the general description of the related system call. Available since 5.6.

.TP
.B IORING_OP_READ
.TP
.B IORING_OP_WRITE
Issue the equivalent of a
.BR pread (2)
or
.BR pwrite (2)
system call.
.I fd
is the file descriptor to be operated on,
.I addr
contains the buffer in question,
.I len
contains the length of the IO operation, and
.I offs
contains the read or write offset. If
.I fd
does not refer to a seekable file,
.I off
must be set to zero or -1. If
.I offs
is set to
.B -1
, the offset will use (and advance) the file position, like the
.BR read (2)
and
.BR write (2)
system calls. These are non-vectored versions of the
.B IORING_OP_READV
and
.B IORING_OP_WRITEV
opcodes. See also
.BR read (2)
and
.BR write (2)
for the general description of the related system call. Available since 5.6.

.TP
.B IORING_OP_SPLICE
Issue the equivalent of a
.BR splice (2)
system call.
.I splice_fd_in
is the file descriptor to read from,
.I splice_off_in
is an offset to read from,
.I fd
is the file descriptor to write to,
.I off
is an offset from which to start writing to. A sentinel value of
.B -1
is used to pass the equivalent of a NULL for the offsets to
.BR splice (2).
.I len
contains the number of bytes to copy.
.I splice_flags
contains a bit mask for the flag field associated with the system call.
Please note that one of the file descriptors must refer to a pipe.
See also
.BR splice (2)
for the general description of the related system call. Available since 5.7.

.TP
.B IORING_OP_TEE
Issue the equivalent of a
.BR tee (2)
system call.
.I splice_fd_in
is the file descriptor to read from,
.I fd
is the file descriptor to write to,
.I len
contains the number of bytes to copy, and
.I splice_flags
contains a bit mask for the flag field associated with the system call.
Please note that both of the file descriptors must refer to a pipe.
See also
.BR tee (2)
for the general description of the related system call. Available since 5.8.

.TP
.B IORING_OP_FILES_UPDATE
This command is an alternative to using
.B IORING_REGISTER_FILES_UPDATE
which then works in an async fashion, like the rest of the io_uring commands.
The arguments passed in are the same.
.I addr
must contain a pointer to the array of file descriptors,
.I len
must contain the length of the array, and
.I off
must contain the offset at which to operate. Note that the array of file
descriptors pointed to in
.I addr
must remain valid until this operation has completed. Available since 5.6.

.TP
.B IORING_OP_PROVIDE_BUFFERS
This command allows an application to register a group of buffers to be used
by commands that read/receive data. Using buffers in this manner can eliminate
the need to separate the poll + read, which provides a convenient point in
time to allocate a buffer for a given request. It's often infeasible to have
as many buffers available as pending reads or receive. With this feature, the
application can have its pool of buffers ready in the kernel, and when the
file or socket is ready to read/receive data, a buffer can be selected for the
operation.
.I fd
must contain the number of buffers to provide,
.I addr
must contain the starting address to add buffers from,
.I len
must contain the length of each buffer to add from the range,
.I buf_group
must contain the group ID of this range of buffers, and
.I off
must contain the starting buffer ID of this range of buffers. With that set,
the kernel adds buffers starting with the memory address in
.I addr,
each with a length of
.I len.
Hence the application should provide
.I len * fd
worth of memory in
.I addr.
Buffers are grouped by the group ID, and each buffer within this group will be
identical in size according to the above arguments. This allows the application
to provide different groups of buffers, and this is often used to have
differently sized buffers available depending on what the expectations are of
the individual request. When submitting a request that should use a provided
buffer, the
.B IOSQE_BUFFER_SELECT
flag must be set, and
.I buf_group
must be set to the desired buffer group ID where the buffer should be selected
from. Available since 5.7.

.TP
.B IORING_OP_REMOVE_BUFFERS
Remove buffers previously registered with
.BR IORING_OP_PROVIDE_BUFFERS .
.I fd
must contain the number of buffers to remove, and
.I buf_group
must contain the buffer group ID from which to remove the buffers. Available
since 5.7.

.TP
.B IORING_OP_SHUTDOWN
Issue the equivalent of a
.BR shutdown (2)
system call.
.I fd
is the file descriptor to the socket being shutdown, and
.I len
must be set to the
.I how
argument. No no other fields should be set. Available since 5.11.

.TP
.B IORING_OP_RENAMEAT
Issue the equivalent of a
.BR renameat2 (2)
system call.
.I fd
should be set to the
.IR olddirfd ,
.I addr
should be set to the
.IR oldpath ,
.I len
should be set to the
.IR newdirfd ,
.I addr
should be set to the
.IR oldpath ,
.I addr2
should be set to the
.IR newpath ,
and finally
.I rename_flags
should be set to the
.I flags
passed in to
.BR renameat2 (2).
Available since 5.11.

.TP
.B IORING_OP_UNLINKAT
Issue the equivalent of a
.BR unlinkat (2)
system call.
.I fd
should be set to the
.IR dirfd ,
.I addr
should be set to the
.IR pathname ,
and
.I unlink_flags
should be set to the
.I flags
being passed in to
.BR unlinkat (2).
Available since 5.11.

.TP
.B IORING_OP_MKDIRAT
Issue the equivalent of a
.BR mkdirat (2)
system call.
.I fd
should be set to the
.IR dirfd ,
.I addr
should be set to the
.IR pathname ,
and
.I len
should be set to the
.I mode
being passed in to
.BR mkdirat (2).
Available since 5.15.

.TP
.B IORING_OP_SYMLINKAT
Issue the equivalent of a
.BR symlinkat (2)
system call.
.I fd
should be set to the
.IR newdirfd ,
.I addr
should be set to the
.I target
and
.I addr2
should be set to the
.I linkpath
being passed in to
.BR symlinkat (2).
Available since 5.15.

.TP
.B IORING_OP_LINKAT
Issue the equivalent of a
.BR linkat (2)
system call.
.I fd
should be set to the
.IR olddirfd ,
.I addr
should be set to the
.IR oldpath ,
.I len
should be set to the
.IR newdirfd ,
.I addr2
should be set to the
.IR newpath ,
and
.I hardlink_flags
should be set to the
.I flags
being passed in to
.BR linkat (2).
Available since 5.15.

.TP
.B IORING_OP_MSG_RING
Send a message to an io_uring.
.I fd
must be set to a file descriptor of a ring that the application has access to,
.I len
can be set to any 32-bit value that the application wishes to pass on, and
.I off
should be set any 64-bit value that the application wishes to send. On the
target ring, a CQE will be posted with the
.I res
field matching the
.I len
set, and a
.I user_data
field matching the
.I off
value being passed in. This request type can be used to either just wake or
interrupt anyone waiting for completions on the target ring, or it can be used
to pass messages via the two fields. Available since 5.18.

.TP
.B IORING_OP_SOCKET
Issue the equivalent of a
.BR socket (2)
system call.
.I fd
must contain the communication domain,
.I off
must contain the communication type,
.I len
must contain the protocol, and
.I rw_flags
is currently unused and must be set to zero. See also
.BR socket (2)
for the general description of the related system call. Available since 5.19.

If the
.I file_index
field is set to a positive number, the file won't be installed into the
normal file table as usual but will be placed into the fixed file table at index
.I file_index
- 1.
In this case, instead of returning a file descriptor, the result will contain
either 0 on success or an error. If the index points to a valid empty slot, the
installation is guaranteed to not fail. If there is already a file in the slot,
it will be replaced, similar to
.BR IORING_OP_FILES_UPDATE .
Please note that only io_uring has access to such files and no other syscall
can use them. See
.B IOSQE_FIXED_FILE
and
.BR IORING_REGISTER_FILES .

Available since 5.19.

.TP
.B IORING_OP_URING_CMD
Issues an asynchronous, per-file private operation, similar to
.BR ioctl (2).
Further information may be found in the dedicated man page of
.BR IORING_OP_URING_CMD .

Available since 5.19.

.TP
.B IORING_OP_SEND_ZC
Issue the zerocopy equivalent of a
.BR send(2)
system call. Similar to
.BR IORING_OP_SEND ,
but tries to avoid making intermediate
copies of data. Zerocopy execution is not guaranteed and may fall back to
copying. The request may also fail with
.BR -EOPNOTSUPP ,
when a protocol doesn't support zerocopy, in which case users are recommended
to use copying sends instead.

The
.I flags
field of the first
.I "struct io_uring_cqe"
may likely contain
.BR IORING_CQE_F_MORE ,
which means that there will be a second completion event / notification for
the request, with the
.I user_data
field set to the same value. The user must not modify the data buffer until the
notification is posted. The first cqe follows the usual rules and so its
.I res
field will contain the number of bytes sent or a negative error code. The
notification's
.I res
field will be set to zero and the
.I flags
field will contain
.BR IORING_CQE_F_NOTIF .
The two step model is needed because the kernel may hold on to buffers for a
long time, e.g. waiting for a TCP ACK, and having a separate cqe for request
completions allows userspace to push more data without extra delays. Note,
notifications are only responsible for controlling the lifetime of the buffers,
and as such don't mean anything about whether the data has atually been sent
out or received by the other end. Even errored requests may generate a
notification, and the user must check for
.B IORING_CQE_F_MORE
rather than relying on the result.

.I fd
must be set to the socket file descriptor,
.I addr
must contain a pointer to the buffer,
.I len
denotes the length of the buffer to send, and
.I msg_flags
holds the flags associated with the system call. When
.I addr2
is non-zero it points to the address of the target with
.I addr_len
specifying its size, turning the request into a
.BR sendto (2)
system call equivalent.

Available since 6.0.

This command also supports the following modifiers in
.I ioprio:

.PP
.in +12
.B IORING_RECVSEND_POLL_FIRST
If set, io_uring will assume the socket is currently full and attempting to
send data will be unsuccessful. For this case, io_uring will arm internal
poll and trigger a send of the data when there is enough space available.
This initial send attempt can be wasteful for the case where the socket
is expected to be full, setting this flag will bypass the initial send
attempt and go straight to arming poll. If poll does indicate that data can
be sent, the operation will proceed.

.B IORING_RECVSEND_FIXED_BUF
If set, instructs io_uring to use a pre-mapped buffer. The
.I buf_index
field should contain an index into an array of fixed buffers. See
.BR io_uring_register (2)
for details on how to setup a context for fixed buffer I/O.
.EE
.in
.PP

.TP
.B IORING_OP_SENDMSG_ZC
Issue the zerocopy equivalent of a
.BR sendmsg (2)
system call.
Works just like
.BR IORING_OP_SENDMSG ,
but like
.B IORING_OP_SEND_ZC
supports
.BR IORING_RECVSEND_FIXED_BUF .
For additional notes regarding zero copy see
.BR IORING_OP_SEND_ZC .

Available since 6.1

.TP
.B IORING_OP_WAITID
Issue the equivalent of a
.BR waitid (2)
system call.
.I len
must contain the idtype being queried/waited for and
.I fd
must contain the 'pid' (or id) being waited for.
.I file_index
is the 'options' being set (the child state changes to wait for).
.I addr2
is a pointer to siginfo_t, if any, being filled in. See also
.BR waitid (2)
for the general description of the related system call. Available since 6.5.

.TP
.B IORING_OP_SETXATTR
.TP
.B IORING_OP_GETXATTR
.TP
.B IORING_OP_FSETXATTR
.TP
.B IORING_OP_FGETXATTR
Issue the equivalent of a
.BR setxattr (2)
or
.BR getxattr (2)
or
.BR fsetxattr (2)
or
.BR fgetxattr (2)
system call.
.I addr
must contain a pointer to a buffer containing the name of the extended
attribute.
.I addr2
must contain a pointer to a buffer of maximum length
.IR len ,
in which the value of the extended attribute is to be placed or is read from.
Additional flags maybe provided in
.IR xattr_flags .
For
.BR setxattr (2)
or
.BR getxattr (2)
.I addr3
must contain a pointer to the path of the file.
For
.BR fsetxattr (2)
or
.BR fgetxattr (2)
.I fd
must contain the file descriptor of the file.

Available since 5.19.

.TP
.B IORING_OP_BIND
Issues the equivalent of the
.BR bind (2)
system call.
.I fd
must contain the file descriptor of the socket,
.I addr
must contain a pointer to the sockaddr struct containing the address to assign
and
.I addr2
must contain the length of the address.

Available since 6.11.

.TP
.B IORING_OP_LISTEN
Issues the equivalent of the
.BR listen (2)
system call.
.I fd
must contain the file descriptor of the socket and
.I addr
must contain the backlog parameter, i.e. the maximum amount of pending
queued connections.

Available since 6.11.

.TP
.B IORING_OP_FTRUNCATE
Issues the equivalent of the
.BR ftruncate (2)
system call.
.I fd
must contain the file descriptor of the file to truncate and
.I off
must contain the length to which the file will be truncated.

Available since 6.9.

.TP
.B IORING_OP_READ_MULTISHOT
Like
.BR IORING_OP_READ ,
but similar to requests prepared with
.IR io_uring_prep_multishot_accept (3)
additional reads and thus CQEs will be performed based on this single SQE once
there is more data available.
Is restricted to pollable files and will fall back to single shot if the file
does not support
.BR NOWAIT .
Like other multishot type requests, the application should look at the CQE
flags and see if
.B IORING_CQE_F_MORE
is set on completion as an indication of whether or not the read request will
generate further CQEs. Available since 6.7.

.TP
.B IORING_OP_FUTEX_WAIT
Issues the equivalent of the
.BR futex_wait (2)
system call.
.I addr
must hold a pointer to the futex,
.I addr2
must hold the value to which the futex has to be changed so this caller to
.BR futex_wait (2)
can be woken by a call to
.BR futex_wake (2),
.I addr3
must hold the bitmask of this
.BR futex_wait (2)
caller.
For a caller of
.BR futex_wake (2)
to wake a waiter additionally the bitmask of the waiter and waker must have
at least one set bit in common.
.I fd
must contain additional flags passed in.

Available since 6.7.

.TP
.B IORING_OP_FUTEX_WAKE
Issues the equivalent of the
.BR futex_wake (2)
system call.
.I addr
must hold a pointer to the futex,
.I addr2
must hold the maximum number of waiters waiting on this futex to wake,
.I addr3
must hold the bitmask of this
.BR futex_wake (2)
call.
To wake a waiter additionally the bitmask of the waiter and waker must have
at least one set bit in common.
.I fd
must contain additional flags passed in.

Available since 6.7.

.TP
.B IORING_OP_FUTEX_WAITV
Issues the equivalent of the
.BR futex_waitv (2)
system call.
.I addr
must hold a pointer to the futexv struct,
.I len
must hold the length of the futexv struct, which may not be 0 and must be
smaller than
.B FUTEX_WAITV_MAX
(as of 6.11 == 128).

Available since 6.7.

.TP
.B IORING_OP_FIXED_FD_INSTALL
This operation is used to insert a registered file into the regular process
file table.
Consequently
.I fd
must contain the file index and
.B IOSQE_FIXED_FILE
must be set.
The resulting regular fd is returned via cqe->res.
Additional flags may be passed in via
.IR install_fd_flags .
Currently supported flags are:
.BR IORING_FIXED_FD_NO_CLOEXEC ,
which overrides a potentially set
.B O_CLOEXEC
flag set on the initial file.

Available since 6.8.

.PP
The
.I flags
field is a bit mask. The supported flags are:
.TP
.B IOSQE_FIXED_FILE
When this flag is specified,
.I fd
is an index into the files array registered with the io_uring instance (see the
.B IORING_REGISTER_FILES
section of the
.BR io_uring_register (2)
man page). Note that this isn't always available for all commands. If used on
a command that doesn't support fixed files, the SQE will error with
.BR -EBADF .
Available since 5.1.
.TP
.B IOSQE_IO_DRAIN
When this flag is specified, the SQE will not be started before previously
submitted SQEs have completed, and new SQEs will not be started before this
one completes. Available since 5.2.
.TP
.B IOSQE_IO_LINK
When this flag is specified, the SQE forms a link with the next SQE in the
submission ring. That next SQE will not be started before the previous request
completes. This, in effect, forms a chain of SQEs, which can be arbitrarily
long. The tail of the chain is denoted by the first SQE that does not have this
flag set. Chains are not supported across submission boundaries. Even if the
last SQE in a submission has this flag set, it will still terminate the current
chain. This flag has no effect on previous SQE submissions, nor does it impact
SQEs that are outside of the chain tail. This means that multiple chains can be
executing in parallel, or chains and individual SQEs. Only members inside the
chain are serialized. A chain of SQEs will be broken if any request in that
chain ends in error. io_uring considers any unexpected result an error. This
means that, eg, a short read will also terminate the remainder of the chain.
If a chain of SQE links is broken, the remaining unstarted part of the chain
will be terminated and completed with
.B -ECANCELED
as the error code. Available since 5.3.
.TP
.B IOSQE_IO_HARDLINK
Like IOSQE_IO_LINK, but it doesn't sever regardless of the completion result.
Note that the link will still sever if we fail submitting the parent request,
hard links are only resilient in the presence of completion results for
requests that did submit correctly.
.B IOSQE_IO_HARDLINK
implies
.BR IOSQE_IO_LINK .
Available since 5.5.
.TP
.B IOSQE_ASYNC
Normal operation for io_uring is to try and issue an sqe as non-blocking first,
and if that fails, execute it in an async manner. To support more efficient
overlapped operation of requests that the application knows/assumes will
always (or most of the time) block, the application can ask for an sqe to be
issued async from the start. Available since 5.6.
.TP
.B IOSQE_BUFFER_SELECT
Used in conjunction with the
.B IORING_OP_PROVIDE_BUFFERS
command, which registers a pool of buffers to be used by commands that read
or receive data. When buffers are registered for this use case, and this
flag is set in the command, io_uring will grab a buffer from this pool when
the request is ready to receive or read data. If successful, the resulting CQE
will have
.B IORING_CQE_F_BUFFER
set in the flags part of the struct, and the upper
.B IORING_CQE_BUFFER_SHIFT
bits will contain the ID of the selected buffers. This allows the application
to know exactly which buffer was selected for the operation. If no buffers
are available and this flag is set, then the request will fail with
.B -ENOBUFS
as the error code. Once a buffer has been used, it is no longer available in
the kernel pool. The application must re-register the given buffer again when
it is ready to recycle it (eg has completed using it). Available since 5.7.
.TP
.B IOSQE_CQE_SKIP_SUCCESS
Don't generate a CQE if the request completes successfully. If the request
fails, an appropriate CQE will be posted as usual and if there is no
.B IOSQE_IO_HARDLINK,
CQEs for all linked requests will be omitted. The notion of failure/success is
opcode specific and is the same as with breaking chains of
.BR IOSQE_IO_LINK .
One special case is when the request has a linked timeout, then the CQE
generation for the linked timeout is decided solely by whether it has
.B IOSQE_CQE_SKIP_SUCCESS
set, regardless whether it timed out or was canceled. In other words, if a
linked timeout has the flag set, it's guaranteed to not post a CQE.

The semantics are chosen to accommodate several use cases. First, when all but
the last request of a normal link without linked timeouts are marked with the
flag, only one CQE per link is posted. Additionally, it enables suppression of
CQEs in cases where the side effects of a successfully executed operation is
enough for userspace to know the state of the system. One such example would
be writing to a synchronisation file.

This flag is incompatible with
.BR IOSQE_IO_DRAIN .
Using both of them in a single ring is undefined behavior, even when they are
not used together in a single request. Currently, after the first request with
.BR IOSQE_CQE_SKIP_SUCCESS ,
all subsequent requests marked with drain will be failed at submission time.
Note that the error reporting is best effort only, and restrictions may change
in the future.

Available since 5.17.

.PP
.I ioprio
specifies the I/O priority.  See
.BR ioprio_get (2)
for a description of Linux I/O priorities.

.I fd
specifies the file descriptor against which the operation will be
performed, with the exception noted above.

If the operation is one of
.B IORING_OP_READ_FIXED
or
.BR IORING_OP_WRITE_FIXED ,
.I addr
and
.I len
must fall within the buffer located at
.I buf_index
in the fixed buffer array.  If the operation is either
.B IORING_OP_READV
or
.BR IORING_OP_WRITEV ,
then
.I addr
points to an iovec array of
.I len
entries.

.IR rw_flags ,
specified for read and write operations, contains a bitwise OR of
per-I/O flags, as described in the
.BR preadv2 (2)
man page.

The
.I fsync_flags
bit mask may contain either 0, for a normal file integrity sync, or
.B IORING_FSYNC_DATASYNC
to provide data sync only semantics.  See the descriptions of
.B O_SYNC
and
.B O_DSYNC
in the
.BR open (2)
manual page for more information.

The bits that may be set in
.I poll_events
are defined in \fI<poll.h>\fP, and documented in
.BR poll (2).

.I user_data
is an application-supplied value that will be copied into
the completion queue entry (see below).
.I buf_index
is an index into an array of fixed buffers, and is only valid if fixed
buffers were registered.
.I personality
is the credentials id to use for this operation. See
.BR io_uring_register (2)
for how to register personalities with io_uring. If set to 0, the current
personality of the submitting task is used.
.PP
Once the submission queue entry is initialized, I/O is submitted by
placing the index of the submission queue entry into the tail of the
submission queue.  After one or more indexes are added to the queue,
and the queue tail is advanced, the
.BR io_uring_enter (2)
system call can be invoked to initiate the I/O.

Completions use the following data structure:
.PP
.in +4n
.EX
/*
 * IO completion data structure (Completion Queue Entry)
 */
struct io_uring_cqe {
    __u64    user_data; /* sqe->data submission passed back */
    __s32    res;       /* result code for this event */
    __u32    flags;
};
.EE
.in
.PP
.I user_data
is copied from the field of the same name in the submission queue
entry.  The primary use case is to store data that the application
will need to access upon completion of this particular I/O.  The
.I flags
is used for certain commands, like
.B IORING_OP_POLL_ADD
or in conjunction with
.B IOSQE_BUFFER_SELECT
or
.BR IORING_OP_MSG_RING ,
see those entries for details.
.I res
is the operation-specific result, but io_uring-specific errors
(e.g. flags or opcode invalid) are returned through this field.
They are described in section
.B CQE
.BR ERRORS .
.PP
For read and write opcodes, the
return values match
.I errno
values documented in the
.BR preadv2 (2)
and
.BR pwritev2 (2)
man pages, with
.I
res
holding the equivalent of
.I -errno
for error cases, or the transferred number of bytes in case the operation
is successful. Hence both error and success return can be found in that
field in the CQE. For other request types, the return values are documented
in the matching man page for that type, or in the opcodes section above for
io_uring-specific opcodes.
.PP
.SH RETURN VALUE
.BR io_uring_enter (2)
returns the number of I/Os successfully consumed.  This can be zero
if
.I to_submit
was zero or if the submission queue was empty. Note that if the ring was
created with
.B IORING_SETUP_SQPOLL
specified, then the return value will generally be the same as
.I to_submit
as submission happens outside the context of the system call.

The errors related to a submission queue entry will be returned through a
completion queue entry (see section
.B CQE
.BR ERRORS ),
rather than through the system call itself.

Errors that occur not on behalf of a submission queue entry are returned via the
system call directly. On such an error, a negative error code is returned. The
caller should not rely on
.I errno
variable.
.PP
.SH ERRORS
These are the errors returned by
.BR io_uring_enter (2)
system call.
.TP
.B EAGAIN
The kernel was unable to allocate memory for the request, or otherwise ran out
of resources to handle it. The application should wait for some completions and
try again.
.TP
.B EBADF
.I fd
is not a valid file descriptor.
.TP
.B EBADFD
.I fd
is a valid file descriptor, but the io_uring ring is not in the right state
(enabled). See
.BR io_uring_register (2)
for details on how to enable the ring.
.TP
.B EBADR
At least one CQE was dropped even with the
.B IORING_FEAT_NODROP
feature, and there are no otherwise available CQEs. This clears the error state
and so with no other changes the next call to
.BR io_uring_enter (2)
will not have this error. This error should be extremely rare and indicates the
machine is running critically low on memory. It may be reasonable for the
application to terminate running unless it is able to safely handle any CQE
being lost.
.TP
.B EBUSY
If the
.B IORING_FEAT_NODROP
feature flag is set, then
.B EBUSY
will be returned if there were overflow entries,
.B IORING_ENTER_GETEVENTS
flag is set and not all of the overflow entries were able to be flushed to
the CQ ring.

Without
.B IORING_FEAT_NODROP
the application is attempting to overcommit the number of requests it can have
pending. The application should wait for some completions and try again. May
occur if the application tries to queue more requests than we have room for in
the CQ ring, or if the application attempts to wait for more events without
having reaped the ones already present in the CQ ring.
.TP
.B EEXIST
The thread submitting the work is invalid. This may occur if
.B IORING_ENTER_GETEVENTS
and
.B IORING_SETUP_DEFER_TASKRUN
is set, but the submitting thread is not the thread that initially created or
enabled the io_uring associated with
.I fd.
.TP
.B EINVAL
Some bits in the
.I flags
argument are invalid.
.TP
.B EFAULT
An invalid user space address was specified for the
.I sig
argument.
.TP
.B ENXIO
The io_uring instance is in the process of being torn down.
.TP
.B EOPNOTSUPP
.I fd
does not refer to an io_uring instance.
.TP
.B EINTR
The operation was interrupted by a delivery of a signal before it could
complete; see
.BR signal (7).
Can happen while waiting for events with
.B IORING_ENTER_GETEVENTS.
.TP
.B EOWNERDEAD
The ring has been setup with
.B IORING_SETUP_SQPOLL
and the sq poll kernel thread has been killed.

.SH CQE ERRORS
These io_uring-specific errors are returned as a negative value in the
.I res
field of the completion queue entry.
.TP
.B EACCES
The
.I flags
field or
.I opcode
in a submission queue entry is not allowed due to registered restrictions.
See
.BR io_uring_register (2)
for details on how restrictions work.
.TP
.B EBADF
The
.I fd
field in the submission queue entry is invalid, or the
.B IOSQE_FIXED_FILE
flag was set in the submission queue entry, but no files were registered
with the io_uring instance.
.TP
.B EFAULT
buffer is outside of the process' accessible address space
.TP
.B EFAULT
.B IORING_OP_READ_FIXED
or
.B IORING_OP_WRITE_FIXED
was specified in the
.I opcode
field of the submission queue entry, but either buffers were not
registered for this io_uring instance, or the address range described
by
.I addr
and
.I len
does not fit within the buffer registered at
.IR buf_index .
.TP
.B EINVAL
The
.I flags
field or
.I opcode
in a submission queue entry is invalid.
.TP
.B EINVAL
The
.I buf_index
member of the submission queue entry is invalid.
.TP
.B EINVAL
The
.I personality
field in a submission queue entry is invalid.
.TP
.B EINVAL
.B IORING_OP_NOP
was specified in the submission queue entry, but the io_uring context
was setup for polling
.RB ( IORING_SETUP_IOPOLL
was specified in the call to io_uring_setup).
.TP
.B EINVAL
.B IORING_OP_READV
or
.B IORING_OP_WRITEV
was specified in the submission queue entry, but the io_uring instance
has fixed buffers registered.
.TP
.B EINVAL
.B IORING_OP_READ_FIXED
or
.B IORING_OP_WRITE_FIXED
was specified in the submission queue entry, and the
.I buf_index
is invalid.
.TP
.B EINVAL
.BR IORING_OP_READV ,
.BR IORING_OP_WRITEV ,
.BR IORING_OP_READ_FIXED ,
.B IORING_OP_WRITE_FIXED
or
.B IORING_OP_FSYNC
was specified in the submission queue entry, but the io_uring instance
was configured for IOPOLLing, or any of
.IR addr ,
.IR ioprio ,
.IR off ,
.IR len ,
or
.I buf_index
was set in the submission queue entry.
.TP
.B EINVAL
.B IORING_OP_POLL_ADD
or
.B IORING_OP_POLL_REMOVE
was specified in the
.I opcode
field of the submission queue entry, but the io_uring instance was
configured for busy-wait polling
.RB ( IORING_SETUP_IOPOLL ),
or any of
.IR ioprio ,
.IR off ,
.IR len ,
or
.I buf_index
was non-zero in the submission queue entry.
.TP
.B EINVAL
.B IORING_OP_POLL_ADD
was specified in the
.I opcode
field of the submission queue entry, and the
.I addr
field was non-zero.
.TP
.B EOPNOTSUPP
.I opcode
is valid, but not supported by this kernel.
.TP
.B EOPNOTSUPP
.B IOSQE_BUFFER_SELECT
was set in the
.I flags
field of the submission queue entry, but the
.I opcode
doesn't support buffer selection.
.TP
.B EINVAL
.B IORING_OP_TIMEOUT
was specified, but
.I timeout_flags
specified more than one clock source or
.B IORING_TIMEOUT_MULTISHOT
was set alongside
.BR IORING_TIMEOUT_ABS .