]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGTrim.h
update sources to ceph Nautilus 14.2.1
[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
21 class MOSDPGTrim : public MessageInstance<MOSDPGTrim, MOSDPeeringOp> {
22 public:
23 friend factory;
24 private:
25 static constexpr int HEAD_VERSION = 2;
26 static constexpr int COMPAT_VERSION = 2;
27
28 public:
29 epoch_t epoch = 0;
30 spg_t pgid;
31 eversion_t trim_to;
32
33 epoch_t get_epoch() const { return epoch; }
34 spg_t get_spg() const {
35 return pgid;
36 }
37 epoch_t get_map_epoch() const {
38 return epoch;
39 }
40 epoch_t get_min_epoch() const {
41 return epoch;
42 }
43 PGPeeringEvent *get_event() override {
44 return new PGPeeringEvent(
45 epoch,
46 epoch,
47 MTrim(epoch, get_source().num(), pgid.shard, trim_to));
48 }
49
50 MOSDPGTrim() : MessageInstance(MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION) {}
51 MOSDPGTrim(version_t mv, spg_t p, eversion_t tt) :
52 MessageInstance(MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION),
53 epoch(mv), pgid(p), trim_to(tt) { }
54 private:
55 ~MOSDPGTrim() override {}
56
57 public:
58 std::string_view get_type_name() const override { return "pg_trim"; }
59 void inner_print(ostream& out) const override {
60 out << trim_to;
61 }
62
63 void encode_payload(uint64_t features) override {
64 using ceph::encode;
65 encode(epoch, payload);
66 encode(pgid.pgid, payload);
67 encode(trim_to, payload);
68 encode(pgid.shard, payload);
69 }
70 void decode_payload() override {
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 };
78
79 #endif