Skip to content

Commit

Permalink
Merge pull request #13085 from jcsp/wip-18361-jewel
Browse files Browse the repository at this point in the history
jewel: client: populate metadata during mount
  • Loading branch information
John Spray committed Jan 25, 2017
2 parents 72b24f0 + 89dcd8b commit e90396f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/client/Client.cc
Expand Up @@ -568,8 +568,6 @@ int Client::init()
<< cpp_strerror(-ret) << dendl;
}

populate_metadata();

client_lock.Lock();
initialized = true;
client_lock.Unlock();
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/Client.h
Expand Up @@ -439,7 +439,7 @@ class Client : public Dispatcher, public md_config_obs_t {

// 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 */
Expand Down

0 comments on commit e90396f

Please sign in to comment.