]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MExportDirPrep.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MExportDirPrep.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
16 #ifndef CEPH_MEXPORTDIRPREP_H
17 #define CEPH_MEXPORTDIRPREP_H
18
19 #include "msg/Message.h"
20 #include "include/types.h"
21
22 class MExportDirPrep : public SafeMessage {
23 private:
24 static const int HEAD_VERSION = 1;
25 static const int COMPAT_VERSION = 1;
26
27 dirfrag_t dirfrag;
28 public:
29 bufferlist basedir;
30 list<dirfrag_t> bounds;
31 list<bufferlist> traces;
32 private:
33 set<mds_rank_t> bystanders;
34 bool b_did_assim = false;
35
36 public:
37 dirfrag_t get_dirfrag() const { return dirfrag; }
38 const list<dirfrag_t>& get_bounds() const { return bounds; }
39 const set<mds_rank_t> &get_bystanders() const { return bystanders; }
40
41 bool did_assim() const { return b_did_assim; }
42 void mark_assim() { b_did_assim = true; }
43
44 protected:
45 MExportDirPrep() = default;
46 MExportDirPrep(dirfrag_t df, uint64_t tid) :
47 SafeMessage{MSG_MDS_EXPORTDIRPREP, HEAD_VERSION, COMPAT_VERSION},
48 dirfrag(df)
49 {
50 set_tid(tid);
51 }
52 ~MExportDirPrep() override {}
53
54 public:
55 std::string_view get_type_name() const override { return "ExP"; }
56 void print(ostream& o) const override {
57 o << "export_prep(" << dirfrag << ")";
58 }
59
60 void add_bound(dirfrag_t df) {
61 bounds.push_back( df );
62 }
63 void add_trace(bufferlist& bl) {
64 traces.push_back(bl);
65 }
66 void add_bystander(mds_rank_t who) {
67 bystanders.insert(who);
68 }
69
70 void decode_payload() override {
71 using ceph::decode;
72 auto p = payload.cbegin();
73 decode(dirfrag, p);
74 decode(basedir, p);
75 decode(bounds, p);
76 decode(traces, p);
77 decode(bystanders, p);
78 }
79
80 void encode_payload(uint64_t features) override {
81 using ceph::encode;
82 encode(dirfrag, payload);
83 encode(basedir, payload);
84 encode(bounds, payload);
85 encode(traces, payload);
86 encode(bystanders, payload);
87 }
88 private:
89 template<class T, typename... Args>
90 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
91 };
92
93 #endif