Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MDiscover.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_MDISCOVER_H
17 #define CEPH_MDISCOVER_H
18
19 #include "msg/Message.h"
20 #include "include/filepath.h"
21
22 #include <string>
23
24
25 class MDiscover : public Message {
26   inodeno_t       base_ino;          // 1 -> root
27   frag_t          base_dir_frag;
28
29   snapid_t        snapid;
30   filepath        want;   // ... [/]need/this/stuff
31
32   bool want_base_dir;
33   bool want_xlocked;
34
35  public:
36   inodeno_t get_base_ino() { return base_ino; }
37   frag_t    get_base_dir_frag() { return base_dir_frag; }
38   snapid_t  get_snapid() { return snapid; }
39
40   filepath& get_want() { return want; }
41   const std::string& get_dentry(int n) { return want[n]; }
42
43   bool wants_base_dir() { return want_base_dir; }
44   bool wants_xlocked() { return want_xlocked; }
45   
46   void set_base_dir_frag(frag_t f) { base_dir_frag = f; }
47
48   MDiscover() : Message(MSG_MDS_DISCOVER) { }
49   MDiscover(inodeno_t base_ino_,
50             frag_t base_frag_,
51             snapid_t s,
52             filepath& want_path_,
53             bool want_base_dir_ = true,
54             bool discover_xlocks_ = false) :
55     Message(MSG_MDS_DISCOVER),
56     base_ino(base_ino_),
57     base_dir_frag(base_frag_),
58     snapid(s),
59     want(want_path_),
60     want_base_dir(want_base_dir_),
61     want_xlocked(discover_xlocks_) { }
62 private:
63   ~MDiscover() override {}
64
65 public:
66   const char *get_type_name() const override { return "Dis"; }
67   void print(ostream &out) const override {
68     out << "discover(" << header.tid << " " << base_ino << "." << base_dir_frag
69         << " " << want << ")";
70   }
71
72   void decode_payload() override {
73     bufferlist::iterator p = payload.begin();
74     ::decode(base_ino, p);
75     ::decode(base_dir_frag, p);
76     ::decode(snapid, p);
77     ::decode(want, p);
78     ::decode(want_base_dir, p);
79     ::decode(want_xlocked, p);
80   }
81   void encode_payload(uint64_t features) override {
82     ::encode(base_ino, payload);
83     ::encode(base_dir_frag, payload);
84     ::encode(snapid, payload);
85     ::encode(want, payload);
86     ::encode(want_base_dir, payload);
87     ::encode(want_xlocked, payload);
88   }
89
90 };
91
92 #endif