|
| 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) 2024 IBM, Red Hat |
| 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 | +#pragma once |
| 16 | + |
| 17 | + |
| 18 | +#include "MOSDFastDispatchOp.h" |
| 19 | + |
| 20 | +class MOSDPGPCT final : public MOSDFastDispatchOp { |
| 21 | +private: |
| 22 | + static constexpr int HEAD_VERSION = 1; |
| 23 | + static constexpr int COMPAT_VERSION = 1; |
| 24 | + |
| 25 | +public: |
| 26 | + /// epoch at which the message was sent |
| 27 | + epoch_t map_epoch = 0; |
| 28 | + |
| 29 | + /// start epoch of the interval in which the message was sent |
| 30 | + epoch_t min_epoch = 0; |
| 31 | + |
| 32 | + /// target pg |
| 33 | + spg_t pgid; |
| 34 | + |
| 35 | + /** |
| 36 | + * pg_committed_to |
| 37 | + * |
| 38 | + * Propagates PeeringState::pg_committed_to to replicas as with |
| 39 | + * MOSDRepOp, ECSubWrite, MOSDPGPCT. |
| 40 | + */ |
| 41 | + eversion_t pg_committed_to; |
| 42 | + |
| 43 | + epoch_t get_map_epoch() const override { |
| 44 | + return map_epoch; |
| 45 | + } |
| 46 | + epoch_t get_min_epoch() const override { |
| 47 | + return min_epoch; |
| 48 | + } |
| 49 | + spg_t get_spg() const override { |
| 50 | + return pgid; |
| 51 | + } |
| 52 | + |
| 53 | + MOSDPGPCT() |
| 54 | + : MOSDFastDispatchOp{MSG_OSD_PG_PCT, HEAD_VERSION, |
| 55 | + COMPAT_VERSION} {} |
| 56 | + MOSDPGPCT( |
| 57 | + spg_t pgid, |
| 58 | + epoch_t epoch, |
| 59 | + epoch_t min_epoch, |
| 60 | + eversion_t pg_committed_to) |
| 61 | + : MOSDFastDispatchOp{MSG_OSD_PG_PCT, HEAD_VERSION, |
| 62 | + COMPAT_VERSION}, |
| 63 | + map_epoch(epoch), |
| 64 | + min_epoch(min_epoch), |
| 65 | + pgid(pgid), |
| 66 | + pg_committed_to(pg_committed_to) |
| 67 | + {} |
| 68 | + |
| 69 | +private: |
| 70 | + ~MOSDPGPCT() final {} |
| 71 | + |
| 72 | +public: |
| 73 | + std::string_view get_type_name() const override { return "PGPCT"; } |
| 74 | + void print(std::ostream& out) const override { |
| 75 | + out << "pg_pct(" << pgid << " epoch " << map_epoch |
| 76 | + << "/" << min_epoch |
| 77 | + << " pg_committed_to " << pg_committed_to |
| 78 | + << ")"; |
| 79 | + } |
| 80 | + |
| 81 | + void encode_payload(uint64_t features) override { |
| 82 | + using ceph::encode; |
| 83 | + encode(map_epoch, payload); |
| 84 | + encode(min_epoch, payload); |
| 85 | + encode(pgid, payload); |
| 86 | + encode(pg_committed_to, payload); |
| 87 | + } |
| 88 | + void decode_payload() override { |
| 89 | + using ceph::decode; |
| 90 | + auto p = payload.cbegin(); |
| 91 | + decode(map_epoch, p); |
| 92 | + decode(min_epoch, p); |
| 93 | + decode(pgid, p); |
| 94 | + decode(pg_committed_to, p); |
| 95 | + } |
| 96 | +private: |
| 97 | + template<class T, typename... Args> |
| 98 | + friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); |
| 99 | +}; |
0 commit comments