]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: update hidden global config when setting pool config override 36309/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2020 01:14:18 +0000 (21:14 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 29 Jul 2020 12:46:50 +0000 (08:46 -0400)
The new "dev"-level global config setting will be updated when any
pool-level config override is updated. librbd clients will detect
the new global-level config update and trigger a refresh. This avoids
the need for potentially tens of thousands of librbd clients
registering a watch on the pool metadata object or periodically polling
the pool metadata object for updates.

Fixes: https://tracker.ceph.com/issues/46694
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/common/options.cc
src/librbd/api/Config.cc
src/librbd/api/PoolMetadata.cc
src/test/librados_test_stub/TestRadosClient.cc

index d00414625f52a082644c5d76c08bccfd94828591..5c5fd48fed536ef526b9bdbcb2661bcf5b329933 100644 (file)
@@ -7639,6 +7639,11 @@ static std::vector<Option> get_rbd_options() {
     .set_default("")
     .set_description("comma-delimited list of librbd plugins to enable"),
 
+    Option("rbd_config_pool_override_update_timestamp", Option::TYPE_UINT,
+           Option::LEVEL_DEV)
+    .set_default(0)
+    .set_description("timestamp of last update to pool-level config overrides"),
+
   });
 }
 
index 174e9a588647ef5272d7d21d6e65e1e0aaebe980..07e37162b4340476b71fe98fdb8b321e1de39a22 100644 (file)
@@ -36,7 +36,8 @@ static std::set<std::string_view> EXCLUDE_OPTIONS {
     "rbd_tracing",
     "rbd_validate_names",
     "rbd_validate_pool",
-    "rbd_mirror_pool_replayers_refresh_interval"
+    "rbd_mirror_pool_replayers_refresh_interval",
+    "rbd_config_pool_override_update_timestamp"
   };
 static std::set<std::string_view> EXCLUDE_IMAGE_OPTIONS {
     "rbd_default_clone_format",
index ae3d43c69679313a99cfe423900c76aba0c4aee3..ea3d43d6e6e9141006a36037805b51413b563555 100644 (file)
@@ -36,6 +36,8 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
                          const std::string &value) {
   CephContext *cct = (CephContext *)io_ctx.cct();
 
+  bool update_pool_timestamp = false;
+
   std::string config_key;
   if (util::is_metadata_config_override(key, &config_key)) {
     if (!librbd::api::Config<I>::is_option_name(io_ctx, config_key)) {
@@ -49,6 +51,8 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
                  << dendl;
       return -EINVAL;
     }
+
+    update_pool_timestamp = true;
   }
 
   ceph::bufferlist bl;
@@ -61,6 +65,26 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
     return r;
   }
 
+  if (update_pool_timestamp) {
+    auto now = ceph_clock_now();
+    std::string cmd =
+      R"({)"
+        R"("prefix": "config set", )"
+        R"("who": "global", )"
+        R"("name": "rbd_config_pool_override_update_timestamp", )"
+        R"("value": ")" + stringify(now.sec()) + R"(")"
+      R"(})";
+
+    librados::Rados rados(io_ctx);
+    bufferlist in_bl;
+    std::string ss;
+    r = rados.mon_command(cmd, in_bl, nullptr, &ss);
+    if (r < 0) {
+      lderr(cct) << "failed to notify clients of pool config update: "
+                 << cpp_strerror(r) << dendl;
+    }
+  }
+
   return 0;
 }
 
index c426f2fcf4d64360f2541938df76b2352ef161ed..5db7dc7bb9b9a9db127ed19fd130157bd976d79a 100644 (file)
@@ -208,6 +208,8 @@ int TestRadosClient::mon_command(const std::vector<std::string>& cmd,
       return 0;
     } else if ((*j_it)->get_data() == "config-key rm") {
       return 0;
+    } else if ((*j_it)->get_data() == "config set") {
+      return 0;
     } else if ((*j_it)->get_data() == "df") {
       std::stringstream str;
       str << R"({"pools": [)";