]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-wnbd: update registry settings handling
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 19 Jul 2023 12:32:40 +0000 (12:32 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 1 Mar 2024 17:39:00 +0000 (17:39 +0000)
This commit will store the mapping config in the Windows registry
only after initializing the mapping. This ensures that we aren't
replacing the registry settings for already mapped images.

We'll also check if the registry setting was added by us before
cleaning it up.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/tools/rbd_wnbd/rbd_mapping.cc
src/tools/rbd_wnbd/rbd_mapping.h

index b2d7cff93bc04c31f043505d3e3f13425cb38796..eaa79180929cb12323d788ae7b629fb7d696c358 100644 (file)
@@ -76,15 +76,6 @@ int RbdMapping::init()
 
   initial_image_size = info.size;
 
-  // We're storing mapping details in the registry even for non-persistent
-  // mappings. This allows us to easily retrieve mapping details such
-  // as the rbd pool or admin socket path.
-  // We're cleaning up the registry entry when the non-persistent mapping
-  // gets disconnected or when the ceph service restarts.
-  r = save_config_to_registry(&cfg);
-  if (r < 0)
-    return r;
-
   handler = new WnbdHandler(image, cfg.devpath,
                             info.size / RBD_WNBD_BLKSIZE,
                             RBD_WNBD_BLKSIZE,
@@ -102,7 +93,7 @@ void RbdMapping::shutdown()
   dout(5) << __func__ << ": removing RBD mapping: " << cfg.devpath << dendl;
 
   int r = 0;
-  if (!cfg.persistent) {
+  if (!cfg.persistent && saved_cfg_to_registry) {
     dout(5) << __func__ << ": cleaning up non-persistent mapping: "
             << cfg.devpath << dendl;
     r = remove_config_from_registry(&cfg);
@@ -161,6 +152,18 @@ int RbdMapping::start()
     return r;
   }
 
+  // We're storing mapping details in the registry even for non-persistent
+  // mappings. This allows us to easily retrieve mapping details such
+  // as the rbd pool or admin socket path.
+  // We're cleaning up the registry entry when the non-persistent mapping
+  // gets disconnected or when the ceph service restarts.
+  r = save_config_to_registry(&cfg);
+  if (r < 0) {
+    return r;
+  } else {
+    saved_cfg_to_registry = true;
+  }
+
   if (disconnect_cbk) {
     monitor_thread = std::thread([this]{
       int ret = this->wait();
index 52404ed503f297c80b5ba1cc92bb76de8cb8217b..1255880cb79378fad0b7efaa1ea6e282177790d5 100644 (file)
@@ -65,6 +65,7 @@ private:
   WnbdHandler* handler = nullptr;
   uint64_t watch_handle;
   WNBDWatchCtx* watch_ctx = nullptr;
+  bool saved_cfg_to_registry = false;
   disconnect_cbk_t disconnect_cbk;
 
   ceph::mutex shutdown_lock = ceph::make_mutex("RbdMapping::ShutdownLock");