]>
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 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef CEPH_MCLIENTSNAP_H | |
16 | #define CEPH_MCLIENTSNAP_H | |
17 | ||
18 | #include "msg/Message.h" | |
19 | ||
f67539c2 | 20 | class MClientSnap final : public SafeMessage { |
11fdf7f2 | 21 | public: |
7c673cae | 22 | ceph_mds_snap_head head; |
f67539c2 | 23 | ceph::buffer::list bl; |
7c673cae FG |
24 | |
25 | // (for split only) | |
f67539c2 TL |
26 | std::vector<inodeno_t> split_inos; |
27 | std::vector<inodeno_t> split_realms; | |
7c673cae | 28 | |
11fdf7f2 | 29 | protected: |
7c673cae | 30 | MClientSnap(int o=0) : |
9f95a23c | 31 | SafeMessage{CEPH_MSG_CLIENT_SNAP} { |
7c673cae FG |
32 | memset(&head, 0, sizeof(head)); |
33 | head.op = o; | |
34 | } | |
f67539c2 | 35 | ~MClientSnap() final {} |
7c673cae FG |
36 | |
37 | public: | |
11fdf7f2 | 38 | std::string_view get_type_name() const override { return "client_snap"; } |
f67539c2 | 39 | void print(std::ostream& out) const override { |
7c673cae FG |
40 | out << "client_snap(" << ceph_snap_op_name(head.op); |
41 | if (head.split) | |
42 | out << " split=" << inodeno_t(head.split); | |
43 | out << " tracelen=" << bl.length(); | |
44 | out << ")"; | |
45 | } | |
46 | ||
47 | void encode_payload(uint64_t features) override { | |
11fdf7f2 | 48 | using ceph::encode; |
7c673cae FG |
49 | head.num_split_inos = split_inos.size(); |
50 | head.num_split_realms = split_realms.size(); | |
51 | head.trace_len = bl.length(); | |
11fdf7f2 | 52 | encode(head, payload); |
f67539c2 TL |
53 | ceph::encode_nohead(split_inos, payload); |
54 | ceph::encode_nohead(split_realms, payload); | |
55 | ceph::encode_nohead(bl, payload); | |
7c673cae FG |
56 | } |
57 | void decode_payload() override { | |
f67539c2 | 58 | using ceph::decode; |
11fdf7f2 TL |
59 | auto p = payload.cbegin(); |
60 | decode(head, p); | |
f67539c2 TL |
61 | ceph::decode_nohead(head.num_split_inos, split_inos, p); |
62 | ceph::decode_nohead(head.num_split_realms, split_realms, p); | |
63 | ceph::decode_nohead(head.trace_len, bl, p); | |
11fdf7f2 | 64 | ceph_assert(p.end()); |
7c673cae | 65 | } |
9f95a23c TL |
66 | private: |
67 | template<class T, typename... Args> | |
68 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
69 | }; |
70 | ||
71 | #endif |