]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: metadata_set API operation should not change global config setting 12843/head
authorMykola Golub <mgolub@mirantis.com>
Mon, 9 Jan 2017 17:31:21 +0000 (18:31 +0100)
committerMykola Golub <mgolub@mirantis.com>
Mon, 9 Jan 2017 17:53:49 +0000 (18:53 +0100)
Fixes: http://tracker.ceph.com/issues/18465
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/librbd/Operations.cc
src/test/librbd/test_librbd.cc

index 3d4dd0d479f5378016e0f0d6e3fe9cacfc54f965..895bdad0cc50a207168eab8b7d2002c4d58f415f 100644 (file)
@@ -1342,8 +1342,9 @@ int Operations<I>::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;
     }
index 0b2e0b2128117bd99ab0c697ba63b27339e5970a..bda3cab33b42c210080505c509907e59d7400c80 100644 (file)
@@ -3946,6 +3946,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"));