16 #if FOXXLL_HAVE_LINUXAIO_FILE 18 #include <sys/syscall.h> 26 void linuxaio_request::completed(
bool posted,
bool canceled)
28 TLX_LOG <<
"linuxaio_request[" <<
this <<
"] completed(" <<
29 posted <<
"," << canceled <<
")";
31 auto* stats = file_->get_file_stats();
32 const double duration =
timestamp() - time_posted_;
37 stats->read_op_finished(bytes_, duration);
40 stats->write_op_finished(bytes_, duration);
46 stats->read_canceled(bytes_);
48 stats->write_canceled(bytes_);
54 iocb* linuxaio_request::fill_control_block()
56 linuxaio_file* af =
dynamic_cast<linuxaio_file*
>(file_);
59 ReferenceCounter::inc_reference();
61 memset(&cb_, 0,
sizeof(cb_));
62 cb_.aio_data =
reinterpret_cast<__u64
>(
this);
63 cb_.aio_fildes = af->file_des_;
64 cb_.aio_lio_opcode = (op_ == READ) ? IOCB_CMD_PREAD : IOCB_CMD_PWRITE;
66 cb_.aio_buf =
static_cast<__u64
>(
reinterpret_cast<unsigned long>(buffer_));
67 cb_.aio_nbytes = bytes_;
68 cb_.aio_offset = offset_;
80 bool linuxaio_request::cancel()
82 TLX_LOG <<
"linuxaio_request[" <<
this <<
"] cancel()";
84 if (!file_)
return false;
87 linuxaio_queue* queue =
dynamic_cast<linuxaio_queue*
>(
89 return queue->cancel_request(req);
93 bool linuxaio_request::cancel_aio(linuxaio_queue* queue)
95 TLX_LOG <<
"linuxaio_request[" <<
this <<
"] cancel_aio()";
97 if (!file_)
return false;
100 long result = syscall(SYS_io_cancel, queue->get_io_context(), &cb_, &event);
103 queue->handle_events(&event, 1,
true);
110 #endif // #if FOXXLL_HAVE_LINUXAIO_FILE
tlx::counting_ptr< request > request_ptr
A reference counting pointer for request.
static double timestamp()
Returns number of seconds since the epoch, high resolution.
void completed(bool canceled) override
static instance_pointer get_instance()
return instance or create base instance if empty
request_queue * get_queue(disk_id_type disk)
#define TLX_LOG
Default logging method: output if the local debug variable is true.