16 #if STXXL_HAVE_LINUXAIO_FILE
23 #include <sys/syscall.h>
27 void linuxaio_request::completed(
bool posted,
bool canceled)
30 posted <<
"," << canceled <<
")");
35 stats::get_instance()->read_finished();
37 stats::get_instance()->write_finished();
42 stats::get_instance()->read_canceled(m_bytes);
44 stats::get_instance()->write_canceled(m_bytes);
46 request_with_state::completed(canceled);
49 void linuxaio_request::fill_control_block()
53 memset(&cb, 0,
sizeof(cb));
55 cb.aio_data =
reinterpret_cast<__u64
>(
new request_ptr(
this));
57 cb.aio_lio_opcode = (m_type == READ) ? IOCB_CMD_PREAD : IOCB_CMD_PWRITE;
59 cb.aio_buf =
static_cast<__u64
>((
unsigned long)(m_buffer));
60 cb.aio_nbytes = m_bytes;
61 cb.aio_offset = m_offset;
66 bool linuxaio_request::post()
71 iocb* cb_pointer = &cb;
76 disk_queues::get_instance()->get_queue(m_file->get_queue_id())
78 long success = syscall(SYS_io_submit, queue->
get_io_context(), 1, &cb_pointer);
82 stats::get_instance()->read_started(m_bytes, now);
84 stats::get_instance()->write_started(m_bytes, now);
86 else if (success == -1 && errno != EAGAIN)
96 bool linuxaio_request::cancel()
100 if (!m_file)
return false;
104 disk_queues::get_instance()->get_queue(m_file->get_queue_id())
110 bool linuxaio_request::cancel_aio()
114 if (!m_file)
return false;
118 disk_queues::get_instance()->get_queue(m_file->get_queue_id())
120 long result = syscall(SYS_io_cancel, queue->
get_io_context(), &cb, &event);
128 #endif // #if STXXL_HAVE_LINUXAIO_FILE
bool cancel_request(request_ptr &req)
External FIFO queue container. Introduction to queue container: see STXXL Queue tutorial Design a...
Implementation of file based on the Linux kernel interface for asynchronous I/O.
counting_ptr< request > request_ptr
A reference counting pointer for request.
#define STXXL_VERBOSE_LINUXAIO(msg)
void handle_events(io_event *events, long num_events, bool canceled)
#define STXXL_BEGIN_NAMESPACE
aio_context_t get_io_context()
#define STXXL_THROW_ERRNO(exception_type, error_message)
Throws exception_type with "Error in [function] : [error_message] : [errno message]".
double timestamp()
Returns number of seconds since the epoch, high resolution.
Queue for linuxaio_file(s)
#define STXXL_END_NAMESPACE