Skip to content

Commit 0ef5941

Browse files
author
neeraj pratap singh
committed
mds: require filter for client/session evict command
This commit fixes the issues in client/session evict command using below solutions: (1) client evict without filter is forbidden (2) SessionFilter::parse is modified to support id=* (id=0 is not allowed) (3) Invalid id error is handled User can use client evict id=* to evict all clients. Fixes: https://tracker.ceph.com/issues/58619 Signed-off-by: Neeraj Pratap Singh <[email protected]>
1 parent 423a086 commit 0ef5941

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/mds/MDSDaemon.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,11 @@ void MDSDaemon::set_up_admin_socket()
407407
asok_hook,
408408
"List client sessions based on a filter");
409409
ceph_assert(r == 0);
410-
r = admin_socket->register_command("session evict name=filters,type=CephString,n=N,req=false",
410+
r = admin_socket->register_command("session evict name=filters,type=CephString,n=N,req=true",
411411
asok_hook,
412412
"Evict client session(s) based on a filter");
413413
ceph_assert(r == 0);
414-
r = admin_socket->register_command("client evict name=filters,type=CephString,n=N,req=false",
414+
r = admin_socket->register_command("client evict name=filters,type=CephString,n=N,req=true",
415415
asok_hook,
416416
"Evict client session(s) based on a filter");
417417
ceph_assert(r == 0);

src/mds/MDSRank.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,7 @@ void MDSRankDispatcher::evict_clients(
31153115
dout(20) << __func__ << " matched " << victims.size() << " sessions" << dendl;
31163116

31173117
if (victims.empty()) {
3118-
on_finish(0, {}, outbl);
3118+
on_finish(-ESRCH, "no hosts match", outbl);
31193119
return;
31203120
}
31213121

src/mds/SessionMap.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,13 @@ int SessionFilter::parse(
12171217
state = v;
12181218
} else if (k == "id") {
12191219
std::string err;
1220+
if (v == "*") {
1221+
// evict all clients , by default id set to 0
1222+
return 0;
1223+
} else if (v == "0") {
1224+
*ss << "Invalid value";
1225+
return -CEPHFS_EINVAL;
1226+
}
12201227
id = strict_strtoll(v.c_str(), 10, &err);
12211228
if (!err.empty()) {
12221229
*ss << err;

0 commit comments

Comments
 (0)