]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: populate metadata during mount 13085/head
authorJohn Spray <john.spray@redhat.com>
Fri, 13 Jan 2017 00:30:28 +0000 (00:30 +0000)
committerJohn Spray <john.spray@redhat.com>
Tue, 24 Jan 2017 14:20:06 +0000 (14:20 +0000)
This way we avoid having to over-write the "root"
metadata during mount, and any user-set overrides (such
as bad values injected by tests) will survive.

Because Client instances may also open sessions without
mounting to send commands, add a call into populate_metadata
from mds_command as well.

Fixes: http://tracker.ceph.com/issues/18361
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 1dbff09ad553f9ff07f4f4217ba7ece6c2cdc5d2)

src/client/Client.cc
src/client/Client.h

index c09af04b0c3a2f1d65ea8816cb57fe1a09d5252a..777ca9d1cc9c842508ae379cb5caa6667e7e9f52 100644 (file)
@@ -568,8 +568,6 @@ int Client::init()
               << cpp_strerror(-ret) << dendl;
   }
 
-  populate_metadata();
-
   client_lock.Lock();
   initialized = true;
   client_lock.Unlock();
@@ -1934,7 +1932,7 @@ MetaSession *Client::_get_or_open_mds_session(mds_rank_t mds)
  * Populate a map of strings with client-identifying metadata,
  * such as the hostname.  Call this once at initialization.
  */
-void Client::populate_metadata()
+void Client::populate_metadata(const std::string &mount_root)
 {
   // Hostname
   struct utsname u;
@@ -1950,7 +1948,9 @@ void Client::populate_metadata()
   metadata["entity_id"] = cct->_conf->name.get_id();
 
   // Our mount position
-  metadata["root"] = cct->_conf->client_mountpoint;
+  if (!mount_root.empty()) {
+    metadata["root"] = mount_root;
+  }
 
   // Ceph version
   metadata["ceph_version"] = pretty_version_to_str();
@@ -5449,6 +5449,12 @@ int Client::mds_command(
     return -ENOENT;
   }
 
+  if (metadata.empty()) {
+    // We are called on an unmounted client, so metadata
+    // won't be initialized yet.
+    populate_metadata("");
+  }
+
   // Send commands to targets
   C_GatherBuilder gather(cct, onfinish);
   for (const auto target_gid : non_laggy) {
@@ -5553,9 +5559,10 @@ int Client::mount(const std::string &mount_root, bool require_mds)
     }
   }
 
+  populate_metadata(mount_root.empty() ? "/" : mount_root);
+
   filepath fp(CEPH_INO_ROOT);
   if (!mount_root.empty()) {
-    metadata["root"] = mount_root.c_str();
     fp = filepath(mount_root.c_str());
   }
   while (true) {
index 7129cab15ca2b7b12a0725508df60fe17ab00ccb..51376c0e51eee52829528426a014f7c37126a8ce 100644 (file)
@@ -439,7 +439,7 @@ protected:
 
   // Optional extra metadata about me to send to the MDS
   std::map<std::string, std::string> metadata;
-  void populate_metadata();
+  void populate_metadata(const std::string &mount_root);
 
 
   /* async block write barrier support */