glusterfs: always allocate io_u->engine_data
authorsimon <simon29rock@gmail.com>
Tue, 3 Apr 2018 12:16:36 +0000 (20:16 +0800)
committersimon <simon29rock@gmail.com>
Tue, 3 Apr 2018 12:16:36 +0000 (20:16 +0800)
When the iodepth is greater then 1 some io_us in fio_gf_io_u_init() can
be fooled into thinking their .engine_data has already been set when it
hasn't. This happens because .index and .engine_data are part of the
same union and .index can be set to non-zero values:

static int init_io_u(struct thread_data *td)
...
        for (i = 0; i < max_units; i++) {
            ...
            io_u->index = i;
            ...
            if (td->io_ops->io_u_init) {
                int ret = td->io_ops->io_u_init(td, io_u);

which means io_u->engine_data != 0 in fio_gf_io_u_init().

Fix the issue by removing the initial check of io_u->engine_data.

Signed-off-by: Simon Gao <simon29rock@gmail.com>
engines/glusterfs_async.c

index 97271d67f13927f7c95e7e814df42df662f20058..eb8df453524d7d5de7dfbc3d84f53ae5d5fa57d7 100644 (file)
@@ -70,20 +70,17 @@ static void fio_gf_io_u_free(struct thread_data *td, struct io_u *io_u)
 
 static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u)
 {
+    struct fio_gf_iou *io;
        dprint(FD_FILE, "%s\n", __FUNCTION__);
-
-       if (!io_u->engine_data) {
-               struct fio_gf_iou *io;
-
-               io = malloc(sizeof(struct fio_gf_iou));
-               if (!io) {
-                       td_verror(td, errno, "malloc");
-                       return 1;
-               }
-               io->io_complete = 0;
-               io->io_u = io_u;
-               io_u->engine_data = io;
-       }
+    
+    io = malloc(sizeof(struct fio_gf_iou));
+    if (!io) {
+        td_verror(td, errno, "malloc");
+        return 1;
+    }
+    io->io_complete = 0;
+    io->io_u = io_u;
+    io_u->engine_data = io;
        return 0;
 }