rbd: add clustername option
authorTianqing <tianqing@unitedstack.com>
Mon, 2 May 2016 14:21:53 +0000 (08:21 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 2 May 2016 14:21:53 +0000 (08:21 -0600)
As the Ceph Jewel is released, ceph cluster name
may not be the default "ceph". So we should add
the clustername for rbd engine to support that.

Signed-off-by: Tianqing <tianqing@unitedstack.com>
Fixed up various coding style violations by me.

Signed-off-by: Jens Axboe <axboe@fb.com>
engines/rbd.c
fio.1

index 8252d270b1bcb44eda6095281a413a3cb0cefdaf..87ed360f7c26a25fb401aac833b9fe05d0c288f4 100644 (file)
@@ -27,6 +27,7 @@ struct rbd_data {
 
 struct rbd_options {
        void *pad;
 
 struct rbd_options {
        void *pad;
+       char *cluster_name;
        char *rbd_name;
        char *pool_name;
        char *client_name;
        char *rbd_name;
        char *pool_name;
        char *client_name;
@@ -34,6 +35,15 @@ struct rbd_options {
 };
 
 static struct fio_option options[] = {
 };
 
 static struct fio_option options[] = {
+        {
+               .name           = "clustername",
+               .lname          = "ceph cluster name",
+               .type           = FIO_OPT_STR_STORE,
+               .help           = "Cluster name for ceph",
+               .off1           = offsetof(struct rbd_options, cluster_name),
+               .category       = FIO_OPT_C_ENGINE,
+               .group          = FIO_OPT_G_RBD,
+        },
        {
                .name           = "rbdname",
                .lname          = "rbd engine rbdname",
        {
                .name           = "rbdname",
                .lname          = "rbd engine rbdname",
@@ -112,7 +122,25 @@ static int _fio_rbd_connect(struct thread_data *td)
        struct rbd_options *o = td->eo;
        int r;
 
        struct rbd_options *o = td->eo;
        int r;
 
-       r = rados_create(&rbd->cluster, o->client_name);
+       if (o->cluster_name) {
+               char *client_name = NULL; 
+
+               /*
+                * If we specify cluser name, the rados_creat2
+                * will not assume 'client.'. name is considered
+                * as a full type.id namestr
+                */
+               if (!index(o->client_name, '.')) {
+                       client_name = calloc(1, strlen("client.") +
+                                               strlen(o->client_name) + 1);
+                       strcat(client_name, "client.");
+                       o->client_name = strcat(client_name, o->client_name);
+               }
+               r = rados_create2(&rbd->cluster, o->cluster_name,
+                                       o->client_name, 0);
+       } else
+               r = rados_create(&rbd->cluster, o->client_name);
+       
        if (r < 0) {
                log_err("rados_create failed.\n");
                goto failed_early;
        if (r < 0) {
                log_err("rados_create failed.\n");
                goto failed_early;
diff --git a/fio.1 b/fio.1
index e502dfe1667b41217b8165240d05e0610095e840..0abe321304cc5f9a4c06812e32017148238803d1 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -1772,6 +1772,9 @@ Preallocate donor's file on init
 .BI 1:
 allocate space immediately inside defragment event, and free right after event
 .RE
 .BI 1:
 allocate space immediately inside defragment event, and free right after event
 .RE
+.TP 
+.BI (rbd)clustername \fR=\fPstr
+Specifies the name of the ceph cluster.
 .TP
 .BI (rbd)rbdname \fR=\fPstr
 Specifies the name of the RBD.
 .TP
 .BI (rbd)rbdname \fR=\fPstr
 Specifies the name of the RBD.
@@ -1780,7 +1783,9 @@ Specifies the name of the RBD.
 Specifies the name of the Ceph pool containing the RBD.
 .TP
 .BI (rbd)clientname \fR=\fPstr
 Specifies the name of the Ceph pool containing the RBD.
 .TP
 .BI (rbd)clientname \fR=\fPstr
-Specifies the username (without the 'client.' prefix) used to access the Ceph cluster.
+Specifies the username (without the 'client.' prefix) used to access the Ceph
+cluster. If the clustername is specified, the clientname should be full type.id
+string. If no type. prefix, fio will add 'client.' by default for you.
 .TP
 .BI (mtd)skipbad \fR=\fPbool
 Skip operations against known bad blocks.
 .TP
 .BI (mtd)skipbad \fR=\fPbool
 Skip operations against known bad blocks.