From: Tianqing Date: Mon, 2 May 2016 14:21:53 +0000 (-0600) Subject: rbd: add clustername option X-Git-Tag: fio-2.10~56 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=6e20c6e7f357d9286e0c3aef9ca93ebcefab2f02;hp=fe8d0f4c54f0c308c9a02a4e3c2f5084e8bf5461 rbd: add clustername option 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 Fixed up various coding style violations by me. Signed-off-by: Jens Axboe --- diff --git a/engines/rbd.c b/engines/rbd.c index 8252d270..87ed360f 100644 --- a/engines/rbd.c +++ b/engines/rbd.c @@ -27,6 +27,7 @@ struct rbd_data { struct rbd_options { void *pad; + char *cluster_name; char *rbd_name; char *pool_name; char *client_name; @@ -34,6 +35,15 @@ struct rbd_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", @@ -112,7 +122,25 @@ static int _fio_rbd_connect(struct thread_data *td) 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; diff --git a/fio.1 b/fio.1 index e502dfe1..0abe3213 100644 --- 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 +.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. @@ -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 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.