]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGTrim.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / messages / MOSDPGTrim.h
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_MOSDPGTRIM_H
16 #define CEPH_MOSDPGTRIM_H
17
18 #include "msg/Message.h"
19 #include "messages/MOSDPeeringOp.h"
20 #include "osd/PGPeeringEvent.h"
21
22 class MOSDPGTrim final : public MOSDPeeringOp {
23 private:
24 static constexpr int HEAD_VERSION = 2;
25 static constexpr int COMPAT_VERSION = 2;
26
27 public:
28 epoch_t epoch = 0;
29 spg_t pgid;
30 eversion_t trim_to;
31
32 epoch_t get_epoch() const { return epoch; }
33 spg_t get_spg() const {
34 return pgid;
35 }
36 epoch_t get_map_epoch() const {
37 return epoch;
38 }
39 epoch_t get_min_epoch() const {
40 return epoch;
41 }
42 PGPeeringEvent *get_event() override {
43 return new PGPeeringEvent(
44 epoch,
45 epoch,
46 MTrim(epoch, get_source().num(), pgid.shard, trim_to));
47 }
48
49 MOSDPGTrim() : MOSDPeeringOp{MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION} {}
50 MOSDPGTrim(version_t mv, spg_t p, eversion_t tt) :
51 MOSDPeeringOp{MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION},
52 epoch(mv), pgid(p), trim_to(tt) { }
53 private:
54 ~MOSDPGTrim() final {}
55
56 public:
57 std::string_view get_type_name() const override { return "pg_trim"; }
58 void inner_print(std::ostream& out) const override {
59 out << trim_to;
60 }
61
62 void encode_payload(uint64_t features) override {
63 using ceph::encode;
64 encode(epoch, payload);
65 encode(pgid.pgid, payload);
66 encode(trim_to, payload);
67 encode(pgid.shard, payload);
68 }
69 void decode_payload() override {
70 using ceph::decode;
71 auto p = payload.cbegin();
72 decode(epoch, p);
73 decode(pgid.pgid, p);
74 decode(trim_to, p);
75 decode(pgid.shard, p);
76 }
77 private:
78 template<class T, typename... Args>
79 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
80 };
81
82 #endif