]>
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_MDIRUPDATE_H | |
17 | #define CEPH_MDIRUPDATE_H | |
18 | ||
f67539c2 | 19 | #include "messages/MMDSOp.h" |
7c673cae | 20 | |
f67539c2 | 21 | class MDirUpdate final : public MMDSOp { |
94b18763 | 22 | public: |
7c673cae FG |
23 | mds_rank_t get_source_mds() const { return from_mds; } |
24 | dirfrag_t get_dirfrag() const { return dirfrag; } | |
25 | int get_dir_rep() const { return dir_rep; } | |
94b18763 | 26 | const std::set<int32_t>& get_dir_rep_by() const { return dir_rep_by; } |
224ce89b | 27 | bool should_discover() const { return discover > tried_discover; } |
7c673cae FG |
28 | const filepath& get_path() const { return path; } |
29 | ||
224ce89b | 30 | bool has_tried_discover() const { return tried_discover > 0; } |
11fdf7f2 | 31 | void inc_tried_discover() const { ++tried_discover; } |
7c673cae | 32 | |
11fdf7f2 | 33 | std::string_view get_type_name() const override { return "dir_update"; } |
f67539c2 | 34 | void print(std::ostream& out) const override { |
7c673cae FG |
35 | out << "dir_update(" << get_dirfrag() << ")"; |
36 | } | |
37 | ||
38 | void decode_payload() override { | |
f67539c2 | 39 | using ceph::decode; |
11fdf7f2 TL |
40 | auto p = payload.cbegin(); |
41 | decode(from_mds, p); | |
42 | decode(dirfrag, p); | |
43 | decode(dir_rep, p); | |
44 | decode(discover, p); | |
45 | decode(dir_rep_by, p); | |
46 | decode(path, p); | |
7c673cae FG |
47 | } |
48 | ||
49 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
50 | using ceph::encode; |
51 | encode(from_mds, payload); | |
52 | encode(dirfrag, payload); | |
53 | encode(dir_rep, payload); | |
54 | encode(discover, payload); | |
55 | encode(dir_rep_by, payload); | |
56 | encode(path, payload); | |
7c673cae | 57 | } |
94b18763 | 58 | |
11fdf7f2 | 59 | protected: |
f67539c2 TL |
60 | ~MDirUpdate() final {} |
61 | MDirUpdate() : MMDSOp(MSG_MDS_DIRUPDATE, HEAD_VERSION, COMPAT_VERSION) {} | |
11fdf7f2 TL |
62 | MDirUpdate(mds_rank_t f, |
63 | dirfrag_t dirfrag, | |
64 | int dir_rep, | |
65 | const std::set<int32_t>& dir_rep_by, | |
66 | filepath& path, | |
67 | bool discover = false) : | |
f67539c2 | 68 | MMDSOp(MSG_MDS_DIRUPDATE, HEAD_VERSION, COMPAT_VERSION), from_mds(f), dirfrag(dirfrag), |
11fdf7f2 TL |
69 | dir_rep(dir_rep), dir_rep_by(dir_rep_by), path(path) { |
70 | this->discover = discover ? 5 : 0; | |
71 | } | |
72 | MDirUpdate(const MDirUpdate& m) | |
f67539c2 | 73 | : MMDSOp{MSG_MDS_DIRUPDATE}, |
11fdf7f2 TL |
74 | from_mds(m.from_mds), |
75 | dirfrag(m.dirfrag), | |
76 | dir_rep(m.dir_rep), | |
77 | discover(m.discover), | |
78 | dir_rep_by(m.dir_rep_by), | |
79 | path(m.path), | |
80 | tried_discover(m.tried_discover) | |
81 | {} | |
94b18763 FG |
82 | |
83 | mds_rank_t from_mds = -1; | |
84 | dirfrag_t dirfrag; | |
85 | int32_t dir_rep = 5; | |
86 | int32_t discover = 5; | |
87 | std::set<int32_t> dir_rep_by; | |
88 | filepath path; | |
11fdf7f2 | 89 | mutable int tried_discover = 0; // XXX HACK |
9f95a23c TL |
90 | |
91 | private: | |
f67539c2 TL |
92 | static constexpr int HEAD_VERSION = 1; |
93 | static constexpr int COMPAT_VERSION = 1; | |
9f95a23c TL |
94 | template<class T, typename... Args> |
95 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
96 | }; |
97 | ||
98 | #endif |