list all the opening files with the corresponding clients and their caps.
Signed-off-by: dongdong tao <tdd21151186@gmail.com>
}
}
-
+void MDCache::dump_openfiles(Formatter *f)
+{
+ f->open_array_section("openfiles");
+ for (auto p = mds->mdlog->segments.begin();
+ p != mds->mdlog->segments.end();
+ ++p) {
+ LogSegment *ls = p->second;
+
+ auto q = ls->open_files.begin(member_offset(CInode, item_open_file));
+ while (!q.end()) {
+ CInode *in = *q;
+ ++q;
+ if ((in->last == CEPH_NOSNAP && !in->is_any_caps_wanted())
+ || (in->last != CEPH_NOSNAP && in->client_snap_caps.empty()))
+ continue;
+ std::string path;
+ in->make_path_string(path, true);
+ if (path.empty())
+ path = "/"
+ f->open_object_section("file");
+ f->dump_string("path", path);
+ in->dump(f);
+ f->close_section();
+ }
+ }
+ f->close_section();
+}
Capability* MDCache::rejoin_import_cap(CInode *in, client_t client, const cap_reconnect_t& icr, mds_rank_t frommds)
{
void clean_open_file_lists();
-
+ void dump_openfiles(Formatter *f);
protected:
// [rejoin]
bool rejoins_pending;
int dump_cache(const std::string &filename);
int dump_cache(Formatter *f);
int dump_cache(const std::string& dump_root, int depth, Formatter *f);
-
+
int cache_status(Formatter *f);
void dump_resolve_status(Formatter *f) const;
return segments[seq];
return NULL;
}
+
+ const std::map<uint64_t,LogSegment*> &get_segments() {
+ return segments;
+ }
bool have_any_segments() const {
return !segments.empty();
asok_hook,
"List fragments in directory");
assert(r == 0);
+ r = admin_socket->register_command("openfiles ls",
+ "openfiles ls",
+ asok_hook,
+ "List the opening files and their caps");
+ assert(r == 0);
}
void MDSDaemon::clean_up_admin_socket()
admin_socket->unregister_command("dirfrag split");
admin_socket->unregister_command("dirfrag merge");
admin_socket->unregister_command("dirfrag ls");
+ admin_socket->unregister_command("openfiles ls");
delete asok_hook;
asok_hook = NULL;
}
command_dirfrag_merge(cmdmap, ss);
} else if (command == "dirfrag ls") {
command_dirfrag_ls(cmdmap, ss, f);
+ } else if (command == "openfiles ls") {
+ command_openfiles_ls(f);
} else {
return false;
}
return true;
}
+void MDSRank::command_openfiles_ls(Formatter *f)
+{
+ Mutex::Locker l(mds_lock);
+ mdcache->dump_openfiles(f);
+}
+
void MDSRank::dump_status(Formatter *f) const
{
if (state == MDSMap::STATE_REPLAY ||
CDir *_command_dirfrag_get(
const cmdmap_t &cmdmap,
std::ostream &ss);
+ void command_openfiles_ls(Formatter *f);
protected:
Messenger *messenger;