Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / journal / Utils.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_LIBRBD_JOURNAL_UTILS_H
5 #define CEPH_LIBRBD_JOURNAL_UTILS_H
6
7 #include "include/int_types.h"
8 #include "include/Context.h"
9 #include "cls/journal/cls_journal_types.h"
10 #include <list>
11
12 struct CephContext;
13 struct Mutex;
14
15 namespace librbd {
16 namespace journal {
17
18 struct TagData;
19
20 namespace util {
21
22 struct C_DecodeTag : public Context {
23   CephContext *cct;
24   Mutex *lock;
25   uint64_t *tag_tid;
26   TagData *tag_data;
27   Context *on_finish;
28
29   cls::journal::Tag tag;
30
31   C_DecodeTag(CephContext *cct, Mutex *lock, uint64_t *tag_tid,
32               TagData *tag_data, Context *on_finish)
33     : cct(cct), lock(lock), tag_tid(tag_tid), tag_data(tag_data),
34       on_finish(on_finish) {
35   }
36
37   void complete(int r) override {
38     on_finish->complete(process(r));
39     Context::complete(0);
40   }
41   void finish(int r) override {
42   }
43
44   int process(int r);
45
46   static int decode(bufferlist::iterator *it, TagData *tag_data);
47
48 };
49
50 struct C_DecodeTags : public Context {
51   typedef std::list<cls::journal::Tag> Tags;
52
53   CephContext *cct;
54   Mutex *lock;
55   uint64_t *tag_tid;
56   TagData *tag_data;
57   Context *on_finish;
58
59   Tags tags;
60
61   C_DecodeTags(CephContext *cct, Mutex *lock, uint64_t *tag_tid,
62                TagData *tag_data, Context *on_finish)
63     : cct(cct), lock(lock), tag_tid(tag_tid), tag_data(tag_data),
64       on_finish(on_finish) {
65   }
66
67   void complete(int r) override {
68     on_finish->complete(process(r));
69     Context::complete(0);
70   }
71   void finish(int r) override {
72   }
73
74   int process(int r);
75 };
76
77 } // namespace util
78 } // namespace journal
79 } // namespace librbd
80
81 #endif // CEPH_LIBRBD_JOURNAL_UTILS_H