cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject git commit: updated refs/heads/master to a7004db
Date Fri, 02 May 2014 10:15:32 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 155745e26 -> a7004db7c


rbd: Create snapshot for cloning operations only when it is required

We used to create the snapshot after the copy from Secondary Storage,
but it could be that we never use the snapshot.

Now we check if the snapshot exists prior to performing the cloning operation


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

Branch: refs/heads/master
Commit: a7004db7c8504ba77ed769a5ed752ea9a67aeb02
Parents: 155745e
Author: Wido den Hollander <wido@widodh.nl>
Authored: Fri May 2 11:55:34 2014 +0200
Committer: Wido den Hollander <wido@widodh.nl>
Committed: Fri May 2 11:55:34 2014 +0200

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a7004db7/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 09400c7..0adad01 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
@@ -1036,6 +1036,30 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                                 + " is RBD format 2. We will perform a RBD clone using snapshot
"
                                 + this.rbdTemplateSnapName);
                                 /* The source image is format 2, we can do a RBD snapshot+clone
(layering) */
+
+
+                        s_logger.debug("Checking if RBD snapshot " + srcPool.getSourceDir()
+ "/" + template.getName()
+                                       + "@" + rbdTemplateSnapName + " exists prior to attempting
a clone operation.");
+
+                        List<RbdSnapInfo> snaps = srcImage.snapList();
+                        s_logger.debug("Found " + snaps.size() +  " snapshots on RBD image
" + srcPool.getSourceDir() + "/" + template.getName());
+                        boolean snapFound = false;
+                        for (RbdSnapInfo snap : snaps) {
+                            if (rbdTemplateSnapName.equals(snap.name)) {
+                                s_logger.debug("RBD snapshot " + srcPool.getSourceDir() +
"/" + template.getName()
+                                               + "@" + rbdTemplateSnapName + " already exists.");
+                                snapFound = true;
+                                break;
+                            }
+                        }
+
+                        if (!snapFound) {
+                            s_logger.debug("Creating RBD snapshot " + rbdTemplateSnapName
+ " on image " + name);
+                            srcImage.snapCreate(rbdTemplateSnapName);
+                            s_logger.debug("Protecting RBD snapshot " + rbdTemplateSnapName
+ " on image " + name);
+                            srcImage.snapProtect(rbdTemplateSnapName);
+                        }
+
                         rbd.clone(template.getName(), this.rbdTemplateSnapName, io, disk.getName(),
this.rbdFeatures, this.rbdOrder);
                         s_logger.debug("Succesfully cloned " + template.getName() + "@" +
this.rbdTemplateSnapName + " to " + disk.getName());
                     }
@@ -1234,12 +1258,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
 
                 RbdImage image = rbd.open(name);
 
-                /* Snapshot the image and protect that snapshot so we can clone (layer) from
it */
-                s_logger.debug("Creating RBD snapshot " + rbdTemplateSnapName + " on image
" + name);
-                image.snapCreate(rbdTemplateSnapName);
-                s_logger.debug("Protecting RBD snapshot " + rbdTemplateSnapName + " on image
" + name);
-                image.snapProtect(rbdTemplateSnapName);
-
                 rbd.close(image);
                 r.ioCtxDestroy(io);
             } catch (QemuImgException e) {


Mime
View raw message