XRootD
Loading...
Searching...
No Matches
XrdCephBulkAioRead.hh
Go to the documentation of this file.
1#include <string>
2#include <map>
3#include <list>
4#include <tuple>
5#include <rados/librados.hpp>
6
7#include "XrdCephPosix.hh"
8
9
11 //typedef std::tuple<ceph::bufferlist*, char*, int*> ReadOpData;
12 typedef void (*logfunc_pointer) (char *, ...);
13
27 public:
28 bulkAioRead(librados::IoCtx* ct, logfunc_pointer ptr, CephFileRef* fileref);
30
31 void clear();
33 ssize_t get_results();
34 int read(void *out_buf, size_t size, off64_t offset);
35
36 private:
37 //Completion pointer
38 class CmplPtr {
39 librados::AioCompletion *ptr;
40 bool used = false;
41 public:
42 CmplPtr() {
43 ptr = librados::Rados::aio_create_completion();
44 if (NULL == ptr) {
45 throw std::bad_alloc();
46 }
47 }
48 ~CmplPtr() {
49 if (used) {
50 this->wait_for_complete();
51 }
52 ptr->release();
53 }
54 void wait_for_complete() {
55 ptr->wait_for_complete();
56 }
57 int get_return_value() {
58 return ptr->get_return_value();
59 }
60 librados::AioCompletion* use() {
61 //If the object was converted to AioCompletion, we suppose it was passed to
62 //the read operation, and therefore set the flag.
63 used = true;
64 return ptr;
65 }
66 };
67
68 //Ceph read operation + completion
69 struct CephOpData {
70 librados::ObjectReadOperation ceph_read_op;
71 CmplPtr cmpl;
72 };
73
74 //Data for an individual read -- ceph's buffer, client's buffer and return code
75 struct ReadOpData {
76 ceph::bufferlist bl;
77 char* out_buf;
78 int rc;
79 ReadOpData(char* output_buf): out_buf(output_buf), rc(-1) {};
80 };
81
82
83
84 int addRequest(size_t obj_idx, char *out_buf, size_t size, off64_t offset);
85 librados::IoCtx* context;
86 std::list<ReadOpData> buffers;
87
88 //map { <object_number> : <CephOpData> }
89 std::map<size_t, CephOpData> operations;
90
91 logfunc_pointer log_func;
92 CephFileRef* file_ref;
93};
#define read(a, b, c)
Definition XrdPosix.hh:82
bulkAioRead(librados::IoCtx *ct, logfunc_pointer ptr, CephFileRef *fileref)
int submit_and_wait_for_complete()