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