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