]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
rbd: Use RBD format 2 by default when creating images.
authorWido den Hollander <wido@widodh.nl>
Tue, 14 Jul 2015 08:15:26 +0000 (10:15 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 16 Jul 2015 16:31:20 +0000 (12:31 -0400)
We used to look at the librbd code version and depending on that
we would invoke rbd_create3() or rbd_create().

Since librbd version 0.67.9 we can however tell RBD that it should
create rbd format 2 images even if we invoke rbd_create().

The less options we pass to librbd, the more we can lean on the sane
defaults it uses.

For rbd_create3() we had things like the stripe count and unit hardcoded
in libvirt and that might cause problems down the road.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
src/storage/storage_backend_rbd.c

index 8e8d7a7ef023aace340493cb6bb9ca70e641387d..1e35c1f6db74b9ead587439a5b207289ba99ec76 100644 (file)
@@ -66,6 +66,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
     const char *client_mount_timeout = "30";
     const char *mon_op_timeout = "30";
     const char *osd_op_timeout = "30";
+    const char *rbd_default_format = "2";
 
     if (authdef) {
         VIR_DEBUG("Using cephx authorization, username: %s", authdef->username);
@@ -211,6 +212,14 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
     VIR_DEBUG("Setting RADOS option rados_osd_op_timeout to %s", osd_op_timeout);
     rados_conf_set(ptr->cluster, "rados_osd_op_timeout", osd_op_timeout);
 
+    /*
+     * Librbd supports creating RBD format 2 images. We no longer have to invoke
+     * rbd_create3(), we can tell librbd to default to format 2.
+     * This leaves us to simply use rbd_create() and use the default behavior of librbd
+     */
+    VIR_DEBUG("Setting RADOS option rbd_default_format to %s", rbd_default_format);
+    rados_conf_set(ptr->cluster, "rbd_default_format", rbd_default_format);
+
     ptr->starttime = time(0);
     r = rados_connect(ptr->cluster);
     if (r < 0) {
@@ -475,18 +484,8 @@ 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_unit, stripe_count) < 0) {
-#else
-    if (rbd_create(io, name, capacity, &order) < 0) {
-#endif
+    if (rbd_create(io, name, capacity, &order) < 0)
         return -1;
-    }
 
     return 0;
 }