]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: update hidden global config when setting pool config override 36725/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2020 01:14:18 +0000 (21:14 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 19 Aug 2020 20:23:53 +0000 (16:23 -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>
(cherry picked from commit f45df9fe786e8057c491c082e840483759d67e9e)

Conflicts:
src/common/options.cc
- "rbd_quiesce_notification_attempts", "rbd_default_snapshot_quiesce_mode", and
  "rbd_plugins" options have not been backported to Octopus, yet

(cherry picked from commit ea2dec49276c5ea79980d184d97b6a410ee1dec5)

Conflicts:
src/common/options.cc: trivial resolution

src/common/options.cc
src/librbd/api/Config.cc
src/librbd/api/PoolMetadata.cc
src/test/librados_test_stub/TestRadosClient.cc

index af30d23f156921c4c1a7208107dd4d21374c2782..ff97bd5d0db3d1ccb7f37c534c3e57f5a00766b9 100644 (file)
@@ -7586,6 +7586,12 @@ static std::vector<Option> get_rbd_options() {
     .set_default(60)
     .set_min(0)
     .set_description("RBD Image access timestamp refresh interval. Set to 0 to disable access timestamp update."),
+
+    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 21d8c0ed3315f5aa7e79d8a3d8b1dc9b049f48f4..08be9d2c3594f78f9e7cff27f7fb7ab1c6d86cd9 100644 (file)
@@ -34,7 +34,8 @@ static std::set<std::string> 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> EXCLUDE_IMAGE_OPTIONS {
     "rbd_default_clone_format",
index 2f65e0ad9b02f6cf1b4fa4ec00ddbb97a9622c56..0a3c5ca61309b2c2d12761ade86f790cf02d06e8 100644 (file)
@@ -34,6 +34,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)) {
@@ -47,6 +49,8 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
                  << dendl;
       return -EINVAL;
     }
+
+    update_pool_timestamp = true;
   }
 
   ceph::bufferlist bl;
@@ -59,6 +63,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 fcd5099af28171dbf2d81b17fb6f119ab869c194..d8a4248e8f59782b251c8751b51e6d9114ed74d9 100644 (file)
@@ -169,6 +169,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": [)";