]>
git.proxmox.com Git - ceph.git/blob - ceph/src/os/fs/aio.h
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"
14 #include "include/types.h"
17 struct iocb iocb
; // must be first element; see shenanigans in aio_queue_t
20 boost::container::small_vector
<iovec
,4> iov
;
21 uint64_t offset
, length
;
23 bufferlist bl
; ///< write payload (so that it remains stable for duration)
25 boost::intrusive::list_member_hook
<> queue_item
;
27 aio_t(void *p
, int f
) : priv(p
), fd(f
), offset(0), length(0), rval(-1000) {
30 void pwritev(uint64_t _offset
, uint64_t len
) {
33 io_prep_pwritev(&iocb
, fd
, &iov
[0], iov
.size(), offset
);
35 void pread(uint64_t _offset
, uint64_t len
) {
38 bufferptr p
= buffer::create_page_aligned(length
);
39 io_prep_pread(&iocb
, fd
, p
.c_str(), length
, offset
);
40 bl
.append(std::move(p
));
43 int get_return_value() {
48 typedef boost::intrusive::list
<
50 boost::intrusive::member_hook
<
52 boost::intrusive::list_member_hook
<>,
53 &aio_t::queue_item
> > aio_list_t
;
59 typedef list
<aio_t
>::iterator aio_iter
;
61 explicit aio_queue_t(unsigned max_iodepth
)
62 : max_iodepth(max_iodepth
),
71 int r
= io_setup(max_iodepth
, &ctx
);
82 int r
= io_destroy(ctx
);
88 int submit(aio_t
&aio
, int *retries
);
89 int submit_batch(aio_iter begin
, aio_iter end
, uint16_t aios_size
,
90 void *priv
, int *retries
);
91 int get_next_completed(int timeout_ms
, aio_t
**paio
, int max
);