From c1a0194d7db21f4a68c57d2f43d8f593fb905777 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 27 Nov 2015 13:45:29 +0000 Subject: [PATCH] client: add client_metadata option to override metadata ...in the session info sent to the MDS. We use this for testing. Users might use it for adding application-layer metadata like what HPC/Hadoop job a mount relates to. Signed-off-by: John Spray --- src/client/Client.cc | 14 ++++++++++++++ src/common/config_opts.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index 7b41772d1ea54..5307b4a8cc94c 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -82,6 +82,7 @@ using namespace std; #include "common/perf_counters.h" #include "common/admin_socket.h" #include "common/errno.h" +#include "include/str_list.h" #define dout_subsys ceph_subsys_client @@ -1862,6 +1863,19 @@ void Client::populate_metadata() // Ceph version metadata["ceph_version"] = pretty_version_to_str(); metadata["ceph_sha1"] = git_version_to_str(); + + // Apply any metadata from the user's configured overrides + std::vector tokens; + get_str_vec(cct->_conf->client_metadata, ",", tokens); + for (const auto &i : tokens) { + auto eqpos = i.find("="); + // Throw out anything that isn't of the form "=" + if (eqpos == 0 || eqpos == std::string::npos || eqpos == i.size()) { + lderr(cct) << "Invalid metadata keyval pair: '" << i << "'" << dendl; + continue; + } + metadata[i.substr(0, eqpos)] = i.substr(eqpos + 1); + } } /** diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 26fae376a5c05..7e570d48b96e7 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -366,6 +366,7 @@ OPTION(client_debug_inject_tick_delay, OPT_INT, 0) // delay the client tick for OPTION(client_max_inline_size, OPT_U64, 4096) OPTION(client_inject_release_failure, OPT_BOOL, false) // synthetic client bug for testing OPTION(client_inject_fixed_oldest_tid, OPT_BOOL, false) // synthetic client bug for testing +OPTION(client_metadata, OPT_STR, "") // note: the max amount of "in flight" dirty data is roughly (max - target) OPTION(fuse_use_invalidate_cb, OPT_BOOL, false) // use fuse 2.8+ invalidate callback to keep page cache consistent -- 2.39.5