From fcc58ecfeba6bbc72588e69dba35779f94d28ba5 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 --- 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 8357f58728a9a..deda99c87c8a5 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -594,6 +594,14 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) 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) { @@ -603,21 +611,6 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) 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.39.5