]>
Commit | Line | Data |
---|---|---|
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) 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 | ||
9f95a23c | 21 | class MPGStats : public PaxosServiceMessage { |
11fdf7f2 TL |
22 | static constexpr int HEAD_VERSION = 2; |
23 | static constexpr int COMPAT_VERSION = 1; | |
11fdf7f2 | 24 | |
9f95a23c | 25 | public: |
7c673cae | 26 | uuid_d fsid; |
9f95a23c | 27 | std::map<pg_t, pg_stat_t> pg_stat; |
7c673cae | 28 | osd_stat_t osd_stat; |
9f95a23c | 29 | std::map<int64_t, store_statfs_t> pool_stat; |
d2e6a577 | 30 | epoch_t epoch = 0; |
9f95a23c TL |
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}, | |
7c673cae | 35 | fsid(f), |
9f95a23c | 36 | epoch(e) |
7c673cae FG |
37 | {} |
38 | ||
39 | private: | |
40 | ~MPGStats() override {} | |
41 | ||
42 | public: | |
11fdf7f2 | 43 | std::string_view get_type_name() const override { return "pg_stats"; } |
9f95a23c | 44 | void print(std::ostream& out) const override { |
7c673cae FG |
45 | out << "pg_stats(" << pg_stat.size() << " pgs tid " << get_tid() << " v " << version << ")"; |
46 | } | |
47 | ||
48 | void encode_payload(uint64_t features) override { | |
11fdf7f2 | 49 | using ceph::encode; |
7c673cae | 50 | paxos_encode(); |
11fdf7f2 TL |
51 | encode(fsid, payload); |
52 | encode(osd_stat, payload, features); | |
53 | encode(pg_stat, payload); | |
54 | encode(epoch, payload); | |
9f95a23c | 55 | encode(utime_t{}, payload); |
11fdf7f2 | 56 | encode(pool_stat, payload, features); |
7c673cae FG |
57 | } |
58 | void decode_payload() override { | |
9f95a23c | 59 | using ceph::decode; |
11fdf7f2 | 60 | auto p = payload.cbegin(); |
7c673cae | 61 | paxos_decode(p); |
11fdf7f2 TL |
62 | decode(fsid, p); |
63 | decode(osd_stat, p); | |
81eedcae TL |
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 | } | |
11fdf7f2 TL |
68 | decode(pg_stat, p); |
69 | decode(epoch, p); | |
9f95a23c TL |
70 | utime_t dummy; |
71 | decode(dummy, p); | |
11fdf7f2 TL |
72 | if (header.version >= 2) |
73 | decode(pool_stat, p); | |
7c673cae FG |
74 | } |
75 | }; | |
76 | ||
77 | #endif |