]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #include "cls/rbd/cls_rbd_types.h" | |
5 | #include "common/Formatter.h" | |
11fdf7f2 | 6 | #include "include/ceph_assert.h" |
7c673cae FG |
7 | #include "include/stringify.h" |
8 | #include "librbd/WatchNotifyTypes.h" | |
7c673cae FG |
9 | |
10 | namespace librbd { | |
11 | namespace watch_notify { | |
12 | ||
7c673cae | 13 | void AsyncRequestId::encode(bufferlist &bl) const { |
11fdf7f2 TL |
14 | using ceph::encode; |
15 | encode(client_id, bl); | |
16 | encode(request_id, bl); | |
7c673cae FG |
17 | } |
18 | ||
11fdf7f2 TL |
19 | void AsyncRequestId::decode(bufferlist::const_iterator &iter) { |
20 | using ceph::decode; | |
21 | decode(client_id, iter); | |
22 | decode(request_id, iter); | |
7c673cae FG |
23 | } |
24 | ||
25 | void AsyncRequestId::dump(Formatter *f) const { | |
26 | f->open_object_section("client_id"); | |
27 | client_id.dump(f); | |
28 | f->close_section(); | |
29 | f->dump_unsigned("request_id", request_id); | |
30 | } | |
31 | ||
32 | void AcquiredLockPayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
33 | using ceph::encode; |
34 | encode(client_id, bl); | |
7c673cae FG |
35 | } |
36 | ||
11fdf7f2 TL |
37 | void AcquiredLockPayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
38 | using ceph::decode; | |
7c673cae | 39 | if (version >= 2) { |
11fdf7f2 | 40 | decode(client_id, iter); |
7c673cae FG |
41 | } |
42 | } | |
43 | ||
44 | void AcquiredLockPayload::dump(Formatter *f) const { | |
45 | f->open_object_section("client_id"); | |
46 | client_id.dump(f); | |
47 | f->close_section(); | |
48 | } | |
49 | ||
50 | void ReleasedLockPayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
51 | using ceph::encode; |
52 | encode(client_id, bl); | |
7c673cae FG |
53 | } |
54 | ||
11fdf7f2 TL |
55 | void ReleasedLockPayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
56 | using ceph::decode; | |
7c673cae | 57 | if (version >= 2) { |
11fdf7f2 | 58 | decode(client_id, iter); |
7c673cae FG |
59 | } |
60 | } | |
61 | ||
62 | void ReleasedLockPayload::dump(Formatter *f) const { | |
63 | f->open_object_section("client_id"); | |
64 | client_id.dump(f); | |
65 | f->close_section(); | |
66 | } | |
67 | ||
68 | void RequestLockPayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
69 | using ceph::encode; |
70 | encode(client_id, bl); | |
71 | encode(force, bl); | |
7c673cae FG |
72 | } |
73 | ||
11fdf7f2 TL |
74 | void RequestLockPayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
75 | using ceph::decode; | |
7c673cae | 76 | if (version >= 2) { |
11fdf7f2 | 77 | decode(client_id, iter); |
7c673cae FG |
78 | } |
79 | if (version >= 3) { | |
11fdf7f2 | 80 | decode(force, iter); |
7c673cae FG |
81 | } |
82 | } | |
83 | ||
84 | void RequestLockPayload::dump(Formatter *f) const { | |
85 | f->open_object_section("client_id"); | |
86 | client_id.dump(f); | |
87 | f->close_section(); | |
88 | f->dump_bool("force", force); | |
89 | } | |
90 | ||
91 | void HeaderUpdatePayload::encode(bufferlist &bl) const { | |
92 | } | |
93 | ||
11fdf7f2 | 94 | void HeaderUpdatePayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
7c673cae FG |
95 | } |
96 | ||
97 | void HeaderUpdatePayload::dump(Formatter *f) const { | |
98 | } | |
99 | ||
100 | void AsyncRequestPayloadBase::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
101 | using ceph::encode; |
102 | encode(async_request_id, bl); | |
7c673cae FG |
103 | } |
104 | ||
11fdf7f2 TL |
105 | void AsyncRequestPayloadBase::decode(__u8 version, bufferlist::const_iterator &iter) { |
106 | using ceph::decode; | |
107 | decode(async_request_id, iter); | |
7c673cae FG |
108 | } |
109 | ||
110 | void AsyncRequestPayloadBase::dump(Formatter *f) const { | |
111 | f->open_object_section("async_request_id"); | |
112 | async_request_id.dump(f); | |
113 | f->close_section(); | |
114 | } | |
115 | ||
116 | void AsyncProgressPayload::encode(bufferlist &bl) const { | |
11fdf7f2 | 117 | using ceph::encode; |
7c673cae | 118 | AsyncRequestPayloadBase::encode(bl); |
11fdf7f2 TL |
119 | encode(offset, bl); |
120 | encode(total, bl); | |
7c673cae FG |
121 | } |
122 | ||
11fdf7f2 TL |
123 | void AsyncProgressPayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
124 | using ceph::decode; | |
7c673cae | 125 | AsyncRequestPayloadBase::decode(version, iter); |
11fdf7f2 TL |
126 | decode(offset, iter); |
127 | decode(total, iter); | |
7c673cae FG |
128 | } |
129 | ||
130 | void AsyncProgressPayload::dump(Formatter *f) const { | |
131 | AsyncRequestPayloadBase::dump(f); | |
132 | f->dump_unsigned("offset", offset); | |
133 | f->dump_unsigned("total", total); | |
134 | } | |
135 | ||
136 | void AsyncCompletePayload::encode(bufferlist &bl) const { | |
11fdf7f2 | 137 | using ceph::encode; |
7c673cae | 138 | AsyncRequestPayloadBase::encode(bl); |
11fdf7f2 | 139 | encode(result, bl); |
7c673cae FG |
140 | } |
141 | ||
11fdf7f2 TL |
142 | void AsyncCompletePayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
143 | using ceph::decode; | |
7c673cae | 144 | AsyncRequestPayloadBase::decode(version, iter); |
11fdf7f2 | 145 | decode(result, iter); |
7c673cae FG |
146 | } |
147 | ||
148 | void AsyncCompletePayload::dump(Formatter *f) const { | |
149 | AsyncRequestPayloadBase::dump(f); | |
150 | f->dump_int("result", result); | |
151 | } | |
152 | ||
153 | void ResizePayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
154 | using ceph::encode; |
155 | encode(size, bl); | |
7c673cae | 156 | AsyncRequestPayloadBase::encode(bl); |
11fdf7f2 | 157 | encode(allow_shrink, bl); |
7c673cae FG |
158 | } |
159 | ||
11fdf7f2 TL |
160 | void ResizePayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
161 | using ceph::decode; | |
162 | decode(size, iter); | |
7c673cae FG |
163 | AsyncRequestPayloadBase::decode(version, iter); |
164 | ||
165 | if (version >= 4) { | |
11fdf7f2 | 166 | decode(allow_shrink, iter); |
7c673cae FG |
167 | } |
168 | } | |
169 | ||
170 | void ResizePayload::dump(Formatter *f) const { | |
f67539c2 | 171 | AsyncRequestPayloadBase::dump(f); |
7c673cae FG |
172 | f->dump_unsigned("size", size); |
173 | f->dump_bool("allow_shrink", allow_shrink); | |
7c673cae FG |
174 | } |
175 | ||
176 | void SnapPayloadBase::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
177 | using ceph::encode; |
178 | encode(snap_name, bl); | |
179 | encode(snap_namespace, bl); | |
f67539c2 | 180 | encode(async_request_id, bl); |
7c673cae FG |
181 | } |
182 | ||
11fdf7f2 TL |
183 | void SnapPayloadBase::decode(__u8 version, bufferlist::const_iterator &iter) { |
184 | using ceph::decode; | |
185 | decode(snap_name, iter); | |
7c673cae | 186 | if (version >= 6) { |
11fdf7f2 | 187 | decode(snap_namespace, iter); |
7c673cae | 188 | } |
f67539c2 TL |
189 | if (version >= 7) { |
190 | decode(async_request_id, iter); | |
191 | } | |
7c673cae FG |
192 | } |
193 | ||
194 | void SnapPayloadBase::dump(Formatter *f) const { | |
f67539c2 | 195 | AsyncRequestPayloadBase::dump(f); |
7c673cae | 196 | f->dump_string("snap_name", snap_name); |
11fdf7f2 | 197 | snap_namespace.dump(f); |
7c673cae FG |
198 | } |
199 | ||
200 | void SnapCreatePayload::encode(bufferlist &bl) const { | |
f67539c2 | 201 | using ceph::encode; |
7c673cae | 202 | SnapPayloadBase::encode(bl); |
f67539c2 | 203 | encode(flags, bl); |
7c673cae FG |
204 | } |
205 | ||
11fdf7f2 TL |
206 | void SnapCreatePayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
207 | using ceph::decode; | |
7c673cae FG |
208 | SnapPayloadBase::decode(version, iter); |
209 | if (version == 5) { | |
11fdf7f2 | 210 | decode(snap_namespace, iter); |
7c673cae | 211 | } |
f67539c2 TL |
212 | if (version >= 7) { |
213 | decode(flags, iter); | |
214 | } | |
7c673cae FG |
215 | } |
216 | ||
217 | void SnapCreatePayload::dump(Formatter *f) const { | |
218 | SnapPayloadBase::dump(f); | |
f67539c2 | 219 | f->dump_unsigned("flags", flags); |
7c673cae FG |
220 | } |
221 | ||
222 | void SnapRenamePayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
223 | using ceph::encode; |
224 | encode(snap_id, bl); | |
7c673cae FG |
225 | SnapPayloadBase::encode(bl); |
226 | } | |
227 | ||
11fdf7f2 TL |
228 | void SnapRenamePayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
229 | using ceph::decode; | |
230 | decode(snap_id, iter); | |
7c673cae FG |
231 | SnapPayloadBase::decode(version, iter); |
232 | } | |
233 | ||
234 | void SnapRenamePayload::dump(Formatter *f) const { | |
7c673cae | 235 | SnapPayloadBase::dump(f); |
f67539c2 | 236 | f->dump_unsigned("src_snap_id", snap_id); |
7c673cae FG |
237 | } |
238 | ||
239 | void RenamePayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
240 | using ceph::encode; |
241 | encode(image_name, bl); | |
f67539c2 | 242 | encode(async_request_id, bl); |
7c673cae FG |
243 | } |
244 | ||
11fdf7f2 TL |
245 | void RenamePayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
246 | using ceph::decode; | |
247 | decode(image_name, iter); | |
f67539c2 TL |
248 | if (version >= 7) { |
249 | decode(async_request_id, iter); | |
250 | } | |
7c673cae FG |
251 | } |
252 | ||
253 | void RenamePayload::dump(Formatter *f) const { | |
f67539c2 | 254 | AsyncRequestPayloadBase::dump(f); |
7c673cae FG |
255 | f->dump_string("image_name", image_name); |
256 | } | |
257 | ||
258 | void UpdateFeaturesPayload::encode(bufferlist &bl) const { | |
11fdf7f2 TL |
259 | using ceph::encode; |
260 | encode(features, bl); | |
261 | encode(enabled, bl); | |
f67539c2 | 262 | encode(async_request_id, bl); |
7c673cae FG |
263 | } |
264 | ||
11fdf7f2 TL |
265 | void UpdateFeaturesPayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
266 | using ceph::decode; | |
267 | decode(features, iter); | |
268 | decode(enabled, iter); | |
f67539c2 TL |
269 | if (version >= 7) { |
270 | decode(async_request_id, iter); | |
271 | } | |
7c673cae FG |
272 | } |
273 | ||
274 | void UpdateFeaturesPayload::dump(Formatter *f) const { | |
f67539c2 | 275 | AsyncRequestPayloadBase::dump(f); |
7c673cae FG |
276 | f->dump_unsigned("features", features); |
277 | f->dump_bool("enabled", enabled); | |
278 | } | |
279 | ||
11fdf7f2 TL |
280 | void SparsifyPayload::encode(bufferlist &bl) const { |
281 | using ceph::encode; | |
282 | AsyncRequestPayloadBase::encode(bl); | |
283 | encode(sparse_size, bl); | |
284 | } | |
285 | ||
286 | void SparsifyPayload::decode(__u8 version, bufferlist::const_iterator &iter) { | |
287 | using ceph::decode; | |
288 | AsyncRequestPayloadBase::decode(version, iter); | |
289 | decode(sparse_size, iter); | |
290 | } | |
291 | ||
292 | void SparsifyPayload::dump(Formatter *f) const { | |
293 | AsyncRequestPayloadBase::dump(f); | |
294 | f->dump_unsigned("sparse_size", sparse_size); | |
295 | } | |
296 | ||
f67539c2 TL |
297 | void MetadataUpdatePayload::encode(bufferlist &bl) const { |
298 | using ceph::encode; | |
299 | encode(key, bl); | |
300 | encode(value, bl); | |
301 | encode(async_request_id, bl); | |
302 | } | |
303 | ||
304 | void MetadataUpdatePayload::decode(__u8 version, bufferlist::const_iterator &iter) { | |
305 | using ceph::decode; | |
306 | decode(key, iter); | |
307 | decode(value, iter); | |
308 | if (version >= 7) { | |
309 | decode(async_request_id, iter); | |
310 | } | |
311 | } | |
312 | ||
313 | void MetadataUpdatePayload::dump(Formatter *f) const { | |
314 | AsyncRequestPayloadBase::dump(f); | |
315 | f->dump_string("key", key); | |
316 | f->dump_string("value", *value); | |
317 | } | |
318 | ||
7c673cae | 319 | void UnknownPayload::encode(bufferlist &bl) const { |
11fdf7f2 | 320 | ceph_abort(); |
7c673cae FG |
321 | } |
322 | ||
11fdf7f2 | 323 | void UnknownPayload::decode(__u8 version, bufferlist::const_iterator &iter) { |
7c673cae FG |
324 | } |
325 | ||
326 | void UnknownPayload::dump(Formatter *f) const { | |
327 | } | |
328 | ||
329 | bool NotifyMessage::check_for_refresh() const { | |
f67539c2 | 330 | return payload->check_for_refresh(); |
7c673cae FG |
331 | } |
332 | ||
333 | void NotifyMessage::encode(bufferlist& bl) const { | |
f67539c2 TL |
334 | ENCODE_START(7, 1, bl); |
335 | encode(static_cast<uint32_t>(payload->get_notify_op()), bl); | |
336 | payload->encode(bl); | |
7c673cae FG |
337 | ENCODE_FINISH(bl); |
338 | } | |
339 | ||
11fdf7f2 | 340 | void NotifyMessage::decode(bufferlist::const_iterator& iter) { |
7c673cae FG |
341 | DECODE_START(1, iter); |
342 | ||
343 | uint32_t notify_op; | |
11fdf7f2 | 344 | decode(notify_op, iter); |
7c673cae FG |
345 | |
346 | // select the correct payload variant based upon the encoded op | |
347 | switch (notify_op) { | |
348 | case NOTIFY_OP_ACQUIRED_LOCK: | |
f67539c2 | 349 | payload.reset(new AcquiredLockPayload()); |
7c673cae FG |
350 | break; |
351 | case NOTIFY_OP_RELEASED_LOCK: | |
f67539c2 | 352 | payload.reset(new ReleasedLockPayload()); |
7c673cae FG |
353 | break; |
354 | case NOTIFY_OP_REQUEST_LOCK: | |
f67539c2 | 355 | payload.reset(new RequestLockPayload()); |
7c673cae FG |
356 | break; |
357 | case NOTIFY_OP_HEADER_UPDATE: | |
f67539c2 | 358 | payload.reset(new HeaderUpdatePayload()); |
7c673cae FG |
359 | break; |
360 | case NOTIFY_OP_ASYNC_PROGRESS: | |
f67539c2 | 361 | payload.reset(new AsyncProgressPayload()); |
7c673cae FG |
362 | break; |
363 | case NOTIFY_OP_ASYNC_COMPLETE: | |
f67539c2 | 364 | payload.reset(new AsyncCompletePayload()); |
7c673cae FG |
365 | break; |
366 | case NOTIFY_OP_FLATTEN: | |
f67539c2 | 367 | payload.reset(new FlattenPayload()); |
7c673cae FG |
368 | break; |
369 | case NOTIFY_OP_RESIZE: | |
f67539c2 | 370 | payload.reset(new ResizePayload()); |
7c673cae FG |
371 | break; |
372 | case NOTIFY_OP_SNAP_CREATE: | |
f67539c2 | 373 | payload.reset(new SnapCreatePayload()); |
7c673cae FG |
374 | break; |
375 | case NOTIFY_OP_SNAP_REMOVE: | |
f67539c2 | 376 | payload.reset(new SnapRemovePayload()); |
7c673cae FG |
377 | break; |
378 | case NOTIFY_OP_SNAP_RENAME: | |
f67539c2 | 379 | payload.reset(new SnapRenamePayload()); |
7c673cae FG |
380 | break; |
381 | case NOTIFY_OP_SNAP_PROTECT: | |
f67539c2 | 382 | payload.reset(new SnapProtectPayload()); |
7c673cae FG |
383 | break; |
384 | case NOTIFY_OP_SNAP_UNPROTECT: | |
f67539c2 | 385 | payload.reset(new SnapUnprotectPayload()); |
7c673cae FG |
386 | break; |
387 | case NOTIFY_OP_REBUILD_OBJECT_MAP: | |
f67539c2 | 388 | payload.reset(new RebuildObjectMapPayload()); |
7c673cae FG |
389 | break; |
390 | case NOTIFY_OP_RENAME: | |
f67539c2 | 391 | payload.reset(new RenamePayload()); |
7c673cae FG |
392 | break; |
393 | case NOTIFY_OP_UPDATE_FEATURES: | |
f67539c2 | 394 | payload.reset(new UpdateFeaturesPayload()); |
7c673cae | 395 | break; |
11fdf7f2 | 396 | case NOTIFY_OP_MIGRATE: |
f67539c2 | 397 | payload.reset(new MigratePayload()); |
11fdf7f2 TL |
398 | break; |
399 | case NOTIFY_OP_SPARSIFY: | |
f67539c2 | 400 | payload.reset(new SparsifyPayload()); |
11fdf7f2 | 401 | break; |
f67539c2 TL |
402 | case NOTIFY_OP_QUIESCE: |
403 | payload.reset(new QuiescePayload()); | |
404 | break; | |
405 | case NOTIFY_OP_UNQUIESCE: | |
406 | payload.reset(new UnquiescePayload()); | |
407 | break; | |
408 | case NOTIFY_OP_METADATA_UPDATE: | |
409 | payload.reset(new MetadataUpdatePayload()); | |
7c673cae FG |
410 | break; |
411 | } | |
412 | ||
f67539c2 | 413 | payload->decode(struct_v, iter); |
7c673cae FG |
414 | DECODE_FINISH(iter); |
415 | } | |
416 | ||
417 | void NotifyMessage::dump(Formatter *f) const { | |
f67539c2 | 418 | payload->dump(f); |
7c673cae FG |
419 | } |
420 | ||
11fdf7f2 | 421 | NotifyOp NotifyMessage::get_notify_op() const { |
f67539c2 | 422 | return payload->get_notify_op(); |
11fdf7f2 TL |
423 | } |
424 | ||
7c673cae | 425 | void NotifyMessage::generate_test_instances(std::list<NotifyMessage *> &o) { |
f67539c2 TL |
426 | o.push_back(new NotifyMessage(new AcquiredLockPayload(ClientId(1, 2)))); |
427 | o.push_back(new NotifyMessage(new ReleasedLockPayload(ClientId(1, 2)))); | |
428 | o.push_back(new NotifyMessage(new RequestLockPayload(ClientId(1, 2), true))); | |
429 | o.push_back(new NotifyMessage(new HeaderUpdatePayload())); | |
430 | o.push_back(new NotifyMessage(new AsyncProgressPayload(AsyncRequestId(ClientId(0, 1), 2), 3, 4))); | |
431 | o.push_back(new NotifyMessage(new AsyncCompletePayload(AsyncRequestId(ClientId(0, 1), 2), 3))); | |
432 | o.push_back(new NotifyMessage(new FlattenPayload(AsyncRequestId(ClientId(0, 1), 2)))); | |
433 | o.push_back(new NotifyMessage(new ResizePayload(AsyncRequestId(ClientId(0, 1), 2), 123, true))); | |
434 | o.push_back(new NotifyMessage(new SnapCreatePayload(AsyncRequestId(ClientId(0, 1), 2), | |
435 | cls::rbd::UserSnapshotNamespace(), | |
436 | "foo", 1))); | |
437 | o.push_back(new NotifyMessage(new SnapRemovePayload(AsyncRequestId(ClientId(0, 1), 2), | |
438 | cls::rbd::UserSnapshotNamespace(), "foo"))); | |
439 | o.push_back(new NotifyMessage(new SnapProtectPayload(AsyncRequestId(ClientId(0, 1), 2), | |
440 | cls::rbd::UserSnapshotNamespace(), "foo"))); | |
441 | o.push_back(new NotifyMessage(new SnapUnprotectPayload(AsyncRequestId(ClientId(0, 1), 2), | |
442 | cls::rbd::UserSnapshotNamespace(), "foo"))); | |
443 | o.push_back(new NotifyMessage(new RebuildObjectMapPayload(AsyncRequestId(ClientId(0, 1), 2)))); | |
444 | o.push_back(new NotifyMessage(new RenamePayload(AsyncRequestId(ClientId(0, 1), 2), "foo"))); | |
445 | o.push_back(new NotifyMessage(new UpdateFeaturesPayload(AsyncRequestId(ClientId(0, 1), 2), | |
446 | 1, true))); | |
447 | o.push_back(new NotifyMessage(new MigratePayload(AsyncRequestId(ClientId(0, 1), 2)))); | |
448 | o.push_back(new NotifyMessage(new SparsifyPayload(AsyncRequestId(ClientId(0, 1), 2), 1))); | |
449 | o.push_back(new NotifyMessage(new QuiescePayload(AsyncRequestId(ClientId(0, 1), 2)))); | |
450 | o.push_back(new NotifyMessage(new UnquiescePayload(AsyncRequestId(ClientId(0, 1), 2)))); | |
451 | o.push_back(new NotifyMessage(new MetadataUpdatePayload(AsyncRequestId(ClientId(0, 1), 2), | |
452 | "foo", std::optional<std::string>{"xyz"}))); | |
7c673cae FG |
453 | } |
454 | ||
455 | void ResponseMessage::encode(bufferlist& bl) const { | |
456 | ENCODE_START(1, 1, bl); | |
11fdf7f2 | 457 | encode(result, bl); |
7c673cae FG |
458 | ENCODE_FINISH(bl); |
459 | } | |
460 | ||
11fdf7f2 | 461 | void ResponseMessage::decode(bufferlist::const_iterator& iter) { |
7c673cae | 462 | DECODE_START(1, iter); |
11fdf7f2 | 463 | decode(result, iter); |
7c673cae FG |
464 | DECODE_FINISH(iter); |
465 | } | |
466 | ||
467 | void ResponseMessage::dump(Formatter *f) const { | |
468 | f->dump_int("result", result); | |
469 | } | |
470 | ||
471 | void ResponseMessage::generate_test_instances(std::list<ResponseMessage *> &o) { | |
472 | o.push_back(new ResponseMessage(1)); | |
473 | } | |
474 | ||
7c673cae FG |
475 | std::ostream &operator<<(std::ostream &out, |
476 | const librbd::watch_notify::NotifyOp &op) { | |
477 | using namespace librbd::watch_notify; | |
478 | ||
479 | switch (op) { | |
480 | case NOTIFY_OP_ACQUIRED_LOCK: | |
481 | out << "AcquiredLock"; | |
482 | break; | |
483 | case NOTIFY_OP_RELEASED_LOCK: | |
484 | out << "ReleasedLock"; | |
485 | break; | |
486 | case NOTIFY_OP_REQUEST_LOCK: | |
487 | out << "RequestLock"; | |
488 | break; | |
489 | case NOTIFY_OP_HEADER_UPDATE: | |
490 | out << "HeaderUpdate"; | |
491 | break; | |
492 | case NOTIFY_OP_ASYNC_PROGRESS: | |
493 | out << "AsyncProgress"; | |
494 | break; | |
495 | case NOTIFY_OP_ASYNC_COMPLETE: | |
496 | out << "AsyncComplete"; | |
497 | break; | |
498 | case NOTIFY_OP_FLATTEN: | |
499 | out << "Flatten"; | |
500 | break; | |
501 | case NOTIFY_OP_RESIZE: | |
502 | out << "Resize"; | |
503 | break; | |
504 | case NOTIFY_OP_SNAP_CREATE: | |
505 | out << "SnapCreate"; | |
506 | break; | |
507 | case NOTIFY_OP_SNAP_REMOVE: | |
508 | out << "SnapRemove"; | |
509 | break; | |
510 | case NOTIFY_OP_SNAP_RENAME: | |
511 | out << "SnapRename"; | |
512 | break; | |
513 | case NOTIFY_OP_SNAP_PROTECT: | |
514 | out << "SnapProtect"; | |
515 | break; | |
516 | case NOTIFY_OP_SNAP_UNPROTECT: | |
517 | out << "SnapUnprotect"; | |
518 | break; | |
519 | case NOTIFY_OP_REBUILD_OBJECT_MAP: | |
520 | out << "RebuildObjectMap"; | |
521 | break; | |
522 | case NOTIFY_OP_RENAME: | |
523 | out << "Rename"; | |
524 | break; | |
525 | case NOTIFY_OP_UPDATE_FEATURES: | |
526 | out << "UpdateFeatures"; | |
527 | break; | |
11fdf7f2 TL |
528 | case NOTIFY_OP_MIGRATE: |
529 | out << "Migrate"; | |
530 | break; | |
531 | case NOTIFY_OP_SPARSIFY: | |
532 | out << "Sparsify"; | |
533 | break; | |
f67539c2 TL |
534 | case NOTIFY_OP_QUIESCE: |
535 | out << "Quiesce"; | |
536 | break; | |
537 | case NOTIFY_OP_UNQUIESCE: | |
538 | out << "Unquiesce"; | |
539 | break; | |
540 | case NOTIFY_OP_METADATA_UPDATE: | |
541 | out << "MetadataUpdate"; | |
542 | break; | |
7c673cae FG |
543 | default: |
544 | out << "Unknown (" << static_cast<uint32_t>(op) << ")"; | |
545 | break; | |
546 | } | |
547 | return out; | |
548 | } | |
549 | ||
550 | std::ostream &operator<<(std::ostream &out, | |
551 | const librbd::watch_notify::AsyncRequestId &request) { | |
552 | out << "[" << request.client_id.gid << "," << request.client_id.handle << "," | |
553 | << request.request_id << "]"; | |
554 | return out; | |
555 | } | |
11fdf7f2 TL |
556 | } // namespace watch_notify |
557 | } // namespace librbd |