]>
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 | ||
11fdf7f2 TL |
23 | class MMDSMap : public MessageInstance<MMDSMap> { |
24 | public: | |
25 | friend factory; | |
26 | private: | |
27 | static constexpr int HEAD_VERSION = 1; | |
28 | static constexpr int COMPAT_VERSION = 1; | |
7c673cae | 29 | public: |
7c673cae | 30 | uuid_d fsid; |
11fdf7f2 | 31 | epoch_t epoch = 0; |
7c673cae FG |
32 | bufferlist encoded; |
33 | ||
34 | version_t get_epoch() const { return epoch; } | |
11fdf7f2 | 35 | const bufferlist& get_encoded() const { return encoded; } |
7c673cae | 36 | |
11fdf7f2 | 37 | protected: |
7c673cae | 38 | MMDSMap() : |
11fdf7f2 TL |
39 | MessageInstance(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION) {} |
40 | MMDSMap(const uuid_d &f, const MDSMap &mm) : | |
41 | MessageInstance(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION), | |
7c673cae | 42 | fsid(f) { |
11fdf7f2 TL |
43 | epoch = mm.get_epoch(); |
44 | mm.encode(encoded, -1); // we will reencode with fewer features as necessary | |
7c673cae | 45 | } |
7c673cae FG |
46 | ~MMDSMap() override {} |
47 | ||
48 | public: | |
11fdf7f2 | 49 | std::string_view get_type_name() const override { return "mdsmap"; } |
7c673cae FG |
50 | void print(ostream& out) const override { |
51 | out << "mdsmap(e " << epoch << ")"; | |
52 | } | |
53 | ||
54 | // marshalling | |
55 | void decode_payload() override { | |
11fdf7f2 TL |
56 | auto p = payload.cbegin(); |
57 | decode(fsid, p); | |
58 | decode(epoch, p); | |
59 | decode(encoded, p); | |
7c673cae FG |
60 | } |
61 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
62 | using ceph::encode; |
63 | encode(fsid, payload); | |
64 | encode(epoch, payload); | |
7c673cae FG |
65 | if ((features & CEPH_FEATURE_PGID64) == 0 || |
66 | (features & CEPH_FEATURE_MDSENC) == 0 || | |
11fdf7f2 TL |
67 | (features & CEPH_FEATURE_MSG_ADDR2) == 0 || |
68 | !HAVE_FEATURE(features, SERVER_NAUTILUS)) { | |
7c673cae FG |
69 | // reencode for old clients. |
70 | MDSMap m; | |
71 | m.decode(encoded); | |
72 | encoded.clear(); | |
73 | m.encode(encoded, features); | |
74 | } | |
11fdf7f2 | 75 | encode(encoded, payload); |
7c673cae FG |
76 | } |
77 | }; | |
78 | ||
79 | #endif |