]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MPGStats.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MPGStats.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_MPGSTATS_H
16 #define CEPH_MPGSTATS_H
17
18 #include "osd/osd_types.h"
19 #include "messages/PaxosServiceMessage.h"
20
21 class MPGStats : public PaxosServiceMessage {
22 static constexpr int HEAD_VERSION = 2;
23 static constexpr int COMPAT_VERSION = 1;
24
25 public:
26 uuid_d fsid;
27 std::map<pg_t, pg_stat_t> pg_stat;
28 osd_stat_t osd_stat;
29 std::map<int64_t, store_statfs_t> pool_stat;
30 epoch_t epoch = 0;
31
32 MPGStats() : PaxosServiceMessage{MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION} {}
33 MPGStats(const uuid_d& f, epoch_t e)
34 : PaxosServiceMessage{MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION},
35 fsid(f),
36 epoch(e)
37 {}
38
39 private:
40 ~MPGStats() override {}
41
42 public:
43 std::string_view get_type_name() const override { return "pg_stats"; }
44 void print(std::ostream& out) const override {
45 out << "pg_stats(" << pg_stat.size() << " pgs tid " << get_tid() << " v " << version << ")";
46 }
47
48 void encode_payload(uint64_t features) override {
49 using ceph::encode;
50 paxos_encode();
51 encode(fsid, payload);
52 encode(osd_stat, payload, features);
53 encode(pg_stat, payload);
54 encode(epoch, payload);
55 encode(utime_t{}, payload);
56 encode(pool_stat, payload, features);
57 }
58 void decode_payload() override {
59 using ceph::decode;
60 auto p = payload.cbegin();
61 paxos_decode(p);
62 decode(fsid, p);
63 decode(osd_stat, p);
64 if (osd_stat.num_osds == 0) {
65 // for the benefit of legacy OSDs who don't set this field
66 osd_stat.num_osds = 1;
67 }
68 decode(pg_stat, p);
69 decode(epoch, p);
70 utime_t dummy;
71 decode(dummy, p);
72 if (header.version >= 2)
73 decode(pool_stat, p);
74 }
75 };
76
77 #endif