X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Frbd.c;h=c85645aeac3ec921e6b599071e951d45b10ceb7c;hp=3688577f7404b242df88116946166a30f08dab60;hb=6ec0dcd1f7c02db47f23eb5cc400772ea095704b;hpb=a1f871c72971efe84cd42670d5df4c4dc56dbd3f diff --git a/engines/rbd.c b/engines/rbd.c index 3688577f..c85645ae 100644 --- a/engines/rbd.c +++ b/engines/rbd.c @@ -8,6 +8,7 @@ #include #include "../fio.h" +#include "../optgroup.h" struct fio_rbd_iou { struct io_u *io_u; @@ -26,6 +27,7 @@ struct rbd_data { struct rbd_options { void *pad; + char *cluster_name; char *rbd_name; char *pool_name; char *client_name; @@ -33,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", @@ -80,7 +91,7 @@ static int _fio_setup_rbd_data(struct thread_data *td, { struct rbd_data *rbd; - if (td->io_ops->data) + if (td->io_ops_data) return 0; rbd = calloc(1, sizeof(struct rbd_data)); @@ -99,19 +110,50 @@ static int _fio_setup_rbd_data(struct thread_data *td, return 0; failed: - if (rbd) + if (rbd) { + if (rbd->aio_events) + free(rbd->aio_events); + if (rbd->sort_events) + free(rbd->sort_events); free(rbd); + } return 1; } static int _fio_rbd_connect(struct thread_data *td) { - struct rbd_data *rbd = td->io_ops->data; + struct rbd_data *rbd = td->io_ops_data; 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_create2 + * will not assume 'client.'. name is considered + * as a full type.id namestr + */ + if (o->client_name) { + if (!index(o->client_name, '.')) { + client_name = calloc(1, strlen("client.") + + strlen(o->client_name) + 1); + strcat(client_name, "client."); + strcat(client_name, o->client_name); + } else { + client_name = o->client_name; + } + } + + r = rados_create2(&rbd->cluster, o->cluster_name, + client_name, 0); + + if (client_name && !index(o->client_name, '.')) + free(client_name); + } else + r = rados_create(&rbd->cluster, o->client_name); + if (r < 0) { log_err("rados_create failed.\n"); goto failed_early; @@ -185,19 +227,19 @@ static void _fio_rbd_finish_aiocb(rbd_completion_t comp, void *data) * a specific error. So we have to assume that it can't do * partial completions. */ - fri->io_complete = 1; - ret = rbd_aio_get_return_value(fri->completion); if (ret < 0) { io_u->error = ret; io_u->resid = io_u->xfer_buflen; } else io_u->error = 0; + + fri->io_complete = 1; } static struct io_u *fio_rbd_event(struct thread_data *td, int event) { - struct rbd_data *rbd = td->io_ops->data; + struct rbd_data *rbd = td->io_ops_data; return rbd->aio_events[event]; } @@ -253,7 +295,7 @@ static int rbd_io_u_cmp(const void *p1, const void *p2) static int rbd_iter_events(struct thread_data *td, unsigned int *events, unsigned int min_evts, int wait) { - struct rbd_data *rbd = td->io_ops->data; + struct rbd_data *rbd = td->io_ops_data; unsigned int this_events = 0; struct io_u *io_u; int i, sidx; @@ -332,7 +374,7 @@ static int fio_rbd_getevents(struct thread_data *td, unsigned int min, static int fio_rbd_queue(struct thread_data *td, struct io_u *io_u) { - struct rbd_data *rbd = td->io_ops->data; + struct rbd_data *rbd = td->io_ops_data; struct fio_rbd_iou *fri = io_u->engine_data; int r = -1; @@ -410,7 +452,7 @@ failed: static void fio_rbd_cleanup(struct thread_data *td) { - struct rbd_data *rbd = td->io_ops->data; + struct rbd_data *rbd = td->io_ops_data; if (rbd) { _fio_rbd_disconnect(rbd); @@ -438,7 +480,7 @@ static int fio_rbd_setup(struct thread_data *td) log_err("fio_setup_rbd_data failed.\n"); goto cleanup; } - td->io_ops->data = rbd; + td->io_ops_data = rbd; /* librbd does not allow us to run first in the main thread and later * in a fork child. It needs to be the same process context all the @@ -497,7 +539,7 @@ static int fio_rbd_open(struct thread_data *td, struct fio_file *f) static int fio_rbd_invalidate(struct thread_data *td, struct fio_file *f) { #if defined(CONFIG_RBD_INVAL) - struct rbd_data *rbd = td->io_ops->data; + struct rbd_data *rbd = td->io_ops_data; return rbd_invalidate_cache(rbd->image); #else