From d7d52d5d603537bca79b74741eb177075a88904f Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 23 Dec 2019 10:46:09 -0500 Subject: [PATCH] librbd: remove pool objects when removing a namespace 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 (cherry picked from commit 9e29914a6a9581ea8b41f3d3efd61f254fafeeff) Conflicts: src/librbd/api/Namespace.cc - "r = Mirror::mode_set(ns_ctx, RBD_MIRROR_MODE_DISABLED)" block is missing in nautilus --- src/librbd/api/Namespace.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/librbd/api/Namespace.cc b/src/librbd/api/Namespace.cc index 282744e5b9e31..ed7f8e284fe8f 100644 --- a/src/librbd/api/Namespace.cc +++ b/src/librbd/api/Namespace.cc @@ -13,6 +13,20 @@ namespace librbd { namespace api { +namespace { + +const std::list POOL_OBJECTS { + RBD_CHILDREN, + RBD_GROUP_DIRECTORY, + RBD_INFO, + RBD_MIRRORING, + RBD_TASK, + RBD_TRASH, + RBD_DIRECTORY +}; + +} // anonymous namespace + template int Namespace::create(librados::IoCtx& io_ctx, const std::string& name) { @@ -117,6 +131,15 @@ int Namespace::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; -- 2.39.5