merge from 2.1.x 86d02eaa155cfdbb0a8cf31c8eae47711fbf5c2b

delete all snapshut which has been backed up to secondary storage
change dd block size from 512 to 1M, make taking snapstho faster for iscsi primary storage
This commit is contained in:
anthony 2010-11-03 19:04:08 -07:00
parent 671918d113
commit 003b0e4a23
2 changed files with 37 additions and 2 deletions

View File

@ -5544,6 +5544,39 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
}
return new CreatePrivateTemplateAnswer(cmd, result, details);
}
private boolean destroySnapshotOnPrimaryStorageExceptThis(String volumeUuid, String avoidSnapshotUuid){
try {
Connection conn = getConnection();
VDI volume = getVDIbyUuid(volumeUuid);
if (volume == null) {
throw new InternalErrorException("Could not destroy snapshot on volume " + volumeUuid + " due to can not find it");
}
Set<VDI> snapshots = volume.getSnapshots(conn);
for( VDI snapshot : snapshots ) {
try {
if(! snapshot.getUuid(conn).equals(avoidSnapshotUuid)) {
snapshot.destroy(conn);
}
} catch (Exception e) {
String msg = "Destroying snapshot: " + snapshot+ " on primary storage failed due to " + e.toString();
s_logger.warn(msg, e);
}
}
s_logger.debug("Successfully destroyed snapshot on volume: " + volumeUuid + " execept this current snapshot "+ avoidSnapshotUuid );
return true;
} catch (XenAPIException e) {
String msg = "Destroying snapshot on volume: " + volumeUuid + " execept this current snapshot "+ avoidSnapshotUuid + " failed due to " + e.toString();
s_logger.error(msg, e);
} catch (Exception e) {
String msg = "Destroying snapshot on volume: " + volumeUuid + " execept this current snapshot "+ avoidSnapshotUuid + " failed due to " + e.toString();
s_logger.warn(msg, e);
}
return false;
}
protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) {
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
@ -5617,7 +5650,9 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
// new one
// and muddle the vhd chain on the secondary storage.
destroySnapshotOnPrimaryStorage(prevSnapshotUuid);
String volumeUuid = cmd.getVolumePath();
destroySnapshotOnPrimaryStorageExceptThis(volumeUuid, snapshotUuid);
}
}

View File

@ -171,7 +171,7 @@ def copyfile(fromFile, toFile, isISCSI):
errMsg = ''
if isISCSI:
try:
cmd = ['dd', 'if=' + fromFile, 'of=' + toFile]
cmd = ['dd', 'if=' + fromFile, 'of=' + toFile, 'bs=1M']
txt = util.pread2(cmd)
except:
txt = ''