Skip to content

Commit 4b8d636

Browse files
committed
remove unused file lock codes from LibvirtStorageAdaptor.java
1 parent 46e4cfd commit 4b8d636

1 file changed

Lines changed: 0 additions & 36 deletions

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
import java.io.FileInputStream;
2121
import java.io.BufferedInputStream;
2222
import java.io.IOException;
23-
import java.net.URI;
24-
import java.net.URISyntaxException;
2523
import java.util.ArrayList;
2624
import java.util.List;
2725
import java.util.UUID;
2826
import java.util.Map;
29-
import java.util.HashMap;
3027
import org.apache.log4j.Logger;
3128
import org.apache.commons.codec.binary.Base64;
3229
import org.apache.cloudstack.utils.qemu.QemuImg;
@@ -37,7 +34,6 @@
3734
import org.libvirt.LibvirtException;
3835
import org.libvirt.Secret;
3936
import org.libvirt.StoragePool;
40-
import org.libvirt.StoragePoolInfo;
4137
import org.libvirt.StorageVol;
4238
import org.libvirt.StoragePoolInfo.StoragePoolState;
4339
import com.ceph.rados.Rados;
@@ -48,7 +44,6 @@
4844
import com.ceph.rbd.RbdException;
4945
import com.ceph.rbd.jna.RbdSnapInfo;
5046

51-
import com.cloud.agent.api.ManageSnapshotCommand;
5247
import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
5348
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef;
5449
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.usage;
@@ -63,7 +58,6 @@
6358
import com.cloud.storage.Storage.StoragePoolType;
6459
import com.cloud.storage.StorageLayer;
6560
import com.cloud.utils.exception.CloudRuntimeException;
66-
import com.cloud.utils.script.OutputInterpreter;
6761
import com.cloud.utils.script.Script;
6862

6963
public class LibvirtStorageAdaptor implements StorageAdaptor {
@@ -72,8 +66,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
7266
private StorageLayer _storageLayer;
7367
private String _mountPoint = "/mnt";
7468
private String _manageSnapshotPath;
75-
private String _lockfile = "KVMFILELOCK" + File.separator + ".lock";
76-
private static final int ACQUIRE_GLOBAL_FILELOCK_TIMEOUT_FOR_KVM = 300; // 300 seconds
7769

7870
private String rbdTemplateSnapName = "cloudstack-base-snap";
7971
private int rbdFeatures = (1<<0); /* Feature 1<<0 means layering in RBD format 2 */
@@ -1175,10 +1167,6 @@ public boolean deleteStoragePool(KVMStoragePool pool) {
11751167
return deleteStoragePool(pool.getUuid());
11761168
}
11771169

1178-
// refreshPool and deleteVol are used to fix CLOUDSTACK-2729/CLOUDSTACK-2780
1179-
// They are caused by a libvirt bug (https://bugzilla.redhat.com/show_bug.cgi?id=977706)
1180-
// However, we also need to fix the issues in CloudStack source code.
1181-
// A file lock is used to prevent deleting a volume from a KVM storage pool when refresh it.
11821170
private void refreshPool(StoragePool pool) throws LibvirtException {
11831171
pool.refresh(0);
11841172
return;
@@ -1188,28 +1176,4 @@ private void deleteVol(LibvirtStoragePool pool, StorageVol vol) throws LibvirtEx
11881176
vol.delete(0);
11891177
}
11901178

1191-
private boolean lock(String path, int wait) {
1192-
File lockFile = new File(path);
1193-
lockFile.getParentFile().mkdir();
1194-
boolean havelock = false;
1195-
try {
1196-
while (wait > 0) {
1197-
if (lockFile.createNewFile()) {
1198-
havelock = true;
1199-
break;
1200-
}
1201-
s_logger.debug("lockFile " + _lockfile + " already exists, waiting 1000 ms");
1202-
Thread.sleep(1000);
1203-
wait--;
1204-
}
1205-
} catch (IOException e) {
1206-
} catch (InterruptedException e) {
1207-
}
1208-
return havelock;
1209-
}
1210-
1211-
private void unlock(String path) {
1212-
File lockFile = new File(path);
1213-
lockFile.delete();
1214-
}
12151179
}

0 commit comments

Comments
 (0)