From 6c7f72bc7a2cd0db71bb51ecf0b5a7da90d5945e Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Sun, 19 Jun 2022 16:29:17 +0300 Subject: [PATCH] core: only use a shared lock for thin template overlays When downloading a disk that is an overlay of a template, take only a shared lock on the disk and skip the locked disk validation, this would allow downloading disks of thin VMs without failing on the disk being locked. Bug-Url: Bug-Url: https://bugzilla.redhat.com/1879391 Signed-off-by: Benny Zlotnik --- .../bll/storage/disk/image/TransferDiskImageCommand.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/TransferDiskImageCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/TransferDiskImageCommand.java index 1842717fcbc..d8600c03c4c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/TransferDiskImageCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/TransferDiskImageCommand.java @@ -444,12 +444,18 @@ protected Map> getSharedLocks() { // StartVmBackup should handle locks return locks; } + if (!Guid.isNullOrEmpty(getParameters().getImageId()) && getDiskImage() != null) { List vms = vmDao.getVmsListForDisk(getDiskImage().getId(), true); vms.forEach(vm -> locks.put(vm.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM, getDiskIsBeingTransferredLockMessage()))); } + if (getDiskImage() != null && getParameters().getTransferType() == TransferType.Download) { + locks.put(getDiskImage().getId().toString(), + LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, EngineMessage.ACTION_TYPE_FAILED_DISK_IS_LOCKED)); + } + return locks; } @@ -466,7 +472,8 @@ protected Map> getExclusiveLocks() { // StartVmBackup should handle locks return locks; } - if (getDiskImage() != null) { + + if (getDiskImage() != null && getParameters().getTransferType() == TransferType.Upload) { locks.put(getDiskImage().getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, getDiskIsBeingTransferredLockMessage())); }