]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add client_metadata option to override metadata 6179/head
authorJohn Spray <john.spray@redhat.com>
Fri, 27 Nov 2015 13:45:29 +0000 (13:45 +0000)
committerJohn Spray <john.spray@redhat.com>
Tue, 5 Jan 2016 19:04:58 +0000 (19:04 +0000)
...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 <john.spray@redhat.com>
src/client/Client.cc
src/common/config_opts.h

index 7b41772d1ea545fd134b1ae95dd39df75d53db20..5307b4a8cc94c76594c21b1347e8f85708b3ab9a 100644 (file)
@@ -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<std::string> 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 "<str>=<str>"
+    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);
+  }
 }
 
 /**
index 26fae376a5c05c2189f9f28528ae050666b34042..7e570d48b96e77794391b3a35d992be3f029405a 100644 (file)
@@ -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