From: xinxin shu Date: Mon, 17 Aug 2015 05:14:08 +0000 (+0800) Subject: fix metadata loading error if we open an image X-Git-Tag: v9.1.0~184^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=68d47f25655273d30151e7c9679b98f32414bfce;p=ceph.git fix metadata loading error if we open an image Signed-off-by: xinxin shu --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 3e860322c991..91dddca96feb 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -819,13 +819,10 @@ public: return false; string key = it->first.substr(conf_prefix_len, it->first.size() - conf_prefix_len); - for (map::iterator cit = configs.begin(); - cit != configs.end(); ++cit) { - if (!key.compare(cit->first)) { - cit->second = true; - res->insert(make_pair(key, it->second)); - break; - } + map::iterator cit = configs.find(key); + if ( cit != configs.end()) { + cit->second = true; + res->insert(make_pair(key, it->second)); } } return true; @@ -882,20 +879,22 @@ public: pairs, &res); for (map::iterator it = res.begin(); it != res.end(); ++it) { - j = local_config_t.set_val(it->first.c_str(), it->second.c_str()); + string val(it->second.c_str(), it->second.length()); + j = local_config_t.set_val(it->first.c_str(), val); if (j < 0) { lderr(cct) << __func__ << " failed to set config " << it->first << " with value " << it->second.c_str() << ": " << j << dendl; } - break; } start = pairs.rbegin()->first; } #define ASSIGN_OPTION(config) \ do { \ - if (configs[#config]) \ + string key = "rbd_"; \ + key = key + #config; \ + if (configs[key]) \ config = local_config_t.rbd_##config; \ else \ config = cct->_conf->rbd_##config; \