From 37067a6f1275ea62d40f398c7b5d8e76f08f527a Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 24 Jan 2018 14:40:56 -0500 Subject: [PATCH] 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) --- src/librbd/internal.cc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) 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; -- 2.47.3