]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMDSFragmentNotify.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / messages / MMDSFragmentNotify.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 #ifndef CEPH_MMDSFRAGMENTNOTIFY_H
16 #define CEPH_MMDSFRAGMENTNOTIFY_H
17
18 #include "messages/MMDSOp.h"
19
20 class MMDSFragmentNotify final : public MMDSOp {
21 private:
22 static constexpr int HEAD_VERSION = 2;
23 static constexpr int COMPAT_VERSION = 1;
24
25 dirfrag_t base_dirfrag;
26 int8_t bits = 0;
27 bool ack_wanted = false;
28
29 public:
30 inodeno_t get_ino() const { return base_dirfrag.ino; }
31 frag_t get_basefrag() const { return base_dirfrag.frag; }
32 dirfrag_t get_base_dirfrag() const { return base_dirfrag; }
33 int get_bits() const { return bits; }
34 bool is_ack_wanted() const { return ack_wanted; }
35 void mark_ack_wanted() { ack_wanted = true; }
36
37 ceph::buffer::list basebl;
38
39 protected:
40 MMDSFragmentNotify() :
41 MMDSOp{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION} {}
42 MMDSFragmentNotify(dirfrag_t df, int b, uint64_t tid) :
43 MMDSOp{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION},
44 base_dirfrag(df), bits(b) {
45 set_tid(tid);
46 }
47 ~MMDSFragmentNotify() final {}
48
49 public:
50 std::string_view get_type_name() const override { return "fragment_notify"; }
51 void print(std::ostream& o) const override {
52 o << "fragment_notify(" << base_dirfrag << " " << (int)bits << ")";
53 }
54
55 void encode_payload(uint64_t features) override {
56 using ceph::encode;
57 encode(base_dirfrag, payload);
58 encode(bits, payload);
59 encode(basebl, payload);
60 encode(ack_wanted, payload);
61 }
62 void decode_payload() override {
63 using ceph::decode;
64 auto p = payload.cbegin();
65 decode(base_dirfrag, p);
66 decode(bits, p);
67 decode(basebl, p);
68 if (header.version >= 2)
69 decode(ack_wanted, p);
70 }
71 private:
72 template<class T, typename... Args>
73 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
74 };
75
76 #endif