From: Jason Dillaman Date: Wed, 24 Jan 2018 19:40:56 +0000 (-0500) Subject: librbd: force removal of a snapshot cannot ignore dependent children X-Git-Tag: v12.2.3~92^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=37067a6f1275ea62d40f398c7b5d8e76f08f527a;p=ceph.git librbd: force removal of a snapshot cannot ignore dependent children Fixes: http://tracker.ceph.com/issues/22791 Signed-off-by: Jason Dillaman (cherry picked from commit fcc58ecfeba6bbc72588e69dba35779f94d28ba5) --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index ee57371ce15..e6b860c0300 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -608,6 +608,14 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { return r; } + if ((imctx->features & RBD_FEATURE_DEEP_FLATTEN) == 0 && + !imctx->snaps.empty()) { + lderr(cct) << "snapshot in-use by " << pool << "/" << imctx->name + << dendl; + imctx->state->close(); + return -EBUSY; + } + librbd::NoOpProgressContext prog_ctx; r = imctx->operations->flatten(prog_ctx); if (r < 0) { @@ -617,21 +625,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { return r; } - if ((imctx->features & RBD_FEATURE_DEEP_FLATTEN) == 0 && - !imctx->snaps.empty()) { - imctx->parent_lock.get_read(); - ParentInfo parent_info = imctx->parent_md; - imctx->parent_lock.put_read(); - - r = cls_client::remove_child(&imctx->md_ctx, RBD_CHILDREN, - parent_info.spec, imctx->id); - if (r < 0 && r != -ENOENT) { - lderr(cct) << "error removing child from children list" << dendl; - imctx->state->close(); - return r; - } - } - r = imctx->state->close(); if (r < 0) { lderr(cct) << "failed to close image: " << cpp_strerror(r) << dendl;