]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: remove image directory object during rollback
authorRamana Raja <rraja@redhat.com>
Thu, 28 Mar 2024 20:15:44 +0000 (16:15 -0400)
committerRamana Raja <rraja@redhat.com>
Tue, 21 May 2024 18:47:24 +0000 (14:47 -0400)
... of rbd namespace creation.

During rbd namespace creation, the image directory object may leak if
the initalization of the image directory fails. Initialization of image
directory involves creation of the rbd_directory object and a state
being set in the object's omap. After creation of the object, error
can occur when setting the state in the object's omap. This would fail
the rbd namespace creation and leave behind the rbd_directory object.
So try to remove the rbd_directory object when rolling back namespace
creation.

Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit bdc50a9720276fa38d30b4f1aa23143333b861be)

src/librbd/api/Namespace.cc

index 86ed70c06acec84caa80b9330a118897dd500163..aa33a1ad9f3f6c397aaec5a1fb98740a3f1ef0d8 100644 (file)
@@ -79,7 +79,12 @@ int Namespace<I>::create(librados::IoCtx& io_ctx, const std::string& name)
   return 0;
 
 rollback:
-  int ret_val = cls_client::namespace_remove(&default_ns_ctx, name);
+  int ret_val = ns_ctx.remove(RBD_DIRECTORY);
+  if (ret_val < 0 && ret_val != -ENOENT) {
+    lderr(cct) << "failed to remove image directory: " << cpp_strerror(ret_val) << dendl;
+  }
+
+  ret_val = cls_client::namespace_remove(&default_ns_ctx, name);
   if (ret_val < 0) {
     lderr(cct) << "failed to remove namespace: " << cpp_strerror(ret_val) << dendl;
   }