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
21 class MPoolOp : public PaxosServiceMessage {
22 private:
23 static constexpr int HEAD_VERSION = 4;
24 static constexpr int COMPAT_VERSION = 2;
25
26 public:
27 uuid_d fsid;
28 __u32 pool = 0;
29 std::string name;
30 __u32 op = 0;
31 snapid_t snapid;
32 __s16 crush_rule = 0;
33
34 MPoolOp()
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},
38 fsid(f), pool(p), name(n), op(o),
39 snapid(0), crush_rule(0) {
40 set_tid(t);
41 }
42
43 private:
44 ~MPoolOp() override {}
45
46 public:
47 std::string_view get_type_name() const override { return "poolop"; }
48 void print(std::ostream& out) const override {
49 out << "pool_op(" << ceph_pool_op_name(op) << " pool " << pool
50 << " tid " << get_tid()
51 << " name " << name
52 << " v" << version << ")";
53 }
54
55 void encode_payload(uint64_t features) override {
56 using ceph::encode;
57 paxos_encode();
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);
64 __u8 pad = 0;
(2) Event overrun-buffer-val: |
Overrunning buffer pointed to by "pad" of 1 bytes by passing it to a function which accesses it at byte offset 7. [details] |
Also see events: |
[assignment] |
65 encode(pad, payload); /* for v3->v4 encoding change */
66 encode(crush_rule, payload);
67 }
68 void decode_payload() override {
69 using ceph::decode;
70 auto p = payload.cbegin();
71 paxos_decode(p);
72 decode(fsid, p);
73 decode(pool, p);
74 if (header.version < 2)
75 decode(name, p);
76 decode(op, p);
77 uint64_t old_auid;
78 decode(old_auid, p);
79 decode(snapid, p);
80 if (header.version >= 2)
81 decode(name, p);
82
83 if (header.version >= 3) {
84 __u8 pad;
85 decode(pad, p);
86 if (header.version >= 4)
87 decode(crush_rule, p);
88 else
89 crush_rule = pad;
90 } else
91 crush_rule = -1;
92 }
93 private:
94 template<class T, typename... Args>
95 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
96 };
97
98 #endif
99