This was almost all public.
Signed-off-by: John Spray <john.spray@redhat.com>
-void FSMap::print_summary(Formatter *f, ostream *out)
+void FSMap::print_summary(Formatter *f, ostream *out) const
{
map<mds_role_t,string> by_rank;
map<string,int> by_state;
}
void print(ostream& out) const;
- void print_summary(Formatter *f, ostream *out);
+ void print_summary(Formatter *f, ostream *out) const;
void dump(Formatter *f) const;
static void generate_test_instances(list<FSMap*>& ls);
};
WRITE_CLASS_ENCODER_FEATURES(FSMap)
-inline ostream& operator<<(ostream& out, FSMap& m) {
+inline ostream& operator<<(ostream& out, const FSMap& m) {
m.print_summary(NULL, &out);
return out;
}
return true;
}
-
-namespace {
-class C_Updated : public Context {
- MDSMonitor *mm;
- MonOpRequestRef op;
-public:
- C_Updated(MDSMonitor *a, MonOpRequestRef c) :
- mm(a), op(c) {}
- void finish(int r) {
- if (r >= 0)
- mm->_updated(op); // success
- else if (r == -ECANCELED) {
- mm->mon->no_reply(op);
- } else {
- mm->dispatch(op); // try again
- }
- }
-};
-}
-
bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
{
op->mark_mdsmon_event(__func__);
dout(7) << "prepare_beacon pending map now:" << dendl;
print_map(pending_fsmap);
- wait_for_finished_proposal(op, new C_Updated(this, op));
+ wait_for_finished_proposal(op, new FunctionContext([op, this](int r){
+ if (r >= 0)
+ _updated(op); // success
+ else if (r == -ECANCELED) {
+ mon->no_reply(op);
+ } else {
+ dispatch(op); // try again
+ }
+ }));
return true;
}
class MDSMonitor : public PaxosService {
public:
- // mds maps
- FSMap fsmap; // current
- FSMap pending_fsmap; // current + pending updates
-
- // my helpers
- void print_map(FSMap &m, int dbl=7);
- void create_new_fs(FSMap &m, const std::string &name, int metadata_pool, int data_pool);
-
- version_t get_trim_to();
+ MDSMonitor(Monitor *mn, Paxos *p, string service_name);
// service methods
void create_initial();
void encode_pending(MonitorDBStore::TransactionRef t);
// we don't require full versions; don't encode any.
virtual void encode_full(MonitorDBStore::TransactionRef t) { }
+ version_t get_trim_to();
- void update_logger();
-
- void _updated(MonOpRequestRef op);
-
bool preprocess_query(MonOpRequestRef op); // true if processed.
bool prepare_update(MonOpRequestRef op);
bool should_propose(double& delay);
void on_active();
+ void check_subs();
+ void check_sub(Subscription *sub);
+
+ const FSMap &get_pending() const { return pending_fsmap; }
+ const FSMap &get_fsmap() const { return fsmap; }
+ void dump_info(Formatter *f);
+ int print_nodes(Formatter *f);
+
+ protected:
+ // mds maps
+ FSMap fsmap; // current
+ FSMap pending_fsmap; // current + pending updates
+
+ // my helpers
+ void print_map(FSMap &m, int dbl=7);
+ void create_new_fs(FSMap &m, const std::string &name, int metadata_pool, int data_pool);
+ void update_logger();
+
+ void _updated(MonOpRequestRef op);
+
void _note_beacon(class MMDSBeacon *m);
bool preprocess_beacon(MonOpRequestRef op);
bool prepare_beacon(MonOpRequestRef op);
std::list<std::shared_ptr<FileSystemCommandHandler> > handlers;
-public:
- MDSMonitor(Monitor *mn, Paxos *p, string service_name);
-
bool maybe_promote_standby(std::shared_ptr<Filesystem> fs);
bool maybe_expand_cluster(std::shared_ptr<Filesystem> fs);
void maybe_replace_gid(mds_gid_t gid, const beacon_info_t &beacon,
bool *mds_propose, bool *osd_propose);
void tick(); // check state, take actions
- void dump_info(Formatter *f);
int dump_metadata(const string& who, Formatter *f, ostream& err);
- int print_nodes(Formatter *f);
-
- void check_subs();
- void check_sub(Subscription *sub);
-private:
MDSMap *generate_mds_map(fs_cluster_id_t fscid);
void update_metadata(mds_gid_t gid, const Metadata& metadata);
void remove_from_metadata(MonitorDBStore::TransactionRef t);
pgmon()->pg_map.print_summary(f, NULL);
f->close_section();
f->open_object_section("fsmap");
- mdsmon()->fsmap.print_summary(f, NULL);
+ mdsmon()->get_fsmap().print_summary(f, NULL);
f->close_section();
f->open_object_section("mgrmap");
ss << " monmap " << *monmap << "\n";
ss << " election epoch " << get_epoch()
<< ", quorum " << get_quorum() << " " << get_quorum_names() << "\n";
- if (mdsmon()->fsmap.filesystem_count() > 0) {
- ss << " fsmap " << mdsmon()->fsmap << "\n";
+ if (mdsmon()->get_fsmap().filesystem_count() > 0) {
+ ss << " fsmap " << mdsmon()->get_fsmap() << "\n";
}
if (mgrmon()->in_use()) {
ss << " mgr ";
const string& poolstr = osdmap.get_pool_name(pool);
// If the Pool is in use by CephFS, refuse to delete it
- FSMap const &pending_fsmap = mon->mdsmon()->pending_fsmap;
+ FSMap const &pending_fsmap = mon->mdsmon()->get_pending();
if (pending_fsmap.pool_in_use(pool)) {
*ss << "pool '" << poolstr << "' is in use by CephFS";
return -EBUSY;
const std::string &tier_pool_name = osdmap.get_pool_name(tier_pool_id);
const std::string &base_pool_name = osdmap.get_pool_name(base_pool_id);
- const FSMap &pending_fsmap = mon->mdsmon()->pending_fsmap;
+ const FSMap &pending_fsmap = mon->mdsmon()->get_pending();
if (pending_fsmap.pool_in_use(tier_pool_id)) {
*ss << "pool '" << tier_pool_name << "' is in use by CephFS";
*err = -EBUSY;
const std::string &base_pool_name = osdmap.get_pool_name(base_pool_id);
// Apply CephFS-specific checks
- const FSMap &pending_fsmap = mon->mdsmon()->pending_fsmap;
+ const FSMap &pending_fsmap = mon->mdsmon()->get_pending();
if (pending_fsmap.pool_in_use(base_pool_id)) {
if (base_pool->type != pg_pool_t::TYPE_REPLICATED) {
// If the underlying pool is erasure coded, we can't permit the