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

mimic: mds: disallow dumping huge caches to formatter #25642

Merged
merged 1 commit into from
Jan 30, 2019
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
10 changes: 10 additions & 0 deletions src/common/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7093,6 +7093,16 @@ std::vector<Option> get_mds_options() {
Option("mds_max_retries_on_remount_failure", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(5)
.set_description("number of consecutive failed remount attempts for invalidating kernel dcache after which client would abort."),

Option("mds_dump_cache_threshold_formatter", Option::TYPE_SIZE, Option::LEVEL_DEV)
.set_default(1_G)
.set_description("threshold for cache usage to disallow \"dump cache\" operation to formatter")
.set_long_description("Disallow MDS from dumping caches to formatter via \"dump cache\" command if cache usage exceeds this threshold."),

Option("mds_dump_cache_threshold_file", Option::TYPE_SIZE, Option::LEVEL_DEV)
.set_default(0)
.set_description("threshold for cache usage to disallow \"dump cache\" operation to file")
.set_long_description("Disallow MDS from dumping caches to file via \"dump cache\" command if cache usage exceeds this threshold."),
});
}

Expand Down
26 changes: 26 additions & 0 deletions src/mds/MDCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12292,6 +12292,32 @@ int MDCache::dump_cache(Formatter *f)
int MDCache::dump_cache(std::string_view fn, Formatter *f)
{
int r = 0;

// dumping large caches may cause mds to hang or worse get killed.
// so, disallow the dump if the cache size exceeds the configured
// threshold, which is 1G for formatter and unlimited for file (note
// that this can be jacked up by the admin... and is nothing but foot
// shooting, but the option itself is for devs and hence dangerous to
// tune). TODO: remove this when fixed.
uint64_t threshold = f ?
g_conf->get_val<Option::size_t>("mds_dump_cache_threshold_formatter") :
g_conf->get_val<Option::size_t>("mds_dump_cache_threshold_file");

if (threshold && cache_size() > threshold) {
if (f) {
std::stringstream ss;
ss << "cache usage exceeds dump threshold";
f->open_object_section("result");
f->dump_string("error", ss.str());
f->close_section();
} else {
derr << "cache usage exceeds dump threshold" << dendl;
r = -EINVAL;
}
return r;
}

r = 0;
int fd = -1;

if (f) {
Expand Down
2 changes: 2 additions & 0 deletions src/mds/MDSDaemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ const char** MDSDaemon::get_tracked_conf_keys() const
"mds_cache_reservation",
"mds_health_cache_threshold",
"mds_cache_mid",
"mds_dump_cache_threshold_formatter",
"mds_dump_cache_threshold_file",
// MDBalancer
"mds_bal_fragment_dirs",
"mds_bal_fragment_interval",
Expand Down