asok_hook,
"Enumerate connected CephFS clients");
assert(r == 0);
+ r = admin_socket->register_command("session config",
+ "session config name=client_id,type=CephInt,req=true "
+ "name=option,type=CephString,req=true "
+ "name=value,type=CephString,req=false ",
+ asok_hook,
+ "Config a CephFS client session");
+ assert(r == 0);
r = admin_socket->register_command("flush journal",
"flush journal",
asok_hook,
COMMAND("client evict " \
"name=filters,type=CephString,n=N,req=false",
"Evict client session(s)", "mds", "rw", "cli,rest")
+COMMAND("client config " \
+ "name=client_id,type=CephInt name=option,type=CephString name=value,type=CephString,req=false",
+ "Config a client session", "mds", "rw", "cli,rest")
COMMAND("damage ls",
"List detected metadata damage", "mds", "r", "cli,rest")
COMMAND("damage rm name=damage_id,type=CephInt",
ss << dss.str();
}
mds_lock.Unlock();
+ } else if (command == "session config") {
+ int64_t client_id;
+ std::string option;
+ std::string value;
+
+ cmd_getval(g_ceph_context, cmdmap, "client_id", client_id);
+ cmd_getval(g_ceph_context, cmdmap, "option", option);
+ bool got_value = cmd_getval(g_ceph_context, cmdmap, "value", value);
+
+ mds_lock.Lock();
+ std::stringstream dss;
+ int ret = config_client(client_id, !got_value, option, value, dss);
+ if (ret < 0) {
+ dout(15) << dss.str() << dendl;
+ ss << dss.str();
+ }
+ mds_lock.Unlock();
} else if (command == "scrub_path") {
string path;
vector<string> scrubop_vec;
objecter->maybe_request_map();
}
+int MDSRank::config_client(int64_t session_id, bool remove,
+ const std::string& option, const std::string& value,
+ std::stringstream& ss)
+{
+ Session *session = sessionmap.get_session(entity_name_t(CEPH_ENTITY_TYPE_CLIENT, session_id));
+ if (!session) {
+ ss << "session " << session_id << " not in sessionmap!";
+ return -ENOENT;
+ }
+
+ if (option == "timeout") {
+ if (remove) {
+ auto it = session->info.client_metadata.find("timeout");
+ if (it == session->info.client_metadata.end()) {
+ ss << "Nonexistent config: " << option;
+ return -ENODATA;
+ }
+ session->info.client_metadata.erase(it);
+ } else {
+ char *end;
+ strtoul(value.c_str(), &end, 0);
+ if (*end) {
+ ss << "Invalid config for timeout: " << value;
+ return -EINVAL;
+ }
+ session->info.client_metadata[option] = value;
+ }
+ //sessionmap._mark_dirty(session, true);
+ } else {
+ ss << "Invalid config option: " << option;
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
bool MDSRank::evict_client(int64_t session_id,
bool wait, bool blacklist, std::stringstream& err_ss,
Context *on_killed)
*need_reply = false;
return true;
+ } else if (prefix == "session config" || prefix == "client config") {
+ int64_t client_id;
+ std::string option;
+ std::string value;
+
+ cmd_getval(g_ceph_context, cmdmap, "client_id", client_id);
+ cmd_getval(g_ceph_context, cmdmap, "option", option);
+ bool got_value = cmd_getval(g_ceph_context, cmdmap, "value", value);
+
+ *r = config_client(client_id, !got_value, option, value, *ss);
+ return true;
} else if (prefix == "damage ls") {
JSONFormatter f(true);
damage_table.dump(&f);
bool evict_client(int64_t session_id, bool wait, bool blacklist,
std::stringstream& ss, Context *on_killed=nullptr);
+ int config_client(int64_t session_id, bool remove,
+ const std::string& option, const std::string& value,
+ std::stringstream& ss);
protected:
void dump_clientreplay_status(Formatter *f) const;