]>
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) 2017 Sage Weil <sage@redhat.com> | |
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_MOSDREPSCRUBMAP_H | |
16 | #define CEPH_MOSDREPSCRUBMAP_H | |
17 | ||
18 | #include "MOSDFastDispatchOp.h" | |
19 | ||
20 | /* | |
21 | * pass a ScrubMap from a shard back to the primary | |
22 | */ | |
23 | ||
f67539c2 | 24 | class MOSDRepScrubMap final : public MOSDFastDispatchOp { |
11fdf7f2 | 25 | public: |
11fdf7f2 TL |
26 | static constexpr int HEAD_VERSION = 2; |
27 | static constexpr int COMPAT_VERSION = 1; | |
7c673cae FG |
28 | |
29 | spg_t pgid; // primary spg_t | |
30 | epoch_t map_epoch = 0; | |
31 | pg_shard_t from; // whose scrubmap this is | |
f67539c2 | 32 | ceph::buffer::list scrub_map_bl; |
28e407b8 | 33 | bool preempted = false; |
7c673cae FG |
34 | |
35 | epoch_t get_map_epoch() const override { | |
36 | return map_epoch; | |
37 | } | |
38 | spg_t get_spg() const override { | |
39 | return pgid; | |
40 | } | |
41 | ||
42 | MOSDRepScrubMap() | |
9f95a23c | 43 | : MOSDFastDispatchOp{MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION} {} |
7c673cae FG |
44 | |
45 | MOSDRepScrubMap(spg_t pgid, epoch_t map_epoch, pg_shard_t from) | |
9f95a23c | 46 | : MOSDFastDispatchOp{MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
47 | pgid(pgid), |
48 | map_epoch(map_epoch), | |
49 | from(from) {} | |
50 | ||
51 | private: | |
f67539c2 | 52 | ~MOSDRepScrubMap() final {} |
7c673cae FG |
53 | |
54 | public: | |
11fdf7f2 | 55 | std::string_view get_type_name() const override { return "rep_scrubmap"; } |
f67539c2 | 56 | void print(std::ostream& out) const override { |
7c673cae | 57 | out << "rep_scrubmap(" << pgid << " e" << map_epoch |
28e407b8 AA |
58 | << " from shard " << from |
59 | << (preempted ? " PREEMPTED":"") << ")"; | |
7c673cae FG |
60 | } |
61 | ||
11fdf7f2 TL |
62 | void encode_payload(uint64_t features) override { |
63 | using ceph::encode; | |
64 | encode(pgid, payload); | |
65 | encode(map_epoch, payload); | |
66 | encode(from, payload); | |
67 | encode(preempted, payload); | |
7c673cae | 68 | } |
11fdf7f2 | 69 | void decode_payload() override { |
f67539c2 | 70 | using ceph::decode; |
11fdf7f2 TL |
71 | auto p = payload.cbegin(); |
72 | decode(pgid, p); | |
73 | decode(map_epoch, p); | |
74 | decode(from, p); | |
28e407b8 | 75 | if (header.version >= 2) { |
11fdf7f2 | 76 | decode(preempted, p); |
28e407b8 | 77 | } |
7c673cae | 78 | } |
9f95a23c TL |
79 | private: |
80 | template<class T, typename... Args> | |
81 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
82 | }; |
83 | ||
7c673cae | 84 | #endif |