]>
Commit | Line | Data |
---|---|---|
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 | #ifndef CEPH_MOSDPGTRIM_H | |
16 | #define CEPH_MOSDPGTRIM_H | |
17 | ||
18 | #include "msg/Message.h" | |
11fdf7f2 | 19 | #include "messages/MOSDPeeringOp.h" |
9f95a23c | 20 | #include "osd/PGPeeringEvent.h" |
7c673cae | 21 | |
f67539c2 | 22 | class MOSDPGTrim final : public MOSDPeeringOp { |
11fdf7f2 TL |
23 | private: |
24 | static constexpr int HEAD_VERSION = 2; | |
25 | static constexpr int COMPAT_VERSION = 2; | |
7c673cae FG |
26 | |
27 | public: | |
d2e6a577 | 28 | epoch_t epoch = 0; |
7c673cae FG |
29 | spg_t pgid; |
30 | eversion_t trim_to; | |
31 | ||
32 | epoch_t get_epoch() const { return epoch; } | |
11fdf7f2 TL |
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 | } | |
7c673cae | 48 | |
9f95a23c | 49 | MOSDPGTrim() : MOSDPeeringOp{MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION} {} |
7c673cae | 50 | MOSDPGTrim(version_t mv, spg_t p, eversion_t tt) : |
9f95a23c | 51 | MOSDPeeringOp{MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
52 | epoch(mv), pgid(p), trim_to(tt) { } |
53 | private: | |
f67539c2 | 54 | ~MOSDPGTrim() final {} |
7c673cae FG |
55 | |
56 | public: | |
11fdf7f2 | 57 | std::string_view get_type_name() const override { return "pg_trim"; } |
f67539c2 | 58 | void inner_print(std::ostream& out) const override { |
11fdf7f2 | 59 | out << trim_to; |
7c673cae FG |
60 | } |
61 | ||
62 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
63 | using ceph::encode; |
64 | encode(epoch, payload); | |
65 | encode(pgid.pgid, payload); | |
66 | encode(trim_to, payload); | |
67 | encode(pgid.shard, payload); | |
7c673cae FG |
68 | } |
69 | void decode_payload() override { | |
f67539c2 | 70 | using ceph::decode; |
11fdf7f2 TL |
71 | auto p = payload.cbegin(); |
72 | decode(epoch, p); | |
73 | decode(pgid.pgid, p); | |
74 | decode(trim_to, p); | |
75 | decode(pgid.shard, p); | |
7c673cae | 76 | } |
9f95a23c TL |
77 | private: |
78 | template<class T, typename... Args> | |
79 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
80 | }; |
81 | ||
82 | #endif |