Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ public void createVolume(CreateVolumeSpec v, ReturnValueCompletion<VolumeStats>

if (v.isEncrypted()) {
try {
v.setSize(alignSize(v.getSize()));
getVolumeEncryptionExtension().createEncryptedEmptyVolume(encryptionBackend(), v, comp);
} catch (OperationFailureException e) {
comp.fail(e.getErrorCode());
Expand Down Expand Up @@ -657,7 +658,9 @@ public void trashVolume(String installPath, Completion comp) {
public void cloneVolume(String srcInstallPath, CreateVolumeSpec dst, ReturnValueCompletion<VolumeStats> comp) {
if (dst.isEncrypted()) {
try {
getVolumeEncryptionExtension().cloneEncryptedVolumeFromImage(encryptionBackend(), srcInstallPath, dst, comp);
ZbsVolumeEncryptionBackend backend = encryptionBackend();
dst.setSize(alignSize(dst.getSize()));
getVolumeEncryptionExtension().cloneEncryptedVolumeFromImage(backend, srcInstallPath, dst, comp);
} catch (OperationFailureException e) {
comp.fail(e.getErrorCode());
}
Expand Down Expand Up @@ -750,7 +753,9 @@ public void handle(ErrorCode errCode, Map data) {
public void copyVolume(String srcInstallPath, CreateVolumeSpec dst, ReturnValueCompletion<VolumeStats> comp) {
if (dst.isEncrypted()) {
try {
getVolumeEncryptionExtension().copyEncryptedVolumeFromSnapshot(encryptionBackend(), srcInstallPath, dst, comp);
ZbsVolumeEncryptionBackend backend = encryptionBackend();
dst.setSize(alignSize(dst.getSize()));
getVolumeEncryptionExtension().copyEncryptedVolumeFromSnapshot(backend, srcInstallPath, dst, comp);
} catch (OperationFailureException e) {
comp.fail(e.getErrorCode());
}
Expand Down Expand Up @@ -880,7 +885,7 @@ public void expandVolume(VolumeInventory volume, long size, ReturnValueCompletio
comp.fail(operr("cannot find ZBS volume encryption extension"));
return;
}
exts.get(0).resizeEncryptedVolume(self.getUuid(), volume, size, comp);
exts.get(0).resizeEncryptedVolume(self.getUuid(), volume, alignSize(size), comp);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,11 @@ public void fail(ErrorCode errorCode) {
private void resolveCloneVirtualSize(ZbsVolumeEncryptionBackend backend, String srcInstallPath,
String resolvedSrcInstallPath, CreateVolumeSpec dst,
ReturnValueCompletion<Long> completion) {
if (dst.getSize() > 0) {
completion.success(dst.getSize());
return;
}

Long dbSize = findSourceVirtualSizeInDb(backend, srcInstallPath);
if (dbSize != null && dbSize > 0) {
dst.setSize(dbSize);
completion.success(dbSize);
long virtualSize = Math.max(dst.getSize(), dbSize);
dst.setSize(virtualSize);
completion.success(virtualSize);
return;
}

Expand All @@ -165,8 +161,9 @@ public void success(VolumeStats stats) {
return;
}

dst.setSize(size);
completion.success(size);
long virtualSize = Math.max(dst.getSize(), size);
dst.setSize(virtualSize);
completion.success(virtualSize);
}

@Override
Expand Down