]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MExportDirNotify.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / messages / MExportDirNotify.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 #ifndef CEPH_MEXPORTDIRNOTIFY_H
16 #define CEPH_MEXPORTDIRNOTIFY_H
17
18 #include "messages/MMDSOp.h"
19
20 class MExportDirNotify final : public MMDSOp {
21 private:
22 static constexpr int HEAD_VERSION = 1;
23 static constexpr int COMPAT_VERSION = 1;
24
25 dirfrag_t base;
26 bool ack;
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)
29
30 public:
31 dirfrag_t get_dirfrag() const { return base; }
32 std::pair<__s32,__s32> get_old_auth() const { return old_auth; }
33 std::pair<__s32,__s32> get_new_auth() const { return new_auth; }
34 bool wants_ack() const { return ack; }
35 const std::list<dirfrag_t>& get_bounds() const { return bounds; }
36 std::list<dirfrag_t>& get_bounds() { return bounds; }
37
38 protected:
39 MExportDirNotify() :
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},
44 base(i), ack(a), old_auth(oa), new_auth(na) {
45 set_tid(tid);
46 }
47 ~MExportDirNotify() final {}
48
49 public:
50 std::string_view get_type_name() const override { return "ExNot"; }
51 void print(std::ostream& o) const override {
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
60 void copy_bounds(std::list<dirfrag_t>& ex) {
61 this->bounds = ex;
62 }
63 void copy_bounds(std::set<dirfrag_t>& ex) {
64 for (auto i = ex.begin(); i != ex.end(); ++i)
65 bounds.push_back(*i);
66 }
67
68 void encode_payload(uint64_t features) override {
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);
75 }
76 void decode_payload() override {
77 using ceph::decode;
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);
84 }
85 private:
86 template<class T, typename... Args>
87 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
88 template<class T, typename... Args>
89 friend MURef<T> crimson::make_message(Args&&... args);
90 };
91
92 #endif