]>
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 | ||
16 | #ifndef CEPH_MMDSMAP_H | |
17 | #define CEPH_MMDSMAP_H | |
18 | ||
19 | #include "msg/Message.h" | |
20 | #include "mds/MDSMap.h" | |
21 | #include "include/ceph_features.h" | |
22 | ||
f67539c2 | 23 | class MMDSMap final : public SafeMessage { |
11fdf7f2 | 24 | private: |
f67539c2 | 25 | static constexpr int HEAD_VERSION = 2; |
11fdf7f2 | 26 | static constexpr int COMPAT_VERSION = 1; |
7c673cae | 27 | public: |
7c673cae | 28 | uuid_d fsid; |
11fdf7f2 | 29 | epoch_t epoch = 0; |
f67539c2 | 30 | ceph::buffer::list encoded; |
20effc67 TL |
31 | // don't really need map_fs_name. it was accidentally added in 51af2346fdf |
32 | // set it to empty string. | |
33 | std::string map_fs_name = std::string(); | |
7c673cae FG |
34 | |
35 | version_t get_epoch() const { return epoch; } | |
f67539c2 | 36 | const ceph::buffer::list& get_encoded() const { return encoded; } |
7c673cae | 37 | |
11fdf7f2 | 38 | protected: |
7c673cae | 39 | MMDSMap() : |
9f95a23c | 40 | SafeMessage{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION} {} |
f67539c2 | 41 | |
20effc67 | 42 | MMDSMap(const uuid_d &f, const MDSMap &mm) : |
9f95a23c | 43 | SafeMessage{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION}, |
20effc67 | 44 | fsid(f) { |
11fdf7f2 TL |
45 | epoch = mm.get_epoch(); |
46 | mm.encode(encoded, -1); // we will reencode with fewer features as necessary | |
7c673cae | 47 | } |
f67539c2 TL |
48 | |
49 | ~MMDSMap() final {} | |
7c673cae FG |
50 | |
51 | public: | |
11fdf7f2 | 52 | std::string_view get_type_name() const override { return "mdsmap"; } |
f67539c2 | 53 | void print(std::ostream& out) const override { |
7c673cae FG |
54 | out << "mdsmap(e " << epoch << ")"; |
55 | } | |
56 | ||
57 | // marshalling | |
58 | void decode_payload() override { | |
f67539c2 | 59 | using ceph::decode; |
11fdf7f2 TL |
60 | auto p = payload.cbegin(); |
61 | decode(fsid, p); | |
62 | decode(epoch, p); | |
63 | decode(encoded, p); | |
f67539c2 TL |
64 | if (header.version >= 2) { |
65 | decode(map_fs_name, p); | |
66 | } | |
7c673cae FG |
67 | } |
68 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
69 | using ceph::encode; |
70 | encode(fsid, payload); | |
71 | encode(epoch, payload); | |
7c673cae FG |
72 | if ((features & CEPH_FEATURE_PGID64) == 0 || |
73 | (features & CEPH_FEATURE_MDSENC) == 0 || | |
11fdf7f2 TL |
74 | (features & CEPH_FEATURE_MSG_ADDR2) == 0 || |
75 | !HAVE_FEATURE(features, SERVER_NAUTILUS)) { | |
7c673cae FG |
76 | // reencode for old clients. |
77 | MDSMap m; | |
78 | m.decode(encoded); | |
79 | encoded.clear(); | |
80 | m.encode(encoded, features); | |
81 | } | |
11fdf7f2 | 82 | encode(encoded, payload); |
f67539c2 | 83 | encode(map_fs_name, payload); |
7c673cae | 84 | } |
9f95a23c TL |
85 | private: |
86 | template<class T, typename... Args> | |
87 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
20effc67 TL |
88 | template<class T, typename... Args> |
89 | friend MURef<T> crimson::make_message(Args&&... args); | |
7c673cae FG |
90 | }; |
91 | ||
92 | #endif |