}
}
-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;
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;
}
}
} else {
::close(fd);
}
+ return r;
}
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;
} 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;
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);