Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mds: add drop cache command #21566

Merged
merged 4 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions qa/tasks/cephfs/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,74 @@ def test_dump_inode(self):
info = self.fs.mds_asok(['dump', 'inode', '1'])
assert(info['path'] == "/")

def _run_drop_cache_cmd(self, timeout, use_tell):
drop_res = None
if use_tell:
mds_id = self.fs.get_lone_mds_id()
drop_res = json.loads(
self.fs.mon_manager.raw_cluster_cmd("tell", "mds.{0}".format(mds_id),
"cache", "drop", str(timeout)))
else:
drop_res = self.fs.mds_asok(["cache", "drop", str(timeout)])
return drop_res

def _drop_cache_command(self, timeout, use_tell=True):
self.mount_b.umount_wait()
ls_data = self.fs.mds_asok(['session', 'ls'])
self.assert_session_count(1, ls_data)

# create some files
self.mount_a.create_n_files("dc-dir/dc-file", 1000)
# drop cache
drop_res = self._run_drop_cache_cmd(timeout, use_tell)

self.assertTrue(drop_res['client_recall']['return_code'] == 0)
self.assertTrue(drop_res['flush_journal']['return_code'] == 0)

def _drop_cache_command_timeout(self, timeout, use_tell=True):
self.mount_b.umount_wait()
ls_data = self.fs.mds_asok(['session', 'ls'])
self.assert_session_count(1, ls_data)

# create some files
self.mount_a.create_n_files("dc-dir/dc-file-t", 1000)

# simulate client death and try drop cache
self.mount_a.kill()
drop_res = self._run_drop_cache_cmd(timeout, use_tell)

self.assertTrue(drop_res['client_recall']['return_code'] == -errno.ETIMEDOUT)
self.assertTrue(drop_res['flush_journal']['return_code'] == 0)

self.mount_a.kill_cleanup()
self.mount_a.mount()
self.mount_a.wait_until_mounted()

def test_drop_cache_command_asok(self):
"""
Basic test for checking drop cache command using admin socket.
Note that the cache size post trimming is not checked here.
"""
self._drop_cache_command(10, use_tell=False)

def test_drop_cache_command_tell(self):
"""
Basic test for checking drop cache command using tell interface.
Note that the cache size post trimming is not checked here.
"""
self._drop_cache_command(10)

def test_drop_cache_command_timeout_asok(self):
"""
Check drop cache command with non-responding client using admin
socket. Note that the cache size post trimming is not checked here.
"""
self._drop_cache_command_timeout(5, use_tell=False)

def test_drop_cache_command_timeout_tell(self):
"""
Check drop cache command with non-responding client using tell
interface. Note that the cache size post trimming is not checked
here.
"""
self._drop_cache_command_timeout(5)
5 changes: 2 additions & 3 deletions src/mds/MDCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7524,7 +7524,7 @@ void MDCache::check_memory_usage()

if (cache_toofull()) {
last_recall_state = clock::now();
mds->server->recall_client_state();
mds->server->recall_client_state(-1.0, false, nullptr);
}

// If the cache size had exceeded its limit, but we're back in bounds
Expand Down Expand Up @@ -12025,7 +12025,7 @@ void MDCache::show_cache()
show_func(p.second);
}

int MDCache::cache_status(Formatter *f)
void MDCache::cache_status(Formatter *f)
{
f->open_object_section("cache");

Expand All @@ -12034,7 +12034,6 @@ int MDCache::cache_status(Formatter *f)
f->close_section();

f->close_section();
return 0;
}

void MDCache::dump_tree(CInode *in, const int cur_depth, const int max_depth, Formatter *f)
Expand Down
2 changes: 1 addition & 1 deletion src/mds/MDCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ class MDCache {
int dump_cache(Formatter *f);
void dump_tree(CInode *in, const int cur_depth, const int max_depth, Formatter *f);

int cache_status(Formatter *f);
void cache_status(Formatter *f);

void dump_resolve_status(Formatter *f) const;
void dump_rejoin_status(Formatter *f) const;
Expand Down
12 changes: 10 additions & 2 deletions src/mds/MDSDaemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ void MDSDaemon::set_up_admin_socket()
asok_hook,
"show cache status");
ceph_assert(r == 0);
r = admin_socket->register_command("cache drop",
"cache drop name=timeout,type=CephInt,range=1",
asok_hook,
"drop cache");
ceph_assert(r == 0);
r = admin_socket->register_command("dump tree",
"dump tree "
"name=root,type=CephString,req=true "
Expand Down Expand Up @@ -696,6 +701,9 @@ COMMAND("heap " \
"name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \
"show heap usage info (available only if compiled with tcmalloc)", \
"mds", "*", "cli,rest")
COMMAND("cache drop name=timeout,type=CephInt,range=1", "trim cache and optionally "
"request client to release all caps and flush the journal", "mds",
"r", "cli,rest")
};


Expand Down Expand Up @@ -861,8 +869,8 @@ int MDSDaemon::_handle_command(
else {
bool handled;
try {
handled = mds_rank->handle_command(cmdmap, m, &r, &ds, &ss,
need_reply);
handled = mds_rank->handle_command(cmdmap, m, &r, &ds, &ss,
run_later, need_reply);
if (!handled) {
// MDSDaemon doesn't know this command
ss << "unrecognized command! " << prefix;
Expand Down
Loading