]> git.proxmox.com Git - ceph.git/blob - ceph/src/cls/lock/cls_lock_ops.h
dbdddfe21407d5182673e4599c689f630fc76dec
[ceph.git] / ceph / src / cls / lock / cls_lock_ops.h
1 #ifndef CEPH_CLS_LOCK_OPS_H
2 #define CEPH_CLS_LOCK_OPS_H
3
4 #include "include/types.h"
5 #include "include/utime.h"
6 #include "cls/lock/cls_lock_types.h"
7
8 struct cls_lock_lock_op
9 {
10 string name;
11 ClsLockType type;
12 string cookie;
13 string tag;
14 string description;
15 utime_t duration;
16 uint8_t flags;
17
18 cls_lock_lock_op() : type(LOCK_NONE), flags(0) {}
19
20 void encode(bufferlist &bl) const {
21 ENCODE_START(1, 1, bl);
22 ::encode(name, bl);
23 uint8_t t = (uint8_t)type;
24 ::encode(t, bl);
25 ::encode(cookie, bl);
26 ::encode(tag, bl);
27 ::encode(description, bl);
28 ::encode(duration, bl);
29 ::encode(flags, bl);
30 ENCODE_FINISH(bl);
31 }
32 void decode(bufferlist::iterator &bl) {
33 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
34 ::decode(name, bl);
35 uint8_t t;
36 ::decode(t, bl);
37 type = (ClsLockType)t;
38 ::decode(cookie, bl);
39 ::decode(tag, bl);
40 ::decode(description, bl);
41 ::decode(duration, bl);
42 ::decode(flags, bl);
43 DECODE_FINISH(bl);
44 }
45 void dump(Formatter *f) const;
46 static void generate_test_instances(list<cls_lock_lock_op*>& o);
47 };
48 WRITE_CLASS_ENCODER(cls_lock_lock_op)
49
50 struct cls_lock_unlock_op
51 {
52 string name;
53 string cookie;
54
55 cls_lock_unlock_op() {}
56
57 void encode(bufferlist &bl) const {
58 ENCODE_START(1, 1, bl);
59 ::encode(name, bl);
60 ::encode(cookie, bl);
61 ENCODE_FINISH(bl);
62 }
63 void decode(bufferlist::iterator &bl) {
64 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
65 ::decode(name, bl);
66 ::decode(cookie, bl);
67 DECODE_FINISH(bl);
68 }
69 void dump(Formatter *f) const;
70 static void generate_test_instances(list<cls_lock_unlock_op*>& o);
71 };
72 WRITE_CLASS_ENCODER(cls_lock_unlock_op)
73
74 struct cls_lock_break_op
75 {
76 string name;
77 entity_name_t locker;
78 string cookie;
79
80 cls_lock_break_op() {}
81
82 void encode(bufferlist &bl) const {
83 ENCODE_START(1, 1, bl);
84 ::encode(name, bl);
85 ::encode(locker, bl);
86 ::encode(cookie, bl);
87 ENCODE_FINISH(bl);
88 }
89 void decode(bufferlist::iterator &bl) {
90 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
91 ::decode(name, bl);
92 ::decode(locker, bl);
93 ::decode(cookie, bl);
94 DECODE_FINISH(bl);
95 }
96 void dump(Formatter *f) const;
97 static void generate_test_instances(list<cls_lock_break_op*>& o);
98 };
99 WRITE_CLASS_ENCODER(cls_lock_break_op)
100
101 struct cls_lock_get_info_op
102 {
103 string name;
104
105 cls_lock_get_info_op() {}
106
107 void encode(bufferlist &bl) const {
108 ENCODE_START(1, 1, bl);
109 ::encode(name, bl);
110 ENCODE_FINISH(bl);
111 }
112 void decode(bufferlist::iterator &bl) {
113 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
114 ::decode(name, bl);
115 DECODE_FINISH(bl);
116 }
117 void dump(Formatter *f) const;
118 static void generate_test_instances(list<cls_lock_get_info_op*>& o);
119 };
120 WRITE_CLASS_ENCODER(cls_lock_get_info_op)
121
122 struct cls_lock_get_info_reply
123 {
124 map<rados::cls::lock::locker_id_t, rados::cls::lock::locker_info_t> lockers;
125 ClsLockType lock_type;
126 string tag;
127
128 cls_lock_get_info_reply() : lock_type(LOCK_NONE) {}
129
130 void encode(bufferlist &bl, uint64_t features) const {
131 ENCODE_START(1, 1, bl);
132 ::encode(lockers, bl, features);
133 uint8_t t = (uint8_t)lock_type;
134 ::encode(t, bl);
135 ::encode(tag, bl);
136 ENCODE_FINISH(bl);
137 }
138 void decode(bufferlist::iterator &bl) {
139 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
140 ::decode(lockers, bl);
141 uint8_t t;
142 ::decode(t, bl);
143 lock_type = (ClsLockType)t;
144 ::decode(tag, bl);
145 DECODE_FINISH(bl);
146 }
147 void dump(Formatter *f) const;
148 static void generate_test_instances(list<cls_lock_get_info_reply*>& o);
149 };
150 WRITE_CLASS_ENCODER_FEATURES(cls_lock_get_info_reply)
151
152 struct cls_lock_list_locks_reply
153 {
154 list<string> locks;
155
156 cls_lock_list_locks_reply() {}
157
158 void encode(bufferlist &bl) const {
159 ENCODE_START(1, 1, bl);
160 ::encode(locks, bl);
161 ENCODE_FINISH(bl);
162 }
163 void decode(bufferlist::iterator &bl) {
164 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
165 ::decode(locks, bl);
166 DECODE_FINISH(bl);
167 }
168 void dump(Formatter *f) const;
169 static void generate_test_instances(list<cls_lock_list_locks_reply*>& o);
170 };
171 WRITE_CLASS_ENCODER(cls_lock_list_locks_reply)
172
173 struct cls_lock_assert_op
174 {
175 string name;
176 ClsLockType type;
177 string cookie;
178 string tag;
179
180 cls_lock_assert_op() : type(LOCK_NONE) {}
181
182 void encode(bufferlist &bl) const {
183 ENCODE_START(1, 1, bl);
184 ::encode(name, bl);
185 uint8_t t = (uint8_t)type;
186 ::encode(t, bl);
187 ::encode(cookie, bl);
188 ::encode(tag, bl);
189 ENCODE_FINISH(bl);
190 }
191 void decode(bufferlist::iterator &bl) {
192 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
193 ::decode(name, bl);
194 uint8_t t;
195 ::decode(t, bl);
196 type = (ClsLockType)t;
197 ::decode(cookie, bl);
198 ::decode(tag, bl);
199 DECODE_FINISH(bl);
200 }
201 void dump(Formatter *f) const;
202 static void generate_test_instances(list<cls_lock_assert_op*>& o);
203 };
204 WRITE_CLASS_ENCODER(cls_lock_assert_op)
205
206 struct cls_lock_set_cookie_op
207 {
208 string name;
209 ClsLockType type;
210 string cookie;
211 string tag;
212 string new_cookie;
213
214 cls_lock_set_cookie_op() : type(LOCK_NONE) {}
215
216 void encode(bufferlist &bl) const {
217 ENCODE_START(1, 1, bl);
218 ::encode(name, bl);
219 uint8_t t = (uint8_t)type;
220 ::encode(t, bl);
221 ::encode(cookie, bl);
222 ::encode(tag, bl);
223 ::encode(new_cookie, bl);
224 ENCODE_FINISH(bl);
225 }
226 void decode(bufferlist::iterator &bl) {
227 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
228 ::decode(name, bl);
229 uint8_t t;
230 ::decode(t, bl);
231 type = (ClsLockType)t;
232 ::decode(cookie, bl);
233 ::decode(tag, bl);
234 ::decode(new_cookie, bl);
235 DECODE_FINISH(bl);
236 }
237 void dump(Formatter *f) const;
238 static void generate_test_instances(list<cls_lock_set_cookie_op*>& o);
239 };
240 WRITE_CLASS_ENCODER(cls_lock_set_cookie_op)
241
242 #endif