]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: update hidden global config when removing pool config override 38831/head
authorJason Dillaman <dillaman@redhat.com>
Sat, 7 Nov 2020 15:09:32 +0000 (10:09 -0500)
committerNathan Cutler <ncutler@suse.com>
Fri, 8 Jan 2021 18:35:35 +0000 (19:35 +0100)
The remove notification was missed and therefore in-use images will not
properly remove pool config overrides.

Fixes: https://tracker.ceph.com/issues/48145
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 4ca1c4912b52d6a7945decd443ddcaf3533dcdf9)

src/librbd/api/PoolMetadata.cc

index 0a3c5ca61309b2c2d12761ade86f790cf02d06e8..f3d539445de02121efc20356199eaaba55d964aa 100644 (file)
 namespace librbd {
 namespace api {
 
+namespace {
+
+void update_pool_timestamp(librados::IoCtx& io_ctx) {
+  CephContext *cct = (CephContext *)io_ctx.cct();
+
+  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;
+  int 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;
+  }
+}
+
+} // anonymous namespace
+
 template <typename I>
 int PoolMetadata<I>::get(librados::IoCtx& io_ctx,
                      const std::string &key, std::string *value) {
@@ -34,7 +60,7 @@ 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;
+  bool need_update_pool_timestamp = false;
 
   std::string config_key;
   if (util::is_metadata_config_override(key, &config_key)) {
@@ -50,7 +76,7 @@ int PoolMetadata<I>::set(librados::IoCtx& io_ctx, const std::string &key,
       return -EINVAL;
     }
 
-    update_pool_timestamp = true;
+    need_update_pool_timestamp = true;
   }
 
   ceph::bufferlist bl;
@@ -63,24 +89,8 @@ 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;
-    }
+  if (need_update_pool_timestamp) {
+    update_pool_timestamp(io_ctx);
   }
 
   return 0;
@@ -109,6 +119,11 @@ int PoolMetadata<I>::remove(librados::IoCtx& io_ctx, const std::string &key) {
     return r;
   }
 
+  std::string config_key;
+  if (util::is_metadata_config_override(key, &config_key)) {
+    update_pool_timestamp(io_ctx);
+  }
+
   return 0;
 }