From: Jason Dillaman Date: Wed, 20 Feb 2019 14:19:01 +0000 (-0500) Subject: librbd: attempt to restore deleted image from trash on known failures X-Git-Tag: v14.1.0~1^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=086a17f99abfd8977c546c3a748b75cbb87b12a1;p=ceph.git librbd: attempt to restore deleted image from trash on known failures If the image has watchers, snapshots, or group links, restore the image from the trash back to the image directory since data removal hasn't yet started. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/api/Image.cc b/src/librbd/api/Image.cc index c77b6005aee6..b657bc4fedf0 100644 --- a/src/librbd/api/Image.cc +++ b/src/librbd/api/Image.cc @@ -750,6 +750,12 @@ int Image::remove(IoCtx& io_ctx, const std::string &image_name, if (trash_image_source == RBD_TRASH_IMAGE_SOURCE_REMOVING) { // proceed with attempting to immediately remove the image r = Trash::remove(io_ctx, image_id, true, prog_ctx); + + if (r == -ENOTEMPTY || r == -EBUSY || r == -EMLINK) { + // best-effort try to restore the image if the removal + // failed for possible expected reasons + Trash::restore(io_ctx, trash_image_source, image_id, image_name); + } } return r; } else if (r < 0 && r != -EOPNOTSUPP) {