]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MDiscover.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / messages / MDiscover.h
CommitLineData
7c673cae
FG
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
7c673cae 19#include "include/filepath.h"
f67539c2 20#include "messages/MMDSOp.h"
7c673cae
FG
21
22#include <string>
23
24
f67539c2 25class MDiscover final : public MMDSOp {
11fdf7f2 26private:
9f95a23c
TL
27 static constexpr int HEAD_VERSION = 1;
28 static constexpr int COMPAT_VERSION = 1;
11fdf7f2 29
7c673cae
FG
30 inodeno_t base_ino; // 1 -> root
31 frag_t base_dir_frag;
32
33 snapid_t snapid;
34 filepath want; // ... [/]need/this/stuff
35
11fdf7f2 36 bool want_base_dir = true;
9f95a23c 37 bool path_locked = false;
7c673cae
FG
38
39 public:
11fdf7f2
TL
40 inodeno_t get_base_ino() const { return base_ino; }
41 frag_t get_base_dir_frag() const { return base_dir_frag; }
42 snapid_t get_snapid() const { return snapid; }
7c673cae 43
11fdf7f2
TL
44 const filepath& get_want() const { return want; }
45 const std::string& get_dentry(int n) const { return want[n]; }
7c673cae 46
11fdf7f2 47 bool wants_base_dir() const { return want_base_dir; }
9f95a23c 48 bool is_path_locked() const { return path_locked; }
7c673cae
FG
49
50 void set_base_dir_frag(frag_t f) { base_dir_frag = f; }
51
11fdf7f2 52protected:
f67539c2 53 MDiscover() : MMDSOp(MSG_MDS_DISCOVER, HEAD_VERSION, COMPAT_VERSION) { }
7c673cae
FG
54 MDiscover(inodeno_t base_ino_,
55 frag_t base_frag_,
56 snapid_t s,
57 filepath& want_path_,
58 bool want_base_dir_ = true,
9f95a23c 59 bool path_locked_ = false) :
f67539c2 60 MMDSOp{MSG_MDS_DISCOVER},
7c673cae
FG
61 base_ino(base_ino_),
62 base_dir_frag(base_frag_),
63 snapid(s),
64 want(want_path_),
65 want_base_dir(want_base_dir_),
9f95a23c 66 path_locked(path_locked_) { }
f67539c2 67 ~MDiscover() final {}
7c673cae
FG
68
69public:
11fdf7f2 70 std::string_view get_type_name() const override { return "Dis"; }
f67539c2 71 void print(std::ostream &out) const override {
7c673cae
FG
72 out << "discover(" << header.tid << " " << base_ino << "." << base_dir_frag
73 << " " << want << ")";
74 }
75
76 void decode_payload() override {
f67539c2 77 using ceph::decode;
11fdf7f2
TL
78 auto p = payload.cbegin();
79 decode(base_ino, p);
80 decode(base_dir_frag, p);
81 decode(snapid, p);
82 decode(want, p);
83 decode(want_base_dir, p);
9f95a23c 84 decode(path_locked, p);
7c673cae
FG
85 }
86 void encode_payload(uint64_t features) override {
11fdf7f2
TL
87 using ceph::encode;
88 encode(base_ino, payload);
89 encode(base_dir_frag, payload);
90 encode(snapid, payload);
91 encode(want, payload);
92 encode(want_base_dir, payload);
9f95a23c 93 encode(path_locked, payload);
7c673cae 94 }
9f95a23c
TL
95private:
96 template<class T, typename... Args>
97 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
20effc67
TL
98 template<class T, typename... Args>
99 friend MURef<T> crimson::make_message(Args&&... args);
7c673cae
FG
100};
101
102#endif