]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGScan.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MOSDPGScan.h
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_MOSDPGSCAN_H
16 #define CEPH_MOSDPGSCAN_H
17
18 #include "MOSDFastDispatchOp.h"
19
20 class MOSDPGScan : public MOSDFastDispatchOp {
21 private:
22 static constexpr int HEAD_VERSION = 2;
23 static constexpr int COMPAT_VERSION = 2;
24
25 public:
26 enum {
27 OP_SCAN_GET_DIGEST = 1, // just objects and versions
28 OP_SCAN_DIGEST = 2, // result
29 };
30 const char *get_op_name(int o) const {
31 switch (o) {
32 case OP_SCAN_GET_DIGEST: return "get_digest";
33 case OP_SCAN_DIGEST: return "digest";
34 default: return "???";
35 }
36 }
37
38 __u32 op = 0;
39 epoch_t map_epoch = 0, query_epoch = 0;
40 pg_shard_t from;
41 spg_t pgid;
42 hobject_t begin, end;
43
44 epoch_t get_map_epoch() const override {
45 return map_epoch;
46 }
47 epoch_t get_min_epoch() const override {
48 return query_epoch;
49 }
50 spg_t get_spg() const override {
51 return pgid;
52 }
53
54 void decode_payload() override {
55 auto p = payload.cbegin();
56 decode(op, p);
57 decode(map_epoch, p);
58 decode(query_epoch, p);
59 decode(pgid.pgid, p);
60 decode(begin, p);
61 decode(end, p);
62
63 // handle hobject_t format upgrade
64 if (!begin.is_max() && begin.pool == -1)
65 begin.pool = pgid.pool();
66 if (!end.is_max() && end.pool == -1)
67 end.pool = pgid.pool();
68
69 decode(from, p);
70 decode(pgid.shard, p);
71 }
72
73 void encode_payload(uint64_t features) override {
74 using ceph::encode;
75 encode(op, payload);
76 encode(map_epoch, payload);
77 if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
78 // pre-nautilus OSDs do not set last_peering_reset properly
79 encode(map_epoch, payload);
80 } else {
81 encode(query_epoch, payload);
82 }
83 encode(pgid.pgid, payload);
84 encode(begin, payload);
85 encode(end, payload);
86 encode(from, payload);
87 encode(pgid.shard, payload);
88 }
89
90 MOSDPGScan()
91 : MOSDFastDispatchOp{MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION} {}
92 MOSDPGScan(__u32 o, pg_shard_t from,
93 epoch_t e, epoch_t qe, spg_t p, hobject_t be, hobject_t en)
94 : MOSDFastDispatchOp{MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION},
95 op(o),
96 map_epoch(e), query_epoch(qe),
97 from(from),
98 pgid(p),
99 begin(be), end(en) {
100 }
101 private:
102 ~MOSDPGScan() override {}
103
104 public:
105 std::string_view get_type_name() const override { return "pg_scan"; }
106 void print(ostream& out) const override {
107 out << "pg_scan(" << get_op_name(op)
108 << " " << pgid
109 << " " << begin << "-" << end
110 << " e " << map_epoch << "/" << query_epoch
111 << ")";
112 }
113 private:
114 template<class T, typename... Args>
115 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
116 };
117
118 #endif