]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MDentryLink.h
import 15.2.2 octopus source
[ceph.git] / ceph / src / messages / MDentryLink.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_MDENTRYLINK_H
17 #define CEPH_MDENTRYLINK_H
18
19 #include <string_view>
20
21 #include "msg/Message.h"
22
23 class MDentryLink : public SafeMessage {
24 private:
25 static const int HEAD_VERSION = 1;
26 static const int COMPAT_VERSION = 1;
27
28 dirfrag_t subtree;
29 dirfrag_t dirfrag;
30 string dn;
31 bool is_primary = false;
32
33 public:
34 dirfrag_t get_subtree() const { return subtree; }
35 dirfrag_t get_dirfrag() const { return dirfrag; }
36 const string& get_dn() const { return dn; }
37 bool get_is_primary() const { return is_primary; }
38
39 bufferlist bl;
40
41 protected:
42 MDentryLink() :
43 SafeMessage(MSG_MDS_DENTRYLINK, HEAD_VERSION, COMPAT_VERSION) { }
44 MDentryLink(dirfrag_t r, dirfrag_t df, std::string_view n, bool p) :
45 SafeMessage(MSG_MDS_DENTRYLINK, HEAD_VERSION, COMPAT_VERSION),
46 subtree(r),
47 dirfrag(df),
48 dn(n),
49 is_primary(p) {}
50 ~MDentryLink() override {}
51
52 public:
53 std::string_view get_type_name() const override { return "dentry_link";}
54 void print(ostream& o) const override {
55 o << "dentry_link(" << dirfrag << " " << dn << ")";
56 }
57
58 void decode_payload() override {
59 auto p = payload.cbegin();
60 decode(subtree, p);
61 decode(dirfrag, p);
62 decode(dn, p);
63 decode(is_primary, p);
64 decode(bl, p);
65 }
66 void encode_payload(uint64_t features) override {
67 using ceph::encode;
68 encode(subtree, payload);
69 encode(dirfrag, payload);
70 encode(dn, payload);
71 encode(is_primary, payload);
72 encode(bl, payload);
73 }
74 private:
75 template<class T, typename... Args>
76 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
77 };
78
79 #endif