1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_MOSDPGREMOVE_H
17 #define CEPH_MOSDPGREMOVE_H
19 #include "common/hobject.h"
20 #include "msg/Message.h"
23 class MOSDPGRemove : public Message {
25 static const int HEAD_VERSION = 3;
26 static const int COMPAT_VERSION = 2;
31 vector<spg_t> pg_list;
33 epoch_t get_epoch() const { return epoch; }
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) {
43 ~MOSDPGRemove() override {}
46 const char *get_type_name() const override { return "PGrm"; }
48 void encode_payload(uint64_t features) override {
49 if (HAVE_FEATURE(features, SERVER_LUMINOUS)) {
50 header.version = HEAD_VERSION;
54 ::encode(epoch, payload);
56 vector<pg_t> _pg_list;
57 _pg_list.reserve(pg_list.size());
58 vector<shard_id_t> _shard_list;
59 _shard_list.reserve(pg_list.size());
60 for (auto i = pg_list.begin(); i != pg_list.end(); ++i) {
61 _pg_list.push_back(i->pgid);
62 _shard_list.push_back(i->shard);
64 ::encode(_pg_list, payload);
65 ::encode(_shard_list, payload);
68 ::encode(epoch, payload);
69 ::encode(pg_list, payload);
71 void decode_payload() override {
72 bufferlist::iterator p = payload.begin();
73 if (header.version == 2) {
76 vector<pg_t> _pg_list;
77 ::decode(_pg_list, p);
79 vector<shard_id_t> _shard_list(_pg_list.size(), shard_id_t::NO_SHARD);
81 ::decode(_shard_list, p);
82 assert(_shard_list.size() == _pg_list.size());
83 pg_list.reserve(_shard_list.size());
84 for (unsigned i = 0; i < _shard_list.size(); ++i) {
85 pg_list.push_back(spg_t(_pg_list[i], _shard_list[i]));
92 void print(ostream& out) const override {
93 out << "osd pg remove(" << "epoch " << epoch << "; ";
94 for (vector<spg_t>::const_iterator i = pg_list.begin();
97 out << "pg" << *i << "; ";