]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: metadata_set API operation should not change global config setting 14534/head
authorMykola Golub <mgolub@mirantis.com>
Mon, 9 Jan 2017 17:31:21 +0000 (18:31 +0100)
committerNathan Cutler <ncutler@suse.com>
Thu, 13 Apr 2017 21:00:35 +0000 (23:00 +0200)
Fixes: http://tracker.ceph.com/issues/18465
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
(cherry picked from commit 27465b5916b55ac3c2846c74b89f4362ad17ff1e)

src/librbd/Operations.cc
src/test/librbd/test_librbd.cc

index 773b58f9eabc0cce086a5d95e89c4754c8c1455a..d85d2d9c4ea2b9a5dbea12138afb3c6da9387d7e 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 b162d5e92928ba053805565e80a0ea061efa8379..3f32df1dbe616af4c7e87519604574dceb941065 100644 (file)
@@ -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"));