]>
git.proxmox.com Git - ceph.git/blob - ceph/src/os/fs/aio.h
c4757158cc90aa076699a09fe2db627d0133eae5
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
10 #include <boost/intrusive/list.hpp>
11 #include <boost/container/small_vector.hpp>
13 #include "include/buffer.h"
16 struct iocb iocb
; // must be first element; see shenanigans in aio_queue_t
19 boost::container::small_vector
<iovec
,4> iov
;
20 uint64_t offset
, length
;
22 bufferlist bl
; ///< write payload (so that it remains stable for duration)
24 boost::intrusive::list_member_hook
<> queue_item
;
26 aio_t(void *p
, int f
) : priv(p
), fd(f
), offset(0), length(0), rval(-1000) {
29 void pwritev(uint64_t _offset
, uint64_t len
) {
32 io_prep_pwritev(&iocb
, fd
, &iov
[0], iov
.size(), offset
);
34 void pread(uint64_t _offset
, uint64_t len
) {
37 bufferptr p
= buffer::create_page_aligned(length
);
38 io_prep_pread(&iocb
, fd
, p
.c_str(), length
, offset
);
39 bl
.append(std::move(p
));
42 int get_return_value() {
47 typedef boost::intrusive::list
<
49 boost::intrusive::member_hook
<
51 boost::intrusive::list_member_hook
<>,
52 &aio_t::queue_item
> > aio_list_t
;
58 explicit aio_queue_t(unsigned max_iodepth
)
59 : max_iodepth(max_iodepth
),
68 int r
= io_setup(max_iodepth
, &ctx
);
79 int r
= io_destroy(ctx
);
85 int submit(aio_t
&aio
, int *retries
);
86 int get_next_completed(int timeout_ms
, aio_t
**paio
, int max
);