From 508bc692ff25ed8e90797faea97e2f62ec6efa5a Mon Sep 17 00:00:00 2001 From: Edison Su Date: Tue, 20 Dec 2011 10:57:12 -0800 Subject: [PATCH] bug 12657: don't hold a vm lock when taking snapshot status 12657: resolved fixed Reviewed-by: Anthony.xu@citrix.com --- .../storage/snapshot/SnapshotManagerImpl.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 5cd08c9c990..b982b36cbce 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -375,21 +375,12 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma SnapshotVO snapshot = null; boolean backedUp = false; - + UserVmVO uservm = null; // does the caller have the authority to act on this volume _accountMgr.checkAccess(UserContext.current().getCaller(), null, volume); try { - if (volume != null && _volsDao.getHypervisorType(volume.getId()).equals(HypervisorType.KVM)) { - /* KVM needs to lock on the vm of volume, because it takes snapshot on behalf of vm, not volume */ - UserVmVO uservm = _vmDao.findById(volume.getInstanceId()); - if (uservm != null) { - UserVmVO vm = _vmDao.acquireInLockTable(uservm.getId(), 10); - if (vm == null) { - throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is being used, try it later "); - } - } - } + Long poolId = volume.getPoolId(); if (poolId == null) { throw new CloudRuntimeException("You cannot take a snapshot of a volume until it has been attached to an instance"); @@ -418,7 +409,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma + userVm.getState().toString() + " state"); } - if(userVm.getHypervisorType() == HypervisorType.VMware) { + if(userVm.getHypervisorType() == HypervisorType.VMware || userVm.getHypervisorType() == HypervisorType.KVM) { List activeSnapshots = _snapshotDao.listByInstanceId(volume.getInstanceId(), Snapshot.Status.Creating, Snapshot.Status.CreatedOnPrimary, Snapshot.Status.BackingUp); if(activeSnapshots.size() > 1) throw new CloudRuntimeException("There is other active snapshot tasks on the instance to which the volume is attached, please try again later");