From: Mykola Golub Date: Mon, 9 Jan 2017 17:31:21 +0000 (+0100) Subject: librbd: metadata_set API operation should not change global config setting X-Git-Tag: v11.2.1~148^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d826600ee2c1b50675a0c8642c70ad803bca02a9;p=ceph.git librbd: metadata_set API operation should not change global config setting Fixes: http://tracker.ceph.com/issues/18465 Signed-off-by: Mykola Golub (cherry picked from commit 27465b5916b55ac3c2846c74b89f4362ad17ff1e) --- diff --git a/src/librbd/Operations.cc b/src/librbd/Operations.cc index 773b58f9eabc..d85d2d9c4ea2 100644 --- a/src/librbd/Operations.cc +++ b/src/librbd/Operations.cc @@ -1342,8 +1342,9 @@ int Operations::metadata_set(const std::string &key, size_t conf_prefix_len = start.size(); if (key.size() > conf_prefix_len && !key.compare(0, conf_prefix_len, start)) { + // validate config setting string subkey = key.substr(conf_prefix_len, key.size() - conf_prefix_len); - int r = cct->_conf->set_val(subkey.c_str(), value); + int r = md_config_t().set_val(subkey.c_str(), value); if (r < 0) { return r; } diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index b162d5e92928..3f32df1dbe61 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -3943,6 +3943,11 @@ TEST_F(TestLibRBD, Metadata) ASSERT_EQ(1U, pairs.size()); ASSERT_EQ(0, strncmp("value2", pairs["key2"].c_str(), 6)); + // test config setting + ASSERT_EQ(0, image1.metadata_set("conf_rbd_cache", "false")); + ASSERT_EQ(-EINVAL, image1.metadata_set("conf_rbd_cache", "INVALID_VALUE")); + ASSERT_EQ(0, image1.metadata_remove("conf_rbd_cache")); + // test metadata with snapshot adding ASSERT_EQ(0, image1.snap_create("snap1")); ASSERT_EQ(0, image1.snap_protect("snap1"));