Skip to content

Commit bdc50a9

Browse files
committed
librbd: remove image directory object during rollback
... 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 <[email protected]>
1 parent 1c34945 commit bdc50a9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librbd/api/Namespace.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ int Namespace<I>::create(librados::IoCtx& io_ctx, const std::string& name)
7979
return 0;
8080

8181
rollback:
82-
int ret_val = cls_client::namespace_remove(&default_ns_ctx, name);
82+
int ret_val = ns_ctx.remove(RBD_DIRECTORY);
83+
if (ret_val < 0 && ret_val != -ENOENT) {
84+
lderr(cct) << "failed to remove image directory: " << cpp_strerror(ret_val) << dendl;
85+
}
86+
87+
ret_val = cls_client::namespace_remove(&default_ns_ctx, name);
8388
if (ret_val < 0) {
8489
lderr(cct) << "failed to remove namespace: " << cpp_strerror(ret_val) << dendl;
8590
}

0 commit comments

Comments
 (0)