]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MExportDirNotify.h
import 15.2.0 Octopus source
[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 "msg/Message.h"
19
20 class MExportDirNotify : public SafeMessage {
21 private:
22 static const int HEAD_VERSION = 1;
23 static const int COMPAT_VERSION = 1;
24
25 dirfrag_t base;
26 bool ack;
27 pair<__s32,__s32> old_auth, new_auth;
28 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 pair<__s32,__s32> get_old_auth() const { return old_auth; }
33 pair<__s32,__s32> get_new_auth() const { return new_auth; }
34 bool wants_ack() const { return ack; }
35 const list<dirfrag_t>& get_bounds() const { return bounds; }
36 list<dirfrag_t>& get_bounds() { return bounds; }
37
38 protected:
39 MExportDirNotify() :
40 SafeMessage{MSG_MDS_EXPORTDIRNOTIFY, HEAD_VERSION, COMPAT_VERSION} {}
41 MExportDirNotify(dirfrag_t i, uint64_t tid, bool a, pair<__s32,__s32> oa, pair<__s32,__s32> na) :
42 SafeMessage{MSG_MDS_EXPORTDIRNOTIFY, HEAD_VERSION, COMPAT_VERSION},
43 base(i), ack(a), old_auth(oa), new_auth(na) {
44 set_tid(tid);
45 }
46 ~MExportDirNotify() override {}
47
48 public:
49 std::string_view get_type_name() const override { return "ExNot"; }
50 void print(ostream& o) const override {
51 o << "export_notify(" << base;
52 o << " " << old_auth << " -> " << new_auth;
53 if (ack)
54 o << " ack)";
55 else
56 o << " no ack)";
57 }
58
59 void copy_bounds(list<dirfrag_t>& ex) {
60 this->bounds = ex;
61 }
62 void copy_bounds(set<dirfrag_t>& ex) {
63 for (set<dirfrag_t>::iterator i = ex.begin();
64 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 auto p = payload.cbegin();
78 decode(base, p);
79 decode(ack, p);
80 decode(old_auth, p);
81 decode(new_auth, p);
82 decode(bounds, p);
83 }
84 private:
85 template<class T, typename... Args>
86 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
87 };
88
89 #endif