]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: remove pool objects when removing a namespace 32839/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 23 Dec 2019 15:46:09 +0000 (10:46 -0500)
committerNathan Cutler <ncutler@suse.com>
Fri, 24 Jan 2020 16:11:59 +0000 (17:11 +0100)
Avoid leaving RBD pool objects within a pool namespace that is
being deleted.

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

Conflicts:
src/librbd/api/Namespace.cc
- "r = Mirror<I>::mode_set(ns_ctx, RBD_MIRROR_MODE_DISABLED)"
  block is missing in nautilus

src/librbd/api/Namespace.cc

index 282744e5b9e317330bfcc98a1bf2b4b7c111a663..ed7f8e284fe8f51b103759d928478aaef887b175 100644 (file)
 namespace librbd {
 namespace api {
 
+namespace {
+
+const std::list<std::string> POOL_OBJECTS {
+  RBD_CHILDREN,
+  RBD_GROUP_DIRECTORY,
+  RBD_INFO,
+  RBD_MIRRORING,
+  RBD_TASK,
+  RBD_TRASH,
+  RBD_DIRECTORY
+};
+
+} // anonymous namespace
+
 template <typename I>
 int Namespace<I>::create(librados::IoCtx& io_ctx, const std::string& name)
 {
@@ -117,6 +131,15 @@ int Namespace<I>::remove(librados::IoCtx& io_ctx, const std::string& name)
     goto rollback;
   }
 
+  for (auto& oid : POOL_OBJECTS) {
+    r = ns_ctx.remove(oid);
+    if (r < 0 && r != -ENOENT) {
+      lderr(cct) << "failed to remove object '" << oid << "': "
+                 << cpp_strerror(r) << dendl;
+      return r;
+    }
+  }
+
   r = cls_client::namespace_remove(&default_ns_ctx, name);
   if (r < 0) {
     lderr(cct) << "failed to remove namespace: " << cpp_strerror(r) << dendl;