cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject [1/3] git commit: updated refs/heads/4.1 to 15b03a2
Date Mon, 02 Sep 2013 15:20:29 GMT
Updated Branches:
  refs/heads/4.1 b41ef1df9 -> 15b03a2d2


revert 4 commits related to primary storage issue.

ba90fa91d3da56d4b63a0850d58add34cc5a7a2c
64bb7007053d004fe7a8ac3b610e20df69f16bab
630d2561d2b13882892799507613823bcc04b4ac
1978d7bd7311d19a4b370a679cfd364d54e1e300


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6efd2b4c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6efd2b4c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6efd2b4c

Branch: refs/heads/4.1
Commit: 6efd2b4c7e0f9eb1a3764ccac8ca4fd30db4fdf9
Parents: b41ef1d
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Mon Sep 2 17:00:40 2013 +0200
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Mon Sep 2 17:00:40 2013 +0200

----------------------------------------------------------------------
 .../kvm/storage/LibvirtStorageAdaptor.java      | 90 ++------------------
 1 file changed, 6 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6efd2b4c/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index 7d6e820..9f85132 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -17,7 +17,6 @@
 package com.cloud.hypervisor.kvm.storage;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -58,8 +57,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
     private StorageLayer _storageLayer;
     private String _mountPoint = "/mnt";
     private String _manageSnapshotPath;
-    private String _lockfile = "KVMFILELOCK" + File.separator + ".lock";
-    private static final int ACQUIRE_GLOBAL_FILELOCK_TIMEOUT_FOR_KVM = 300; // 300 seconds
 
     public LibvirtStorageAdaptor(StorageLayer storage) {
         _storageLayer = storage;
@@ -107,7 +104,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
     public void storagePoolRefresh(StoragePool pool) {
         try {
             synchronized (getStoragePool(pool.getUUIDString())) {
-                refreshPool(pool);
+                pool.refresh(0);
             }
         } catch (LibvirtException e) {
 
@@ -392,9 +389,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
             }
             LibvirtStoragePoolDef spd = getStoragePoolDef(conn, storage);
             StoragePoolType type = null;
-            if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.NETFS) {
-                type = StoragePoolType.NetworkFilesystem;
-            } else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.DIR) {
+            if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.NETFS
+                    || spd.getPoolType() == LibvirtStoragePoolDef.poolType.DIR) {
                 type = StoragePoolType.Filesystem;
             } else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.RBD) {
                 type = StoragePoolType.RBD;
@@ -670,8 +666,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
         try {
             StorageVol vol = this.getVolume(libvirtPool.getPool(), uuid);
-            StoragePool virtPool = libvirtPool.getPool();
-            deleteVol(virtPool, vol);
+            vol.delete(0);
             vol.free();
             return true;
         } catch (LibvirtException e) {
@@ -845,7 +840,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
         StoragePool virtPool = libvirtPool.getPool();
         try {
-            refreshPool(virtPool);
+            virtPool.refresh(0);
         } catch (LibvirtException e) {
             return false;
         }
@@ -862,10 +857,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         try {
             conn = LibvirtConnection.getConnection();
             StorageVol vol = conn.storageVolLookupByPath(diskPath);
-            StoragePool pool = vol.storagePoolLookupByVolume();
             if(vol != null) {
                 s_logger.debug("requested delete disk " + diskPath);
-                deleteVol(pool, vol);
+                vol.delete(0);
             }
         } catch (LibvirtException e) {
             s_logger.debug("Libvirt error in attempting to find and delete patch disk:" +
e.toString());
@@ -874,76 +868,4 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         return true;
     }
 
-    // refreshPool and deleteVol are used to fix CLOUDSTACK-2729/CLOUDSTACK-2780
-    // They are caused by a libvirt bug (https://bugzilla.redhat.com/show_bug.cgi?id=977706)
-    // However, we also need to fix the issues in CloudStack source code.
-    // A file lock is used to prevent deleting a volume from a KVM storage pool when refresh
it.
-    private void refreshPool(StoragePool pool) throws LibvirtException {
-        Connect conn = LibvirtConnection.getConnection();
-        LibvirtStoragePoolDef spd = getStoragePoolDef(conn, pool);
-        if ((! spd.getPoolType().equals(LibvirtStoragePoolDef.poolType.NETFS))
-                && (! spd.getPoolType().equals(LibvirtStoragePoolDef.poolType.DIR)))
{
-            pool.refresh(0);
-            return;
-        }
-        String lockFile = spd.getTargetPath() + File.separator + _lockfile;
-        s_logger.debug("Attempting to lock pool " + pool.getName() + " with file " + lockFile);
-        if (lock(lockFile, ACQUIRE_GLOBAL_FILELOCK_TIMEOUT_FOR_KVM)) {
-            try {
-                pool.refresh(0);
-            } finally {
-                s_logger.debug("Releasing the lock on pool " + pool.getName() + " with file
" + lockFile);
-                unlock(lockFile);
-            }
-        } else {
-            throw new CloudRuntimeException("Can not get file lock to refresh the pool "
+ pool.getName());
-        }
-    }
-
-    private void deleteVol(StoragePool pool, StorageVol vol) throws LibvirtException {
-        Connect conn = LibvirtConnection.getConnection();
-        LibvirtStoragePoolDef spd = getStoragePoolDef(conn, pool);
-        if ((! spd.getPoolType().equals(LibvirtStoragePoolDef.poolType.NETFS))
-                && (! spd.getPoolType().equals(LibvirtStoragePoolDef.poolType.DIR)))
{
-            vol.delete(0);
-            return;
-        }
-        String lockFile = spd.getTargetPath() + File.separator + _lockfile;
-        s_logger.debug("Attempting to lock pool " + pool.getName() + " with file " + lockFile);
-        if (lock(lockFile, ACQUIRE_GLOBAL_FILELOCK_TIMEOUT_FOR_KVM)) {
-            try {
-                vol.delete(0);
-            } finally {
-                s_logger.debug("Releasing the lock on pool " + pool.getName() + " with file
" + lockFile);
-                unlock(lockFile);
-            }
-        } else {
-            throw new CloudRuntimeException("Can not get file lock to delete the volume "
+ vol.getName());
-        }
-    }
-
-    private boolean lock(String path, int wait) {
-        File lockFile = new File(path);
-        lockFile.getParentFile().mkdir();
-        boolean havelock = false;
-        try {
-            while (wait > 0) {
-                if (lockFile.createNewFile()) {
-                    havelock = true;
-                    break;
-                }
-                s_logger.debug("lockFile " + _lockfile + " already exists, waiting 1000 ms");
-                Thread.sleep(1000);
-                wait--;
-            }
-        } catch (IOException e) {
-        } catch (InterruptedException e) {
-        }
-        return havelock;
-    }
-
-    private void unlock(String path) {
-        File lockFile = new File(path);
-        lockFile.delete();
-    }
 }


Mime
View raw message