]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MPoolOp.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MPoolOp.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#ifndef CEPH_MPOOLOP_H
16#define CEPH_MPOOLOP_H
17
18#include "messages/PaxosServiceMessage.h"
19
20
9f95a23c 21class MPoolOp : public PaxosServiceMessage {
11fdf7f2
TL
22private:
23 static constexpr int HEAD_VERSION = 4;
24 static constexpr int COMPAT_VERSION = 2;
7c673cae
FG
25
26public:
27 uuid_d fsid;
d2e6a577 28 __u32 pool = 0;
9f95a23c 29 std::string name;
d2e6a577 30 __u32 op = 0;
7c673cae 31 snapid_t snapid;
d2e6a577 32 __s16 crush_rule = 0;
7c673cae
FG
33
34 MPoolOp()
9f95a23c
TL
35 : PaxosServiceMessage{CEPH_MSG_POOLOP, 0, HEAD_VERSION, COMPAT_VERSION} {}
36 MPoolOp(const uuid_d& f, ceph_tid_t t, int p, std::string& n, int o, version_t v)
37 : PaxosServiceMessage{CEPH_MSG_POOLOP, v, HEAD_VERSION, COMPAT_VERSION},
7c673cae 38 fsid(f), pool(p), name(n), op(o),
11fdf7f2 39 snapid(0), crush_rule(0) {
7c673cae
FG
40 set_tid(t);
41 }
42
43private:
44 ~MPoolOp() override {}
45
46public:
11fdf7f2 47 std::string_view get_type_name() const override { return "poolop"; }
9f95a23c 48 void print(std::ostream& out) const override {
7c673cae 49 out << "pool_op(" << ceph_pool_op_name(op) << " pool " << pool
7c673cae
FG
50 << " tid " << get_tid()
51 << " name " << name
52 << " v" << version << ")";
53 }
54
55 void encode_payload(uint64_t features) override {
11fdf7f2 56 using ceph::encode;
7c673cae 57 paxos_encode();
11fdf7f2
TL
58 encode(fsid, payload);
59 encode(pool, payload);
60 encode(op, payload);
61 encode((uint64_t)0, payload);
62 encode(snapid, payload);
63 encode(name, payload);
7c673cae 64 __u8 pad = 0;
11fdf7f2
TL
65 encode(pad, payload); /* for v3->v4 encoding change */
66 encode(crush_rule, payload);
7c673cae
FG
67 }
68 void decode_payload() override {
9f95a23c 69 using ceph::decode;
11fdf7f2 70 auto p = payload.cbegin();
7c673cae 71 paxos_decode(p);
11fdf7f2
TL
72 decode(fsid, p);
73 decode(pool, p);
7c673cae 74 if (header.version < 2)
11fdf7f2
TL
75 decode(name, p);
76 decode(op, p);
77 uint64_t old_auid;
78 decode(old_auid, p);
79 decode(snapid, p);
7c673cae 80 if (header.version >= 2)
11fdf7f2 81 decode(name, p);
7c673cae
FG
82
83 if (header.version >= 3) {
84 __u8 pad;
11fdf7f2 85 decode(pad, p);
7c673cae 86 if (header.version >= 4)
11fdf7f2 87 decode(crush_rule, p);
7c673cae
FG
88 else
89 crush_rule = pad;
90 } else
91 crush_rule = -1;
92 }
9f95a23c
TL
93private:
94 template<class T, typename... Args>
95 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
7c673cae
FG
96};
97
98#endif