From: Jason Dillaman Date: Mon, 23 Dec 2019 15:46:09 +0000 (-0500) Subject: librbd: remove pool objects when removing a namespace X-Git-Tag: v14.2.8~78^2~23^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d7d52d5d603537bca79b74741eb177075a88904f;p=ceph.git 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 --- diff --git a/src/librbd/api/Namespace.cc b/src/librbd/api/Namespace.cc index 282744e5b9e..ed7f8e284fe 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;