crush->find_nonshadow_roots(roots);
root = roots.begin();
}
+ explicit Dumper(const CrushWrapper *crush_,
+ const name_map_t& weight_set_names_,
+ bool show_shadow)
+ : crush(crush_), weight_set_names(weight_set_names_) {
+ if (show_shadow) {
+ crush->find_roots(roots);
+ } else {
+ crush->find_nonshadow_roots(roots);
+ }
+ root = roots.begin();
+ }
virtual ~Dumper() {}
explicit FormattingDumper(const CrushWrapper *crush,
const name_map_t& weight_set_names)
: Dumper<Formatter>(crush, weight_set_names) {}
+ explicit FormattingDumper(const CrushWrapper *crush,
+ const name_map_t& weight_set_names,
+ bool show_shadow)
+ : Dumper<Formatter>(crush, weight_set_names, show_shadow) {}
protected:
void dump_item(const Item &qi, Formatter *f) override {
explicit CrushTreePlainDumper(const CrushWrapper *crush,
const CrushTreeDumper::name_map_t& wsnames)
: Parent(crush, wsnames) {}
+ explicit CrushTreePlainDumper(const CrushWrapper *crush,
+ const CrushTreeDumper::name_map_t& wsnames,
+ bool show_shadow)
+ : Parent(crush, wsnames, show_shadow) {}
+
void dump(TextTable *tbl) {
tbl->define_column("ID", TextTable::LEFT, TextTable::RIGHT);
const CrushTreeDumper::name_map_t& wsnames)
: Parent(crush, wsnames) {}
+ explicit CrushTreeFormattingDumper(
+ const CrushWrapper *crush,
+ const CrushTreeDumper::name_map_t& wsnames,
+ bool show_shadow)
+ : Parent(crush, wsnames, show_shadow) {}
+
void dump(Formatter *f) {
f->open_array_section("nodes");
Parent::dump(f);
void CrushWrapper::dump_tree(
- ostream *out, Formatter *f,
- const CrushTreeDumper::name_map_t& weight_set_names) const
+ ostream *out,
+ Formatter *f,
+ const CrushTreeDumper::name_map_t& weight_set_names,
+ bool show_shadow) const
{
if (out) {
TextTable tbl;
- CrushTreePlainDumper(this, weight_set_names).dump(&tbl);
+ CrushTreePlainDumper(this, weight_set_names, show_shadow).dump(&tbl);
*out << tbl;
}
if (f) {
- CrushTreeFormattingDumper(this, weight_set_names).dump(f);
+ CrushTreeFormattingDumper(this, weight_set_names, show_shadow).dump(f);
}
}
void dump_choose_args(Formatter *f) const;
void list_rules(Formatter *f) const;
void list_rules(ostream *ss) const;
- void dump_tree(ostream *out, Formatter *f,
- const CrushTreeDumper::name_map_t& ws) const;
+ void dump_tree(ostream *out,
+ Formatter *f,
+ const CrushTreeDumper::name_map_t& ws,
+ bool show_shadow = false) const;
void dump_tree(ostream *out, Formatter *f) {
dump_tree(out, f, CrushTreeDumper::name_map_t());
}
COMMAND("osd crush rule rm " \
"name=name,type=CephString,goodchars=[A-Za-z0-9-_.] ", \
"remove crush rule <name>", "osd", "rw", "cli,rest")
-COMMAND("osd crush tree",
+COMMAND("osd crush tree "
+ "name=shadow,type=CephChoices,strings=--show-shadow,req=false", \
"dump crush buckets and items in a tree view",
"osd", "r", "cli,rest")
COMMAND("osd crush class create " \
rs << "\n";
rdata.append(rs.str());
} else if (prefix == "osd crush tree") {
+ string shadow;
+ cmd_getval(g_ceph_context, cmdmap, "shadow", shadow);
+ bool show_shadow = shadow == "--show-shadow";
boost::scoped_ptr<Formatter> f(Formatter::create(format));
if (f) {
- osdmap.crush->dump_tree(nullptr, f.get(), osdmap.get_pool_names());
+ osdmap.crush->dump_tree(nullptr,
+ f.get(),
+ osdmap.get_pool_names(),
+ show_shadow);
f->flush(rdata);
} else {
ostringstream ss;
- osdmap.crush->dump_tree(&ss, nullptr, osdmap.get_pool_names());
+ osdmap.crush->dump_tree(&ss,
+ nullptr,
+ osdmap.get_pool_names(),
+ show_shadow);
rdata.append(ss.str());
}
} else if (prefix == "osd crush class ls") {