Skip to content

Commit e38b7a7

Browse files
kvm: apply rbd_default_data_pool when creating volumes from templates on RBD (#13361)
RBD erasure-coded pool support (#9808) added handling of the rbd_default_data_pool storage-pool detail to RBDStringBuilder (qemu-img path) and to createPhysicalDisk (blank volumes), but not to createDiskFromTemplateOnRBD. As a result, ROOT volumes created from a template via rados-java rbd.clone()/rbd.create() are created without a data pool: all of their data objects land in the (replicated) metadata pool instead of the erasure-coded data pool, defeating the point of EC and consuming ~3x raw space. Set rbd_default_data_pool on the Rados connection (before connect) in both the same-cluster clone/copy branch and the cross-cluster copy branch of createDiskFromTemplateOnRBD, using the destination pool's detail. librbd then honors it as the default data pool when the new image is created, so template-derived volumes get data_pool set, the same way blank volumes already do.
1 parent a01fb0b commit e38b7a7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,8 @@ private KVMPhysicalDisk createDiskFromTemplateOnRBD(KVMPhysicalDisk template,
13481348
*/
13491349

13501350
KVMStoragePool srcPool = template.getPool();
1351+
Map<String, String> destDetails = destPool.getDetails();
1352+
String dataPool = (destDetails == null) ? null : destDetails.get(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL);
13511353
KVMPhysicalDisk disk = null;
13521354
String newUuid = name;
13531355

@@ -1396,6 +1398,10 @@ private KVMPhysicalDisk createDiskFromTemplateOnRBD(KVMPhysicalDisk template,
13961398
r.confSet("mon_host", srcPool.getSourceHost() + ":" + srcPool.getSourcePort());
13971399
r.confSet("key", srcPool.getAuthSecret());
13981400
r.confSet("client_mount_timeout", "30");
1401+
if (dataPool != null) {
1402+
logger.debug("Setting RBD data pool to " + dataPool + " for the new image " + disk.getName());
1403+
r.confSet(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL, dataPool);
1404+
}
13991405
r.connect();
14001406
logger.debug("Successfully connected to Ceph cluster at " + r.confGet("mon_host"));
14011407

@@ -1474,6 +1480,10 @@ private KVMPhysicalDisk createDiskFromTemplateOnRBD(KVMPhysicalDisk template,
14741480
rDest.confSet("mon_host", destPool.getSourceHost() + ":" + destPool.getSourcePort());
14751481
rDest.confSet("key", destPool.getAuthSecret());
14761482
rDest.confSet("client_mount_timeout", "30");
1483+
if (dataPool != null) {
1484+
logger.debug("Setting RBD data pool to " + dataPool + " on the destination cluster for the new image " + disk.getName());
1485+
rDest.confSet(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL, dataPool);
1486+
}
14771487
rDest.connect();
14781488
logger.debug("Successfully connected to source Ceph cluster at " + rDest.confGet("mon_host"));
14791489

0 commit comments

Comments
 (0)