solaris: fix compile error on ctime_r()
[fio.git] / ioengines.c
index e8ed871d2d96d641014cbd79e7e4df27c6b472a3..c2a64cb092786519746ef82111e19bd1a79300fb 100644 (file)
@@ -104,7 +104,9 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
         * Unlike the included modules, external engines should have a
         * non-static ioengine structure that we can reference.
         */
-       ops = dlsym(dlhandle, "ioengine");
+       ops = dlsym(dlhandle, engine_lib);
+       if (!ops)
+               ops = dlsym(dlhandle, "ioengine");
        if (!ops) {
                td_vmsg(td, -1, dlerror(), "dlsym");
                dlclose(dlhandle);
@@ -208,6 +210,16 @@ int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max,
 {
        int r = 0;
 
+       /*
+        * For ioengine=rdma one side operation RDMA_WRITE or RDMA_READ,
+        * server side gets a message from the client
+        * side that the task is finished, and
+        * td->done is set to 1 after td_io_commit(). In this case,
+        * there is no need to reap complete event in server side.
+        */
+       if (td->done)
+               return 0;
+
        if (min > 0 && td->io_ops->commit) {
                r = td->io_ops->commit(td);
                if (r < 0)
@@ -222,9 +234,14 @@ int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max,
        if (max && td->io_ops->getevents)
                r = td->io_ops->getevents(td, min, max, t);
 out:
-       if (r >= 0)
+       if (r >= 0) {
+               /*
+                * Reflect that our submitted requests were retrieved with
+                * whatever OS async calls are in the underlying engine.
+                */
+               td->io_u_in_flight -= r;
                io_u_mark_complete(td, r);
-       else
+       else
                td_verror(td, r, "get_events");
 
        dprint(FD_IO, "getevents: %d\n", r);
@@ -273,11 +290,12 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
         */
        if (io_u->error == EINVAL && td->io_issues[io_u->ddir & 1] == 1 &&
            td->o.odirect) {
+
                log_info("fio: first direct IO errored. File system may not "
                         "support direct IO, or iomem_align= is bad.\n");
        }
 
-       if (!td->io_ops->commit) {
+       if (!td->io_ops->commit || ddir_trim(io_u->ddir)) {
                io_u_mark_submit(td, 1);
                io_u_mark_complete(td, 1);
        }
@@ -286,8 +304,7 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
                if (ddir_rw(io_u->ddir)) {
                        io_u_mark_depth(td, 1);
                        td->ts.total_io_u[io_u->ddir]++;
-               } else if (io_u->ddir == DDIR_TRIM)
-                       td->ts.total_io_u[2]++;
+               }
        } else if (ret == FIO_Q_QUEUED) {
                int r;
 
@@ -344,14 +361,19 @@ int td_io_commit(struct thread_data *td)
        if (!td->cur_depth || !td->io_u_queued)
                return 0;
 
-       io_u_mark_depth(td, td->io_u_queued);
-       td->io_u_queued = 0;
+       io_u_mark_depth(td, td->io_u_queued);   
 
        if (td->io_ops->commit) {
                ret = td->io_ops->commit(td);
                if (ret)
                        td_verror(td, -ret, "io commit");
        }
+       
+       /*
+        * Reflect that events were submitted as async IO requests.
+        */
+       td->io_u_in_flight += td->io_u_queued;
+       td->io_u_queued = 0;
 
        return 0;
 }