]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: attempt to restore deleted image from trash on known failures
authorJason Dillaman <dillaman@redhat.com>
Wed, 20 Feb 2019 14:19:01 +0000 (09:19 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 20 Feb 2019 21:47:07 +0000 (16:47 -0500)
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 <dillaman@redhat.com>
src/librbd/api/Image.cc

index c77b6005aee615fb1a0fb1a0e78d510e0dbddad1..b657bc4fedf061849d7ed06822d0d3ea7f3c6640 100644 (file)
@@ -750,6 +750,12 @@ int Image<I>::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<I>::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<I>::restore(io_ctx, trash_image_source, image_id, image_name);
+        }
       }
       return r;
     } else if (r < 0 && r != -EOPNOTSUPP) {