io_submit(2)

NAME
io_submit - submit io requests

SYNOPSIS
#include <errno.h>
#include <libaio.h>

int io_submit(io_context_t ctx, long nr, struct iocb *iocbs[]);

DESCRIPTION
io_submit submits to the io_context ctx up to nr I/O requests pointed to by the vector iocbs. The iocb structure is defined as something like

    struct iocb {
        void    *data;
        short    aio_lio_opcode;
        short    aio_reqprio;
        int      aio_fildes;
    };

data is a an opaque pointer which will upon completion be returned in the io_event structure by io_getevents(2). Callers will typically use this to point directly or indirectly to a callback function.

aio_lio_opcode is the I/O operation requested. Callers will typically set this and the arguments to the I/O operation calling the io_prep_(3) function corresponding to the operation.

aio_reqprio is the priority of the request. Higher values have more priority; the normal priority is 0.

aio_fildes is the file descriptor for the I/O operation. Callers will typically set this and the arguments to the I/O operation calling the io_prep_*(3) function corresponding to the operation.

The caller may not modify the contents or resubmit a submitted iocb structure until after the operation completes or is canceled. The implementation of io_submit(2) is permitted to modify reserved fields of the iocb structure.

RETURN VALUES
If able to submit at least one iocb, io_submit returns the number of iocbs submitted successfully. Otherwise, -error is returned, where error is one of the Exxx values defined in the Errors section.

ERRORS

EFAULT
    iocbs referenced data outside of the program's accessible address space.

EINVAL
    nr is negative, ctx refers to an uninitialized aio context, the iocb pointed to by iocbs[0] is improperly initialized or specifies an unsupported operation.

EBADF
    The iocb pointed to by iocbs[0] contains a file descriptor that does not exist.

EAGAIN
    Insufficient resources were available to queue any operations.

SEE ALSO
io_setup(2), io_destroy(2), io_getevents(2), io_prep_pread(3), io_prep_pwrite(3), io_prep_fsync(3), io_prep_fdsync(3), io_prep_noop(3), io_cancel(2), errno(3)