]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MPoolOp.h
update sources to v12.1.3
[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
21class MPoolOp : public PaxosServiceMessage {
22
23 static const int HEAD_VERSION = 4;
24 static const int COMPAT_VERSION = 2;
25
26public:
27 uuid_d fsid;
d2e6a577 28 __u32 pool = 0;
7c673cae 29 string name;
d2e6a577
FG
30 __u32 op = 0;
31 uint64_t auid = 0;
7c673cae 32 snapid_t snapid;
d2e6a577 33 __s16 crush_rule = 0;
7c673cae
FG
34
35 MPoolOp()
36 : PaxosServiceMessage(CEPH_MSG_POOLOP, 0, HEAD_VERSION, COMPAT_VERSION) { }
37 MPoolOp(const uuid_d& f, ceph_tid_t t, int p, string& n, int o, version_t v)
38 : PaxosServiceMessage(CEPH_MSG_POOLOP, v, HEAD_VERSION, COMPAT_VERSION),
39 fsid(f), pool(p), name(n), op(o),
40 auid(0), snapid(0), crush_rule(0) {
41 set_tid(t);
42 }
43 MPoolOp(const uuid_d& f, ceph_tid_t t, int p, string& n,
44 int o, uint64_t uid, version_t v)
45 : PaxosServiceMessage(CEPH_MSG_POOLOP, v, HEAD_VERSION, COMPAT_VERSION),
46 fsid(f), pool(p), name(n), op(o),
47 auid(uid), snapid(0), crush_rule(0) {
48 set_tid(t);
49 }
50
51private:
52 ~MPoolOp() override {}
53
54public:
55 const char *get_type_name() const override { return "poolop"; }
56 void print(ostream& out) const override {
57 out << "pool_op(" << ceph_pool_op_name(op) << " pool " << pool
58 << " auid " << auid
59 << " tid " << get_tid()
60 << " name " << name
61 << " v" << version << ")";
62 }
63
64 void encode_payload(uint64_t features) override {
65 paxos_encode();
66 ::encode(fsid, payload);
67 ::encode(pool, payload);
68 ::encode(op, payload);
69 ::encode(auid, payload);
70 ::encode(snapid, payload);
71 ::encode(name, payload);
72 __u8 pad = 0;
73 ::encode(pad, payload); /* for v3->v4 encoding change */
74 ::encode(crush_rule, payload);
75 }
76 void decode_payload() override {
77 bufferlist::iterator p = payload.begin();
78 paxos_decode(p);
79 ::decode(fsid, p);
80 ::decode(pool, p);
81 if (header.version < 2)
82 ::decode(name, p);
83 ::decode(op, p);
84 ::decode(auid, p);
85 ::decode(snapid, p);
86 if (header.version >= 2)
87 ::decode(name, p);
88
89 if (header.version >= 3) {
90 __u8 pad;
91 ::decode(pad, p);
92 if (header.version >= 4)
93 ::decode(crush_rule, p);
94 else
95 crush_rule = pad;
96 } else
97 crush_rule = -1;
98 }
99};
100
101#endif