Merge pull request #15592 from david-z/wip-fix-dump-cache

mds: explicitly output error msg for dump cache asok command

Reviewed-by: John Spray <john.spray@redhat.com>
This commit is contained in:
John Spray 2017-06-20 06:47:13 -04:00 committed by GitHub
commit 412b397dc5
3 changed files with 25 additions and 16 deletions

View File

@ -11882,26 +11882,26 @@ void MDCache::show_cache()
}
}
void MDCache::dump_cache(std::string const &file_name)
int MDCache::dump_cache(std::string const &file_name)
{
dump_cache(file_name.c_str(), NULL);
return dump_cache(file_name.c_str(), NULL);
}
void MDCache::dump_cache(Formatter *f)
int MDCache::dump_cache(Formatter *f)
{
dump_cache(NULL, f);
return dump_cache(NULL, f);
}
void MDCache::dump_cache(const string& dump_root, int depth, Formatter *f)
int MDCache::dump_cache(const string& dump_root, int depth, Formatter *f)
{
dump_cache(NULL, f, dump_root, depth);
return dump_cache(NULL, f, dump_root, depth);
}
/**
* Dump the metadata cache, either to a Formatter, if
* provided, else to a plain text file.
*/
void MDCache::dump_cache(const char *fn, Formatter *f,
int MDCache::dump_cache(const char *fn, Formatter *f,
const string& dump_root, int depth)
{
int r = 0;
@ -11921,7 +11921,7 @@ void MDCache::dump_cache(const char *fn, Formatter *f,
fd = ::open(fn, O_WRONLY|O_CREAT|O_EXCL, 0600);
if (fd < 0) {
derr << "failed to open " << fn << ": " << cpp_strerror(errno) << dendl;
return;
return errno;
}
}
@ -12023,6 +12023,7 @@ void MDCache::dump_cache(const char *fn, Formatter *f,
} else {
::close(fd);
}
return r;
}

View File

@ -1117,14 +1117,14 @@ public:
void discard_delayed_expire(CDir *dir);
protected:
void dump_cache(const char *fn, Formatter *f,
int dump_cache(const char *fn, Formatter *f,
const std::string& dump_root = "",
int depth = -1);
public:
void dump_cache() {dump_cache(NULL, NULL);}
void dump_cache(const std::string &filename);
void dump_cache(Formatter *f);
void dump_cache(const std::string& dump_root, int depth, Formatter *f);
int dump_cache() { return dump_cache(NULL, NULL); }
int dump_cache(const std::string &filename);
int dump_cache(Formatter *f);
int dump_cache(const std::string& dump_root, int depth, Formatter *f);
void dump_resolve_status(Formatter *f) const;
void dump_rejoin_status(Formatter *f) const;

View File

@ -1919,10 +1919,15 @@ bool MDSRankDispatcher::handle_asok_command(
} else if (command == "dump cache") {
Mutex::Locker l(mds_lock);
string path;
int r;
if(!cmd_getval(g_ceph_context, cmdmap, "path", path)) {
mdcache->dump_cache(f);
r = mdcache->dump_cache(f);
} else {
mdcache->dump_cache(path);
r = mdcache->dump_cache(path);
}
if (r != 0) {
ss << "Failed to dump cache: " << cpp_strerror(r);
}
} else if (command == "dump tree") {
string root;
@ -1932,7 +1937,10 @@ bool MDSRankDispatcher::handle_asok_command(
depth = -1;
{
Mutex::Locker l(mds_lock);
mdcache->dump_cache(root, depth, f);
int r = mdcache->dump_cache(root, depth, f);
if (r != 0) {
ss << "Failed to dump tree: " << cpp_strerror(r);
}
}
} else if (command == "force_readonly") {
Mutex::Locker l(mds_lock);