examples: remove test.png
[fio.git] / engines / rdma.c
index 67c5aa7e23eb1f65b47ea5ad4b93886b630f2e82..fcb41068896de230ad4cd7f2b83064045eb0f122 100644 (file)
@@ -226,7 +226,8 @@ static int client_recv(struct thread_data *td, struct ibv_wc *wc)
                rd->rmt_nr = ntohl(rd->recv_buf.nr);
 
                for (i = 0; i < rd->rmt_nr; i++) {
-                       rd->rmt_us[i].buf = be64_to_cpu(rd->recv_buf.rmt_us[i].buf);
+                       rd->rmt_us[i].buf = __be64_to_cpu(
+                                               rd->recv_buf.rmt_us[i].buf);
                        rd->rmt_us[i].rkey = ntohl(rd->recv_buf.rmt_us[i].rkey);
                        rd->rmt_us[i].size = ntohl(rd->recv_buf.rmt_us[i].size);
 
@@ -791,8 +792,8 @@ static int fio_rdmaio_recv(struct thread_data *td, struct io_u **io_us,
        return i;
 }
 
-static enum fio_q_status
-fio_rdmaio_queue(struct thread_data *td, struct io_u *io_u)
+static enum fio_q_status fio_rdmaio_queue(struct thread_data *td,
+                                         struct io_u *io_u)
 {
        struct rdmaio_data *rd = td->io_ops_data;
 
@@ -831,6 +832,12 @@ static void fio_rdmaio_queued(struct thread_data *td, struct io_u **io_us,
                memcpy(&io_u->issue_time, &now, sizeof(now));
                io_u_queued(td, io_u);
        }
+
+       /*
+        * only used for iolog
+        */
+       if (td->o.read_iolog_file)
+               memcpy(&td->last_issue, &now, sizeof(now));
 }
 
 static int fio_rdmaio_commit(struct thread_data *td)
@@ -1050,7 +1057,7 @@ static int fio_rdmaio_setup_connect(struct thread_data *td, const char *host,
                return err;
 
        /* resolve route */
-       if (strcmp(o->bindname, "") != 0) {
+       if (o->bindname && strlen(o->bindname)) {
                addrb.ss_family = AF_INET;
                err = aton(td, o->bindname, (struct sockaddr_in *)&addrb);
                if (err)
@@ -1116,7 +1123,7 @@ static int fio_rdmaio_setup_listen(struct thread_data *td, short port)
        rd->addr.sin_family = AF_INET;
        rd->addr.sin_port = htons(port);
 
-       if (strcmp(o->bindname, "") == 0)
+       if (!o->bindname || !strlen(o->bindname))
                rd->addr.sin_addr.s_addr = htonl(INADDR_ANY);
        else
                rd->addr.sin_addr.s_addr = htonl(*o->bindname);
@@ -1193,7 +1200,7 @@ static int check_set_rlimits(struct thread_data *td)
 
 static int compat_options(struct thread_data *td)
 {
-       // The original RDMA engine had an ugly / seperator
+       // The original RDMA engine had an ugly / separator
        // on the filename for it's options. This function
        // retains backwards compatibility with it. Note we do not
        // support setting the bindname option is this legacy mode.
@@ -1249,8 +1256,7 @@ static int fio_rdmaio_init(struct thread_data *td)
 {
        struct rdmaio_data *rd = td->io_ops_data;
        struct rdmaio_options *o = td->eo;
-       unsigned int max_bs;
-       int ret, i;
+       int ret;
 
        if (td_rw(td)) {
                log_err("fio: rdma connections must be read OR write\n");
@@ -1318,6 +1324,13 @@ static int fio_rdmaio_init(struct thread_data *td)
                rd->is_client = 1;
                ret = fio_rdmaio_setup_connect(td, td->o.filename, o->port);
        }
+       return ret;
+}
+static int fio_rdmaio_post_init(struct thread_data *td)
+{
+       unsigned int max_bs;
+       int i;
+       struct rdmaio_data *rd = td->io_ops_data;
 
        max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]);
        rd->send_buf.max_bs = htonl(max_bs);
@@ -1351,7 +1364,7 @@ static int fio_rdmaio_init(struct thread_data *td)
 
        rd->send_buf.nr = htonl(i);
 
-       return ret;
+       return 0;
 }
 
 static void fio_rdmaio_cleanup(struct thread_data *td)
@@ -1376,18 +1389,19 @@ static int fio_rdmaio_setup(struct thread_data *td)
                rd = malloc(sizeof(*rd));
 
                memset(rd, 0, sizeof(*rd));
-               init_rand_seed(&rd->rand_state, (unsigned int) GOLDEN_RATIO_PRIME, 0);
+               init_rand_seed(&rd->rand_state, (unsigned int) GOLDEN_RATIO_64, 0);
                td->io_ops_data = rd;
        }
 
        return 0;
 }
 
-static struct ioengine_ops ioengine_rw = {
+FIO_STATIC struct ioengine_ops ioengine = {
        .name                   = "rdma",
        .version                = FIO_IOOPS_VERSION,
        .setup                  = fio_rdmaio_setup,
        .init                   = fio_rdmaio_init,
+       .post_init              = fio_rdmaio_post_init,
        .prep                   = fio_rdmaio_prep,
        .queue                  = fio_rdmaio_queue,
        .commit                 = fio_rdmaio_commit,
@@ -1396,17 +1410,18 @@ static struct ioengine_ops ioengine_rw = {
        .cleanup                = fio_rdmaio_cleanup,
        .open_file              = fio_rdmaio_open_file,
        .close_file             = fio_rdmaio_close_file,
-       .flags                  = FIO_DISKLESSIO | FIO_UNIDIR | FIO_PIPEIO,
+       .flags                  = FIO_DISKLESSIO | FIO_UNIDIR | FIO_PIPEIO |
+                                       FIO_ASYNCIO_SETS_ISSUE_TIME,
        .options                = options,
        .option_struct_size     = sizeof(struct rdmaio_options),
 };
 
 static void fio_init fio_rdmaio_register(void)
 {
-       register_ioengine(&ioengine_rw);
+       register_ioengine(&ioengine);
 }
 
 static void fio_exit fio_rdmaio_unregister(void)
 {
-       unregister_ioengine(&ioengine_rw);
+       unregister_ioengine(&ioengine);
 }