]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MDirUpdate.h
update sources to v12.1.1
[ceph.git] / ceph / src / messages / MDirUpdate.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_MDIRUPDATE_H
17 #define CEPH_MDIRUPDATE_H
18
19 #include "msg/Message.h"
20
21 class MDirUpdate : public Message {
22 mds_rank_t from_mds;
23 dirfrag_t dirfrag;
24 int32_t dir_rep;
25 int32_t discover;
26 compact_set<int32_t> dir_rep_by;
27 filepath path;
28 int tried_discover;
29
30 public:
31 mds_rank_t get_source_mds() const { return from_mds; }
32 dirfrag_t get_dirfrag() const { return dirfrag; }
33 int get_dir_rep() const { return dir_rep; }
34 const compact_set<int>& get_dir_rep_by() const { return dir_rep_by; }
35 bool should_discover() const { return discover > tried_discover; }
36 const filepath& get_path() const { return path; }
37
38 bool has_tried_discover() const { return tried_discover > 0; }
39 void inc_tried_discover() { ++tried_discover; }
40
41 MDirUpdate() : Message(MSG_MDS_DIRUPDATE), tried_discover(0) {}
42 MDirUpdate(mds_rank_t f,
43 dirfrag_t dirfrag,
44 int dir_rep,
45 compact_set<int>& dir_rep_by,
46 filepath& path,
47 bool discover = false) :
48 Message(MSG_MDS_DIRUPDATE), tried_discover(0) {
49 this->from_mds = f;
50 this->dirfrag = dirfrag;
51 this->dir_rep = dir_rep;
52 this->dir_rep_by = dir_rep_by;
53 this->discover = discover ? 5 : 0;
54 this->path = path;
55 }
56 private:
57 ~MDirUpdate() override {}
58
59 public:
60 const char *get_type_name() const override { return "dir_update"; }
61 void print(ostream& out) const override {
62 out << "dir_update(" << get_dirfrag() << ")";
63 }
64
65 void decode_payload() override {
66 bufferlist::iterator p = payload.begin();
67 ::decode(from_mds, p);
68 ::decode(dirfrag, p);
69 ::decode(dir_rep, p);
70 ::decode(discover, p);
71 ::decode(dir_rep_by, p);
72 ::decode(path, p);
73 }
74
75 void encode_payload(uint64_t features) override {
76 ::encode(from_mds, payload);
77 ::encode(dirfrag, payload);
78 ::encode(dir_rep, payload);
79 ::encode(discover, payload);
80 ::encode(dir_rep_by, payload);
81 ::encode(path, payload);
82 }
83 };
84
85 #endif