]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MOSDPGPush.h
import 15.2.2 octopus source
[ceph.git] / ceph / src / messages / MOSDPGPush.h
CommitLineData
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) 2013 Inktank Storage, Inc.
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 MOSDPGPUSH_H
16#define MOSDPGPUSH_H
17
18#include "MOSDFastDispatchOp.h"
19
9f95a23c 20class MOSDPGPush : public MOSDFastDispatchOp {
11fdf7f2
TL
21private:
22 static constexpr int HEAD_VERSION = 4;
23 static constexpr int COMPAT_VERSION = 2;
7c673cae
FG
24
25public:
26 pg_shard_t from;
27 spg_t pgid;
11fdf7f2 28 epoch_t map_epoch = 0, min_epoch = 0;
7c673cae 29 vector<PushOp> pushes;
11fdf7f2 30 bool is_repair = false;
7c673cae
FG
31
32private:
9f95a23c 33 uint64_t cost = 0;
7c673cae
FG
34
35public:
36 void compute_cost(CephContext *cct) {
37 cost = 0;
38 for (vector<PushOp>::iterator i = pushes.begin();
39 i != pushes.end();
40 ++i) {
41 cost += i->cost(cct);
42 }
43 }
44
45 int get_cost() const override {
46 return cost;
47 }
48
49 epoch_t get_map_epoch() const override {
50 return map_epoch;
51 }
52 epoch_t get_min_epoch() const override {
53 return min_epoch;
54 }
55 spg_t get_spg() const override {
56 return pgid;
57 }
58
59 void set_cost(uint64_t c) {
60 cost = c;
61 }
62
63 MOSDPGPush()
9f95a23c
TL
64 : MOSDFastDispatchOp{MSG_OSD_PG_PUSH, HEAD_VERSION, COMPAT_VERSION}
65 {}
7c673cae
FG
66
67 void decode_payload() override {
11fdf7f2
TL
68 auto p = payload.cbegin();
69 decode(pgid.pgid, p);
70 decode(map_epoch, p);
71 decode(pushes, p);
72 decode(cost, p);
73 decode(pgid.shard, p);
74 decode(from, p);
7c673cae 75 if (header.version >= 3) {
11fdf7f2 76 decode(min_epoch, p);
7c673cae
FG
77 } else {
78 min_epoch = map_epoch;
79 }
11fdf7f2
TL
80 if (header.version >= 4) {
81 decode(is_repair, p);
82 } else {
83 is_repair = false;
84 }
7c673cae
FG
85 }
86
87 void encode_payload(uint64_t features) override {
11fdf7f2
TL
88 using ceph::encode;
89 encode(pgid.pgid, payload);
90 encode(map_epoch, payload);
91 encode(pushes, payload, features);
92 encode(cost, payload);
93 encode(pgid.shard, payload);
94 encode(from, payload);
95 encode(min_epoch, payload);
96 encode(is_repair, payload);
7c673cae
FG
97 }
98
11fdf7f2 99 std::string_view get_type_name() const override { return "MOSDPGPush"; }
7c673cae
FG
100
101 void print(ostream& out) const override {
102 out << "MOSDPGPush(" << pgid
103 << " " << map_epoch << "/" << min_epoch
104 << " " << pushes;
105 out << ")";
106 }
9f95a23c
TL
107
108private:
109 template<class T, typename... Args>
110 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
7c673cae
FG
111};
112
113#endif