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_HIPRI
54                     High priority request, poll if possible
55
56              RWF_DSYNC
57                     Write operation complete according to requirement of syn‐
58                     chronized I/O data integrity.  See the description of the
59                     flag of the same name in pwritev2(2) as well the descrip‐
60                     tion of O_DSYNC in open(2).
61
62              RWF_SYNC
63                     Write operation complete according to requirement of syn‐
64                     chronized I/O file integrity.  See the description of the
65                     flag of the same name in pwritev2(2) as well the descrip‐
66                     tion of O_SYNC in open(2).
67
68              RWF_NOWAIT
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       aio_lio_opcode
77              This defines the type of I/O to be performed by the iocb  struc‐
78              ture.   The  valid  values  are  defined  by the enum defined in
79              linux/aio_abi.h:
80
81                  enum {
82                      IOCB_CMD_PREAD = 0,
83                      IOCB_CMD_PWRITE = 1,
84                      IOCB_CMD_FSYNC = 2,
85                      IOCB_CMD_FDSYNC = 3,
86                      IOCB_CMD_NOOP = 6,
87                      IOCB_CMD_PREADV = 7,
88                      IOCB_CMD_PWRITEV = 8,
89                  };
90
91       aio_reqprio
92              This defines the requests priority.
93
94       aio_filedes
95              The file descriptor on which the I/O operation  is  to  be  per‐
96              formed.
97
98       aio_buf
99              This  is  the  buffer  used to transfer data for a read or write
100              operation.
101
102       aio_nbytes
103              This is the size of the buffer pointed to by aio_buf.
104
105       aio_offset
106              This is the file offset at which the I/O operation is to be per‐
107              formed.
108
109       aio_flags
110              This  is  the  flag to be passed iocb structure.  The only valid
111              value is IOCB_FLAG_RESFD, which indicates that the  asynchronous
112              I/O  control  must  signal  the  file  descriptor  mentioned  in
113              aio_resfd upon completion.
114
115       aio_resfd
116              The file descriptor to signal in the event of  asynchronous  I/O
117              completion.
118

RETURN VALUE

120       On  success,  io_submit()  returns the number of iocbs submitted (which
121       may be less than nr, or 0 if nr is zero).  For the failure return,  see
122       NOTES.
123

ERRORS

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

VERSIONS

139       The asynchronous I/O system calls first appeared in Linux 2.5.
140

CONFORMING TO

142       io_submit() is Linux-specific and should not be used in  programs  that
143       are intended to be portable.
144

NOTES

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

SEE ALSO

160       io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), aio(7)
161

COLOPHON

163       This page is part of release 4.15 of the Linux  man-pages  project.   A
164       description  of  the project, information about reporting bugs, and the
165       latest    version    of    this    page,    can     be     found     at
166       https://www.kernel.org/doc/man-pages/.
167
168
169
170Linux                             2017-09-15                      IO_SUBMIT(2)
Impressum