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