]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MOSDPGRemove.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / messages / MOSDPGRemove.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_MOSDPGREMOVE_H
17#define CEPH_MOSDPGREMOVE_H
18
19#include "common/hobject.h"
20#include "msg/Message.h"
21
22
23class MOSDPGRemove : public Message {
24
25 static const int HEAD_VERSION = 3;
26 static const int COMPAT_VERSION = 2;
27
28 epoch_t epoch;
29
30 public:
31 vector<spg_t> pg_list;
32
33 epoch_t get_epoch() const { return epoch; }
34
35 MOSDPGRemove() :
36 Message(MSG_OSD_PG_REMOVE, HEAD_VERSION, COMPAT_VERSION) {}
37 MOSDPGRemove(epoch_t e, vector<spg_t>& l) :
38 Message(MSG_OSD_PG_REMOVE, HEAD_VERSION, COMPAT_VERSION) {
39 this->epoch = e;
40 pg_list.swap(l);
41 }
42private:
43 ~MOSDPGRemove() override {}
44
45public:
46 const char *get_type_name() const override { return "PGrm"; }
47
48 void encode_payload(uint64_t features) override {
49 if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
50 // for jewel+kraken
51 header.version = 2;
52 ::encode(epoch, payload);
53
54 vector<pg_t> _pg_list;
55 _pg_list.reserve(pg_list.size());
56 vector<shard_id_t> _shard_list;
57 _shard_list.reserve(pg_list.size());
58 for (auto i = pg_list.begin(); i != pg_list.end(); ++i) {
59 _pg_list.push_back(i->pgid);
60 _shard_list.push_back(i->shard);
61 }
62 ::encode(_pg_list, payload);
63 ::encode(_shard_list, payload);
64 return;
65 }
66 ::encode(epoch, payload);
67 ::encode(pg_list, payload);
68 }
69 void decode_payload() override {
70 bufferlist::iterator p = payload.begin();
71 if (header.version == 2) {
72 // jewel/kraken
73 ::decode(epoch, p);
74 vector<pg_t> _pg_list;
75 ::decode(_pg_list, p);
76
77 vector<shard_id_t> _shard_list(_pg_list.size(), shard_id_t::NO_SHARD);
78 _shard_list.clear();
79 ::decode(_shard_list, p);
80 assert(_shard_list.size() == _pg_list.size());
81 pg_list.reserve(_shard_list.size());
82 for (unsigned i = 0; i < _shard_list.size(); ++i) {
83 pg_list.push_back(spg_t(_pg_list[i], _shard_list[i]));
84 }
85 return;
86 }
87 ::decode(epoch, p);
88 ::decode(pg_list, p);
89 }
90 void print(ostream& out) const override {
91 out << "osd pg remove(" << "epoch " << epoch << "; ";
92 for (vector<spg_t>::const_iterator i = pg_list.begin();
93 i != pg_list.end();
94 ++i) {
95 out << "pg" << *i << "; ";
96 }
97 out << ")";
98 }
99};
100
101#endif