提交 0227889a 编写于 作者: W Wido den Hollander 提交者: Daniel P. Berrange

rbd: Use rbd_create3 to create RBD format 2 images by default

This new RBD format supports snapshotting and cloning. By having
libvirt create images in format 2 end-users of the created images
can benefit from the new RBD format.

Older versions of libvirt can work with this new RBD format as long
as librbd supports format 2. RBD format is supported by librbd since
version 0.56 (Ceph Bobtail).
Signed-off-by: NWido den Hollander <wido@widodh.nl>
上级 97410063
...@@ -458,6 +458,25 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -458,6 +458,25 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
return 0; return 0;
} }
static int virStorageBackendRBDCreateImage(rados_ioctx_t io,
char *name, long capacity)
{
int order = 0;
#if LIBRBD_VERSION_CODE > 260
uint64_t features = 3;
uint64_t stripe_count = 1;
uint64_t stripe_unit = 4194304;
if (rbd_create3(io, name, capacity, features, &order,
stripe_count, stripe_unit) < 0) {
#else
if (rbd_create(io, name, capacity, &order) < 0) {
#endif
return -1;
}
return 0;
}
static int static int
virStorageBackendRBDBuildVol(virConnectPtr conn, virStorageBackendRBDBuildVol(virConnectPtr conn,
...@@ -468,7 +487,6 @@ virStorageBackendRBDBuildVol(virConnectPtr conn, ...@@ -468,7 +487,6 @@ virStorageBackendRBDBuildVol(virConnectPtr conn,
virStorageBackendRBDState ptr; virStorageBackendRBDState ptr;
ptr.cluster = NULL; ptr.cluster = NULL;
ptr.ioctx = NULL; ptr.ioctx = NULL;
int order = 0;
int ret = -1; int ret = -1;
VIR_DEBUG("Creating RBD image %s/%s with size %llu", VIR_DEBUG("Creating RBD image %s/%s with size %llu",
...@@ -494,7 +512,7 @@ virStorageBackendRBDBuildVol(virConnectPtr conn, ...@@ -494,7 +512,7 @@ virStorageBackendRBDBuildVol(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
if (rbd_create(ptr.ioctx, vol->name, vol->capacity, &order) < 0) { if (virStorageBackendRBDCreateImage(ptr.ioctx, vol->name, vol->capacity) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to create volume '%s/%s'"), _("failed to create volume '%s/%s'"),
pool->def->source.name, pool->def->source.name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册