]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: request exclusive lock when moving to trash
authorJason Dillaman <dillaman@redhat.com>
Thu, 19 Mar 2020 14:57:03 +0000 (10:57 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 20 Mar 2020 17:18:14 +0000 (13:18 -0400)
Even if the image is in-use, moving it to the trash does not
remove any data. This also solves a race between snapshot-based
mirroring shutting down and being able to move a mirrored image
to the trash.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Trash.cc

index 7d615050a254bfa2d783ceb0992b5ab8f2eaff51..720be6f55aa97c22a53f0dd567db5019b2578155 100644 (file)
@@ -158,7 +158,7 @@ int Trash<I>::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
       ictx->exclusive_lock->block_requests(0);
 
       r = ictx->operations->prepare_image_update(
-        exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL, false);
+        exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL, true);
       if (r < 0) {
         lderr(cct) << "cannot obtain exclusive lock - not removing" << dendl;
         ictx->owner_lock.unlock_shared();