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