Merge branch 'wip-traceinfo' of https://github.com/vears91/fio
authorJens Axboe <axboe@fb.com>
Tue, 2 Aug 2016 21:05:59 +0000 (15:05 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 2 Aug 2016 21:05:59 +0000 (15:05 -0600)
1  2 
engines/rbd.c

diff --combined engines/rbd.c
index c85645aeac3ec921e6b599071e951d45b10ceb7c,552e5c575a82c07a1de4290dafcf8e3e81d2e06e..b319315fc73e1e10d43a177651187666e9e8e731
@@@ -9,12 -9,16 +9,16 @@@
  
  #include "../fio.h"
  #include "../optgroup.h"
+ #ifdef CONFIG_RBD_BLKIN
+ #include <zipkin_c.h>
+ #endif
  
  struct fio_rbd_iou {
        struct io_u *io_u;
        rbd_completion_t completion;
        int io_seen;
        int io_complete;
+       struct blkin_trace_info info;
  };
  
  struct rbd_data {
@@@ -91,7 -95,7 +95,7 @@@ static int _fio_setup_rbd_data(struct t
  {
        struct rbd_data *rbd;
  
 -      if (td->io_ops->data)
 +      if (td->io_ops_data)
                return 0;
  
        rbd = calloc(1, sizeof(struct rbd_data));
        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;
  
                char *client_name = NULL; 
  
                /*
 -               * If we specify cluser name, the rados_creat2
 +               * If we specify cluser name, the rados_create2
                 * 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);
 +              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,
 -                                      o->client_name, 0);
 +                               client_name, 0);
 +
 +              if (client_name && !index(o->client_name, '.'))
 +                      free(client_name);
        } else
                r = rados_create(&rbd->cluster, o->client_name);
        
@@@ -239,7 -230,7 +243,7 @@@ static void _fio_rbd_finish_aiocb(rbd_c
  
  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];
  }
@@@ -295,7 -286,7 +299,7 @@@ static int rbd_io_u_cmp(const void *p1
  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;
@@@ -374,7 -365,7 +378,7 @@@ static int fio_rbd_getevents(struct thr
  
  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;
  
        }
  
        if (io_u->ddir == DDIR_WRITE) {
+ #ifdef CONFIG_RBD_BLKIN
+               blkin_init_trace_info(&fri->info);
+               r = rbd_aio_write_traced(rbd->image, io_u->offset, io_u->xfer_buflen,
+                                        io_u->xfer_buf, fri->completion, &fri->info);
+ #else
                r = rbd_aio_write(rbd->image, io_u->offset, io_u->xfer_buflen,
                                         io_u->xfer_buf, fri->completion);
+ #endif
                if (r < 0) {
                        log_err("rbd_aio_write failed.\n");
                        goto failed_comp;
                }
  
        } else if (io_u->ddir == DDIR_READ) {
+ #ifdef CONFIG_RBD_BLKIN
+               blkin_init_trace_info(&fri->info);
+               r = rbd_aio_read_traced(rbd->image, io_u->offset, io_u->xfer_buflen,
+                                       io_u->xfer_buf, fri->completion, &fri->info);
+ #else
                r = rbd_aio_read(rbd->image, io_u->offset, io_u->xfer_buflen,
                                        io_u->xfer_buf, fri->completion);
+ #endif
  
                if (r < 0) {
                        log_err("rbd_aio_read failed.\n");
@@@ -452,7 -455,7 +468,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);
@@@ -480,7 -483,7 +496,7 @@@ static int fio_rbd_setup(struct thread_
                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
@@@ -539,7 -542,7 +555,7 @@@ static int fio_rbd_open(struct thread_d
  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