Skip to content

Commit

Permalink
mon: enable dump all mds metadata at once
Browse files Browse the repository at this point in the history
Same as mon and osd, leave out ID to get all.

Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 325ab80)
  • Loading branch information
John Spray authored and Abhishek Varshney committed Jun 8, 2016
1 parent f0d1169 commit a12bd5e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
2 changes: 2 additions & 0 deletions qa/workunits/cephtool/test.sh
Expand Up @@ -795,6 +795,8 @@ function test_mon_mds()
for mds_gid in $(get_mds_gids $FS_NAME) ; do
ceph mds metadata $mds_id
done
ceph mds metadata

# XXX mds fail, but how do you undo it?
mdsmapfile=$TMPDIR/mdsmap.$$
current_epoch=$(ceph mds getmap -o $mdsmapfile --no-log-to-stderr 2>&1 | grep epoch | sed 's/.*epoch //')
Expand Down
40 changes: 35 additions & 5 deletions src/mon/MDSMonitor.cc
Expand Up @@ -1017,13 +1017,43 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op)
delete p;
}
} else if (prefix == "mds metadata") {
string who;
cmd_getval(g_ceph_context, cmdmap, "who", who);
if (!f)
f.reset(Formatter::create("json-pretty"));
f->open_object_section("mds_metadata");
r = dump_metadata(who, f.get(), ss);
f->close_section();

string who;
bool all = !cmd_getval(g_ceph_context, cmdmap, "who", who);
dout(1) << "all = " << all << dendl;
if (all) {
// Dump all MDSs' metadata
const auto all_info = fsmap.get_mds_info();

f->open_array_section("mds_metadata");
for(const auto &i : all_info) {
const auto &info = i.second;

f->open_object_section("mds");
f->dump_string("name", info.name);
std::ostringstream get_err;
r = dump_metadata(info.name, f.get(), get_err);
if (r == -EINVAL || r == -ENOENT) {
// Drop error, list what metadata we do have
dout(1) << get_err.str() << dendl;
r = 0;
} else if (r != 0) {
derr << "Unexpected error reading metadata: " << cpp_strerror(r)
<< dendl;
ss << get_err.str();
break;
}
f->close_section();
}
f->close_section();
} else {
// Dump a single daemon's metadata
f->open_object_section("mds_metadata");
r = dump_metadata(who, f.get(), ss);
f->close_section();
}
f->flush(ds);
} else if (prefix == "mds getmap") {
epoch_t e;
Expand Down
2 changes: 1 addition & 1 deletion src/mon/MonCommands.h
Expand Up @@ -312,7 +312,7 @@ COMMAND("fs dump "
COMMAND("mds getmap " \
"name=epoch,type=CephInt,req=false,range=0", \
"get MDS map, optionally from epoch", "mds", "r", "cli,rest")
COMMAND("mds metadata name=who,type=CephString",
COMMAND("mds metadata name=who,type=CephString,req=false",
"fetch metadata for mds <who>",
"mds", "r", "cli,rest")
COMMAND("mds tell " \
Expand Down

0 comments on commit a12bd5e

Please sign in to comment.