From ae726336d274ec9d5e02ecd05ddeab2750ff8959 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 19 Mar 2020 10:57:03 -0400 Subject: [PATCH] librbd: request exclusive lock when moving to trash 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 --- src/librbd/api/Trash.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librbd/api/Trash.cc b/src/librbd/api/Trash.cc index 7d615050a25..720be6f55aa 100644 --- a/src/librbd/api/Trash.cc +++ b/src/librbd/api/Trash.cc @@ -158,7 +158,7 @@ int Trash::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();