Merge pull request #12915 from jcsp/wip-18361

client: populate metadata during mount

Reviewed-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
John Spray 2017-01-16 21:36:43 +00:00 committed by GitHub
commit 81356114b0
2 changed files with 13 additions and 6 deletions

View File

@ -544,8 +544,6 @@ int Client::init()
<< cpp_strerror(-ret) << dendl; << cpp_strerror(-ret) << dendl;
} }
populate_metadata();
client_lock.Lock(); client_lock.Lock();
initialized = true; initialized = true;
client_lock.Unlock(); client_lock.Unlock();
@ -1925,7 +1923,7 @@ MetaSession *Client::_get_or_open_mds_session(mds_rank_t mds)
* Populate a map of strings with client-identifying metadata, * Populate a map of strings with client-identifying metadata,
* such as the hostname. Call this once at initialization. * such as the hostname. Call this once at initialization.
*/ */
void Client::populate_metadata() void Client::populate_metadata(const std::string &mount_root)
{ {
// Hostname // Hostname
struct utsname u; struct utsname u;
@ -1943,7 +1941,9 @@ void Client::populate_metadata()
metadata["entity_id"] = cct->_conf->name.get_id(); metadata["entity_id"] = cct->_conf->name.get_id();
// Our mount position // Our mount position
metadata["root"] = cct->_conf->client_mountpoint; if (!mount_root.empty()) {
metadata["root"] = mount_root;
}
// Ceph version // Ceph version
metadata["ceph_version"] = pretty_version_to_str(); metadata["ceph_version"] = pretty_version_to_str();
@ -5499,6 +5499,12 @@ int Client::mds_command(
return -ENOENT; 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 // Send commands to targets
C_GatherBuilder gather(cct, onfinish); C_GatherBuilder gather(cct, onfinish);
for (const auto target_gid : non_laggy) { for (const auto target_gid : non_laggy) {
@ -5621,9 +5627,10 @@ int Client::mount(const std::string &mount_root, const UserPerm& perms,
} }
} }
populate_metadata(mount_root.empty() ? "/" : mount_root);
filepath fp(CEPH_INO_ROOT); filepath fp(CEPH_INO_ROOT);
if (!mount_root.empty()) { if (!mount_root.empty()) {
metadata["root"] = mount_root.c_str();
fp = filepath(mount_root.c_str()); fp = filepath(mount_root.c_str());
} }
while (true) { while (true) {

View File

@ -433,7 +433,7 @@ protected:
// Optional extra metadata about me to send to the MDS // Optional extra metadata about me to send to the MDS
std::map<std::string, std::string> metadata; std::map<std::string, std::string> metadata;
void populate_metadata(); void populate_metadata(const std::string &mount_root);
/* async block write barrier support */ /* async block write barrier support */