]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MDentryUnlink.h
import ceph quincy 17.2.6
[ceph.git] / ceph / src / messages / MDentryUnlink.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_MDENTRYUNLINK_H
17#define CEPH_MDENTRYUNLINK_H
18
11fdf7f2
TL
19#include <string_view>
20
f67539c2 21#include "messages/MMDSOp.h"
11fdf7f2 22
f67539c2 23class MDentryUnlink final : public MMDSOp {
11fdf7f2 24private:
39ae355f 25 static constexpr int HEAD_VERSION = 2;
f67539c2 26 static constexpr int COMPAT_VERSION = 1;
39ae355f 27
7c673cae 28 dirfrag_t dirfrag;
f67539c2 29 std::string dn;
39ae355f 30 bool unlinking = false;
7c673cae
FG
31
32 public:
11fdf7f2 33 dirfrag_t get_dirfrag() const { return dirfrag; }
f67539c2 34 const std::string& get_dn() const { return dn; }
39ae355f 35 bool is_unlinking() const { return unlinking; }
7c673cae 36
f67539c2
TL
37 ceph::buffer::list straybl;
38 ceph::buffer::list snapbl;
7c673cae 39
11fdf7f2 40protected:
7c673cae 41 MDentryUnlink() :
f67539c2 42 MMDSOp(MSG_MDS_DENTRYUNLINK, HEAD_VERSION, COMPAT_VERSION) { }
39ae355f 43 MDentryUnlink(dirfrag_t df, std::string_view n, bool u=false) :
f67539c2 44 MMDSOp(MSG_MDS_DENTRYUNLINK, HEAD_VERSION, COMPAT_VERSION),
39ae355f 45 dirfrag(df), dn(n), unlinking(u) {}
f67539c2 46 ~MDentryUnlink() final {}
7c673cae
FG
47
48public:
11fdf7f2 49 std::string_view get_type_name() const override { return "dentry_unlink";}
f67539c2 50 void print(std::ostream& o) const override {
7c673cae
FG
51 o << "dentry_unlink(" << dirfrag << " " << dn << ")";
52 }
39ae355f 53
7c673cae 54 void decode_payload() override {
f67539c2 55 using ceph::decode;
11fdf7f2
TL
56 auto p = payload.cbegin();
57 decode(dirfrag, p);
58 decode(dn, p);
59 decode(straybl, p);
39ae355f
TL
60 if (header.version >= 2)
61 decode(unlinking, p);
7c673cae
FG
62 }
63 void encode_payload(uint64_t features) override {
11fdf7f2
TL
64 using ceph::encode;
65 encode(dirfrag, payload);
66 encode(dn, payload);
67 encode(straybl, payload);
39ae355f
TL
68 encode(unlinking, payload);
69 }
70private:
71 template<class T, typename... Args>
72 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
73 template<class T, typename... Args>
74 friend MURef<T> crimson::make_message(Args&&... args);
75};
76
77class MDentryUnlinkAck final : public MMDSOp {
78private:
79 static constexpr int HEAD_VERSION = 1;
80 static constexpr int COMPAT_VERSION = 1;
81
82 dirfrag_t dirfrag;
83 std::string dn;
84
85 public:
86 dirfrag_t get_dirfrag() const { return dirfrag; }
87 const std::string& get_dn() const { return dn; }
88
89protected:
90 MDentryUnlinkAck() :
91 MMDSOp(MSG_MDS_DENTRYUNLINK_ACK, HEAD_VERSION, COMPAT_VERSION) { }
92 MDentryUnlinkAck(dirfrag_t df, std::string_view n) :
93 MMDSOp(MSG_MDS_DENTRYUNLINK_ACK, HEAD_VERSION, COMPAT_VERSION),
94 dirfrag(df), dn(n) {}
95 ~MDentryUnlinkAck() final {}
96
97public:
98 std::string_view get_type_name() const override { return "dentry_unlink_ack";}
99 void print(std::ostream& o) const override {
100 o << "dentry_unlink_ack(" << dirfrag << " " << dn << ")";
101 }
102
103 void decode_payload() override {
104 using ceph::decode;
105 auto p = payload.cbegin();
106 decode(dirfrag, p);
107 decode(dn, p);
108 }
109 void encode_payload(uint64_t features) override {
110 using ceph::encode;
111 encode(dirfrag, payload);
112 encode(dn, payload);
7c673cae 113 }
9f95a23c
TL
114private:
115 template<class T, typename... Args>
116 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
20effc67
TL
117 template<class T, typename... Args>
118 friend MURef<T> crimson::make_message(Args&&... args);
7c673cae
FG
119};
120
121#endif