1IO_SUBMIT(2)               Linux Programmer's Manual              IO_SUBMIT(2)
2
3
4

NAME

6       io_submit - submit asynchronous I/O blocks for processing
7

SYNOPSIS

9       #include <linux/aio_abi.h>          /* Defines needed types */
10
11       int io_submit(aio_context_t ctx_id, long nr, struct iocb **iocbpp);
12
13       Note: There is no glibc wrapper for this system call; see NOTES.
14

DESCRIPTION

16       The io_submit() system call queues nr I/O request blocks for processing
17       in the AIO context ctx_id.  The iocbpp argument should be an  array  of
18       nr AIO control blocks, which will be submitted to context ctx_id.
19
20       The  iocb  (I/O  control  block)  structure  defined in linux/aio_abi.h
21       defines the parameters that control the I/O operation.
22
23           #include <linux/aio_abi.h>
24
25           struct iocb {
26               __u64   aio_data;
27               __u32   PADDED(aio_key, aio_rw_flags);
28               __u16   aio_lio_opcode;
29               __s16   aio_reqprio;
30               __u32   aio_fildes;
31               __u64   aio_buf;
32               __u64   aio_nbytes;
33               __s64   aio_offset;
34               __u64   aio_reserved2;
35               __u32   aio_flags;
36               __u32   aio_resfd;
37           };
38
39       The fields of this structure are as follows:
40
41       aio_data
42              This is an internal field used by the  kernel.   Do  not  modify
43              this field after an io_submit(2) call.
44
45       aio_key
46              This  is  an  internal  field used by the kernel.  Do not modify
47              this field after an io_submit(2) call.
48
49       aio_rw_flags
50              This defines the R/W flags passed  with  structure.   The  valid
51              values are:
52
53              RWF_APPEND (since Linux 4.16)
54                     Append  data to the end of the file.  See the description
55                     of the flag of the same name in pwritev2(2)  as  well  as
56                     the  description  of O_APPEND in open(2).  The aio_offset
57                     field is ignored.  The file offset is not changed.
58
59              RWF_DSYNC (since Linux 4.7)
60                     Write operation complete according to requirement of syn‐
61                     chronized I/O data integrity.  See the description of the
62                     flag of the same name in pwritev2(2) as well the descrip‐
63                     tion of O_DSYNC in open(2).
64
65              RWF_HIPRI (since Linux 4.6)
66                     High priority request, poll if possible
67
68              RWF_NOWAIT (since Linux 4.14)
69                     Don't  wait  if the I/O will block for operations such as
70                     file block allocations, dirty page flush, mutex locks, or
71                     a  congested  block  device inside the kernel.  If any of
72                     these conditions are met, the control block  is  returned
73                     immediately  with  a  return  value of -EAGAIN in the res
74                     field of the io_event structure (see io_getevents(2)).
75
76              RWF_SYNC (since Linux 4.7)
77                     Write operation complete according to requirement of syn‐
78                     chronized I/O file integrity.  See the description of the
79                     flag of the same name in pwritev2(2) as well the descrip‐
80                     tion of O_SYNC in open(2).
81
82       aio_lio_opcode
83              This  defines the type of I/O to be performed by the iocb struc‐
84              ture.  The valid values are  defined  by  the  enum  defined  in
85              linux/aio_abi.h:
86
87                  enum {
88                      IOCB_CMD_PREAD = 0,
89                      IOCB_CMD_PWRITE = 1,
90                      IOCB_CMD_FSYNC = 2,
91                      IOCB_CMD_FDSYNC = 3,
92                      IOCB_CMD_NOOP = 6,
93                      IOCB_CMD_PREADV = 7,
94                      IOCB_CMD_PWRITEV = 8,
95                  };
96
97       aio_reqprio
98              This defines the requests priority.
99
100       aio_filedes
101              The  file  descriptor  on  which the I/O operation is to be per‐
102              formed.
103
104       aio_buf
105              This is the buffer used to transfer data for  a  read  or  write
106              operation.
107
108       aio_nbytes
109              This is the size of the buffer pointed to by aio_buf.
110
111       aio_offset
112              This is the file offset at which the I/O operation is to be per‐
113              formed.
114
115       aio_flags
116              This is the flag to be passed iocb structure.   The  only  valid
117              value  is IOCB_FLAG_RESFD, which indicates that the asynchronous
118              I/O  control  must  signal  the  file  descriptor  mentioned  in
119              aio_resfd upon completion.
120
121       aio_resfd
122              The  file  descriptor to signal in the event of asynchronous I/O
123              completion.
124

RETURN VALUE

126       On success, io_submit() returns the number of  iocbs  submitted  (which
127       may  be less than nr, or 0 if nr is zero).  For the failure return, see
128       NOTES.
129

ERRORS

131       EAGAIN Insufficient resources are available to queue any iocbs.
132
133       EBADF  The file descriptor specified in the first iocb is invalid.
134
135       EFAULT One of the data structures points to invalid data.
136
137       EINVAL The AIO context specified by ctx_id is invalid.  nr is less than
138              0.   The  iocb at *iocbpp[0] is not properly initialized, or the
139              operation specified is invalid for the file  descriptor  in  the
140              iocb.
141
142       ENOSYS io_submit() is not implemented on this architecture.
143

VERSIONS

145       The asynchronous I/O system calls first appeared in Linux 2.5.
146

CONFORMING TO

148       io_submit()  is  Linux-specific and should not be used in programs that
149       are intended to be portable.
150

NOTES

152       Glibc does not provide a wrapper function for this  system  call.   You
153       could  invoke  it  using syscall(2).  But instead, you probably want to
154       use the io_submit() wrapper function provided by libaio.
155
156       Note that the libaio wrapper function uses a  different  type  (io_con‐
157       text_t)  for  the  ctx_id  argument.  Note also that the libaio wrapper
158       does not follow the usual C library conventions for indicating  errors:
159       on  error it returns a negated error number (the negative of one of the
160       values  listed  in  ERRORS).   If  the  system  call  is  invoked   via
161       syscall(2),  then  the  return  value follows the usual conventions for
162       indicating an error: -1, with errno set  to  a  (positive)  value  that
163       indicates the error.
164

SEE ALSO

166       io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), aio(7)
167

COLOPHON

169       This  page  is  part of release 4.16 of the Linux man-pages project.  A
170       description of the project, information about reporting bugs,  and  the
171       latest     version     of     this    page,    can    be    found    at
172       https://www.kernel.org/doc/man-pages/.
173
174
175
176Linux                             2018-04-30                      IO_SUBMIT(2)
Impressum