]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMDSScrub.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / messages / MMDSScrub.h
CommitLineData
f67539c2
TL
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_MMDSSCRUB_H
16#define CEPH_MMDSSCRUB_H
17
18#include "messages/MMDSOp.h"
19
20#include "include/types.h"
21#include "include/frag.h"
22
23class MMDSScrub : public MMDSOp {
24public:
25 static constexpr int OP_QUEUEDIR = 1;
26 static constexpr int OP_QUEUEDIR_ACK = -1;
27 static constexpr int OP_QUEUEINO = 2;
28 static constexpr int OP_QUEUEINO_ACK = -2;
29 static constexpr int OP_ABORT = 3;
30 static constexpr int OP_PAUSE = 4;
31 static constexpr int OP_RESUME = 5;
32
33 static const char *get_opname(int o) {
34 switch (o) {
35 case OP_QUEUEDIR: return "queue_dir";
36 case OP_QUEUEDIR_ACK: return "queue_dir_ack";
37 case OP_QUEUEINO: return "queue_ino";
38 case OP_QUEUEINO_ACK: return "queue_ino_ack";
39 case OP_ABORT: return "abort";
40 case OP_PAUSE: return "pause";
41 case OP_RESUME: return "resume";
42 default: ceph_abort(); return nullptr;
43 }
44 }
45
46 std::string_view get_type_name() const override { return "mds_scrub"; }
47
48 void print(std::ostream& out) const override {
49 out << "mds_scrub(" << get_opname(op) << " "
50 << ino << " " << frags << " " << tag;
51 if (is_force()) out << " force";
52 if (is_recursive()) out << " recursive";
53 if (is_repair()) out << " repair";
54 out << ")";
55 }
56 void encode_payload(uint64_t features) override {
57 using ceph::encode;
58 encode(op, payload);
59 encode(ino, payload);
60 encode(frags, payload);
61 encode(tag, payload);
62 encode(origin, payload);
63 encode(flags, payload);
64 }
65 void decode_payload() override {
66 using ceph::decode;
67 auto p = payload.cbegin();
68 decode(op, p);
69 decode(ino, p);
70 decode(frags, p);
71 decode(tag, p);
72 decode(origin, p);
73 decode(flags, p);
74 }
75 inodeno_t get_ino() const {
76 return ino;
77 }
78 const fragset_t& get_frags() const {
79 return frags;
80 }
81 const std::string& get_tag() const {
82 return tag;
83 }
84 inodeno_t get_origin() const {
85 return origin;
86 }
87 int get_op() const {
88 return op;
89 }
90 bool is_internal_tag() const {
91 return flags & FLAG_INTERNAL_TAG;
92 }
93 bool is_force() const {
94 return flags & FLAG_FORCE;
95 }
96 bool is_recursive() const {
97 return flags & FLAG_RECURSIVE;
98 }
99 bool is_repair() const {
100 return flags & FLAG_REPAIR;
101 }
102
103protected:
104 static constexpr int HEAD_VERSION = 1;
105 static constexpr int COMPAT_VERSION = 1;
106
107 MMDSScrub() : MMDSOp(MSG_MDS_SCRUB, HEAD_VERSION, COMPAT_VERSION) {}
108 MMDSScrub(int o)
109 : MMDSOp(MSG_MDS_SCRUB, HEAD_VERSION, COMPAT_VERSION), op(o) {}
110 MMDSScrub(int o, inodeno_t i, fragset_t&& _frags, std::string_view _tag,
111 inodeno_t _origin=inodeno_t(), bool internal_tag=false,
112 bool force=false, bool recursive=false, bool repair=false)
113 : MMDSOp(MSG_MDS_SCRUB, HEAD_VERSION, COMPAT_VERSION),
114 op(o), ino(i), frags(std::move(_frags)), tag(_tag), origin(_origin) {
115 if (internal_tag) flags |= FLAG_INTERNAL_TAG;
116 if (force) flags |= FLAG_FORCE;
117 if (recursive) flags |= FLAG_RECURSIVE;
118 if (repair) flags |= FLAG_REPAIR;
119 }
120
121 ~MMDSScrub() override {}
122private:
123 template<class T, typename... Args>
20effc67
TL
124 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
125 template<class T, typename... Args>
126 friend MURef<T> crimson::make_message(Args&&... args);
f67539c2
TL
127
128 static constexpr unsigned FLAG_INTERNAL_TAG = 1<<0;
129 static constexpr unsigned FLAG_FORCE = 1<<1;
130 static constexpr unsigned FLAG_RECURSIVE = 1<<2;
131 static constexpr unsigned FLAG_REPAIR = 1<<3;
132
133 int op;
134 inodeno_t ino;
135 fragset_t frags;
136 std::string tag;
137 inodeno_t origin;
138 unsigned flags = 0;
139};
140#endif // CEPH_MMDSSCRUB_H