]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: remove pool objects when removing a namespace 32401/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 23 Dec 2019 15:46:09 +0000 (10:46 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 23 Dec 2019 15:46:09 +0000 (10:46 -0500)
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>
src/librbd/api/Namespace.cc

index 16dd4b81b4d206b30f7e682311e785958d2053ba..6c5ac7fda3145dc44d140f7a032202819df08c44 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)
 {
@@ -125,6 +139,15 @@ int Namespace<I>::remove(librados::IoCtx& io_ctx, const std::string& name)
     return r;
   }
 
+  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;