]>
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 | #ifndef CEPH_MEXPORTDIRNOTIFY_H | |
16 | #define CEPH_MEXPORTDIRNOTIFY_H | |
17 | ||
f67539c2 | 18 | #include "messages/MMDSOp.h" |
7c673cae | 19 | |
f67539c2 | 20 | class MExportDirNotify final : public MMDSOp { |
11fdf7f2 | 21 | private: |
f67539c2 TL |
22 | static constexpr int HEAD_VERSION = 1; |
23 | static constexpr int COMPAT_VERSION = 1; | |
9f95a23c | 24 | |
7c673cae FG |
25 | dirfrag_t base; |
26 | bool ack; | |
f67539c2 TL |
27 | std::pair<__s32,__s32> old_auth, new_auth; |
28 | std::list<dirfrag_t> bounds; // bounds; these dirs are _not_ included (tho the dirfragdes are) | |
7c673cae FG |
29 | |
30 | public: | |
11fdf7f2 | 31 | dirfrag_t get_dirfrag() const { return base; } |
f67539c2 TL |
32 | std::pair<__s32,__s32> get_old_auth() const { return old_auth; } |
33 | std::pair<__s32,__s32> get_new_auth() const { return new_auth; } | |
11fdf7f2 | 34 | bool wants_ack() const { return ack; } |
f67539c2 TL |
35 | const std::list<dirfrag_t>& get_bounds() const { return bounds; } |
36 | std::list<dirfrag_t>& get_bounds() { return bounds; } | |
7c673cae | 37 | |
11fdf7f2 | 38 | protected: |
9f95a23c | 39 | MExportDirNotify() : |
f67539c2 TL |
40 | MMDSOp{MSG_MDS_EXPORTDIRNOTIFY, HEAD_VERSION, COMPAT_VERSION} {} |
41 | MExportDirNotify(dirfrag_t i, uint64_t tid, bool a, std::pair<__s32,__s32> oa, | |
42 | std::pair<__s32,__s32> na) : | |
43 | MMDSOp{MSG_MDS_EXPORTDIRNOTIFY, HEAD_VERSION, COMPAT_VERSION}, | |
7c673cae FG |
44 | base(i), ack(a), old_auth(oa), new_auth(na) { |
45 | set_tid(tid); | |
46 | } | |
f67539c2 | 47 | ~MExportDirNotify() final {} |
7c673cae FG |
48 | |
49 | public: | |
11fdf7f2 | 50 | std::string_view get_type_name() const override { return "ExNot"; } |
f67539c2 | 51 | void print(std::ostream& o) const override { |
7c673cae FG |
52 | o << "export_notify(" << base; |
53 | o << " " << old_auth << " -> " << new_auth; | |
54 | if (ack) | |
55 | o << " ack)"; | |
56 | else | |
57 | o << " no ack)"; | |
58 | } | |
59 | ||
f67539c2 | 60 | void copy_bounds(std::list<dirfrag_t>& ex) { |
7c673cae FG |
61 | this->bounds = ex; |
62 | } | |
f67539c2 TL |
63 | void copy_bounds(std::set<dirfrag_t>& ex) { |
64 | for (auto i = ex.begin(); i != ex.end(); ++i) | |
7c673cae FG |
65 | bounds.push_back(*i); |
66 | } | |
67 | ||
68 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
69 | using ceph::encode; |
70 | encode(base, payload); | |
71 | encode(ack, payload); | |
72 | encode(old_auth, payload); | |
73 | encode(new_auth, payload); | |
74 | encode(bounds, payload); | |
7c673cae FG |
75 | } |
76 | void decode_payload() override { | |
f67539c2 | 77 | using ceph::decode; |
11fdf7f2 TL |
78 | auto p = payload.cbegin(); |
79 | decode(base, p); | |
80 | decode(ack, p); | |
81 | decode(old_auth, p); | |
82 | decode(new_auth, p); | |
83 | decode(bounds, p); | |
7c673cae | 84 | } |
9f95a23c TL |
85 | private: |
86 | template<class T, typename... Args> | |
87 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
88 | }; |
89 | ||
90 | #endif |