1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2017 Greg Farnum/Red Hat <gfarnum@redhat.com>
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.
16 * This service abstracts out the specific implementation providing information
17 * needed by parts of the Monitor based around PGStats. This'll make for
18 * an easier transition from the PGMonitor-based queries where we handle
19 * PGStats directly, to where we are getting information passed in from
22 * This initial implementation cheats by wrapping a PGMap so we don't need
23 * to reimplement everything in one go.
26 #ifndef CEPH_PGSTATSERVICE_H
27 #define CEPH_PGSTATSERVICE_H
29 struct creating_pgs_t;
34 virtual ~PGStatService() {}
35 // FIXME: Kill this once we rip out PGMonitor post-luminous
36 /** returns true if the underlying data is readable. Always true
37 * post-luminous, but not when we are redirecting to the PGMonitor
39 virtual bool is_readable() const { return true; }
40 virtual const pool_stat_t* get_pool_stat(int64_t poolid) const = 0;
41 virtual const osd_stat_t& get_osd_sum() const {
44 virtual const osd_stat_t *get_osd_stat(int osd) const {
47 virtual const mempool::pgmap::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const {
50 virtual float get_full_ratio() const {
53 virtual float get_nearfull_ratio() const {
56 virtual bool have_creating_pgs() const {
59 virtual bool is_creating_pg(pg_t pgid) const {
62 virtual epoch_t get_min_last_epoch_clean() const {
66 virtual bool have_full_osds() const {
69 virtual bool have_nearfull_osds() const {
73 virtual size_t get_num_pg_by_osd(int osd) const {
76 virtual ceph_statfs get_statfs(OSDMap &osd_map,
77 boost::optional<int64_t> data_pool) const = 0;
78 virtual void print_summary(Formatter *f, ostream *out) const = 0;
79 virtual void dump_info(Formatter *f) const = 0;
80 virtual void dump_fs_stats(stringstream *ss, Formatter *f, bool verbose) const = 0;
81 virtual void dump_pool_stats(const OSDMap& osdm, stringstream *ss, Formatter *f,
82 bool verbose) const = 0;
84 virtual int process_pg_command(const string& prefix,
85 const map<string,cmd_vartype>& cmdmap,
89 bufferlist *odata) const {
95 class MonPGStatService : virtual public PGStatService {
97 MonPGStatService() : PGStatService() {}
98 virtual ~MonPGStatService() {}
100 * For upgrades. If the PGMap has newer data than the monitor's new
101 * creating_pgs (scan_epoch), insert them into the passed pending_creates.
103 virtual unsigned maybe_add_creating_pgs(epoch_t scan_epoch,
104 const mempool::osdmap::map<int64_t,pg_pool_t>& pools,
105 creating_pgs_t *pending_creates) const {
110 * For upgrades. If some PGs are created before all OSDs are luminous
111 * and start sending MOSDPGCreated, we need to be sync with pgmap
114 virtual void maybe_trim_creating_pgs(creating_pgs_t *creates) const {
117 virtual int reweight_by_utilization(const OSDMap &osd_map,
121 bool by_pg, const set<int64_t> *pools,
123 mempool::osdmap::map<int32_t, uint32_t>* new_weights,
124 std::stringstream *ss,
125 std::string *out_str,
126 Formatter *f) const {