Run the gluster engines through indent
authorJens Axboe <axboe@fb.com>
Mon, 19 May 2014 16:12:56 +0000 (10:12 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 19 May 2014 16:12:56 +0000 (10:12 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
engines/glusterfs.c
engines/glusterfs_async.c
engines/glusterfs_sync.c

index 230274af430001cba57aa0dda0d8f35130b9d3fe..b233b207eb49dec4e5477b16d83de48d1a7f31b0 100644 (file)
@@ -8,27 +8,27 @@
 #include "gfapi.h"
 
 struct fio_option gfapi_options[] = {
-    {
-        .name     = "volume",
-        .lname    = "Glusterfs volume",
-        .type     = FIO_OPT_STR_STORE,
-        .help     = "Name of the Glusterfs volume",
-        .off1     = offsetof(struct gf_options, gf_vol),
-        .category = FIO_OPT_C_ENGINE,
-        .group    = FIO_OPT_G_GFAPI,
-    },
-    {
-        .name     = "brick",
-        .lname    = "Glusterfs brick name",
-        .type     = FIO_OPT_STR_STORE,
-        .help     = "Name of the Glusterfs brick to connect",
-        .off1     = offsetof(struct gf_options, gf_brick),
-        .category = FIO_OPT_C_ENGINE,
-        .group    = FIO_OPT_G_GFAPI,
-    },
-    {
-        .name = NULL,
-    },
+       {
+        .name = "volume",
+        .lname = "Glusterfs volume",
+        .type = FIO_OPT_STR_STORE,
+        .help = "Name of the Glusterfs volume",
+        .off1 = offsetof(struct gf_options, gf_vol),
+        .category = FIO_OPT_C_ENGINE,
+        .group = FIO_OPT_G_GFAPI,
+        },
+       {
+        .name = "brick",
+        .lname = "Glusterfs brick name",
+        .type = FIO_OPT_STR_STORE,
+        .help = "Name of the Glusterfs brick to connect",
+        .off1 = offsetof(struct gf_options, gf_brick),
+        .category = FIO_OPT_C_ENGINE,
+        .group = FIO_OPT_G_GFAPI,
+        },
+       {
+        .name = NULL,
+        },
 };
 
 int fio_gf_setup(struct thread_data *td)
@@ -36,54 +36,56 @@ int fio_gf_setup(struct thread_data *td)
        int r = 0;
        struct gf_data *g = NULL;
        struct gf_options *opt = td->eo;
-    struct stat sb = {0, };
+       struct stat sb = { 0, };
 
        dprint(FD_IO, "fio setup\n");
 
        if (td->io_ops->data)
-           return 0;
+               return 0;
 
        g = malloc(sizeof(struct gf_data));
-       if (!g){
-           log_err("malloc failed.\n");
-           return -ENOMEM;
+       if (!g) {
+               log_err("malloc failed.\n");
+               return -ENOMEM;
        }
-       g->fs = NULL; g->fd = NULL; g->aio_events = NULL;
-
-       g->fs = glfs_new (opt->gf_vol);
-       if (!g->fs){
-           log_err("glfs_new failed.\n");
-           goto cleanup;
+       g->fs = NULL;
+       g->fd = NULL;
+       g->aio_events = NULL;
+
+       g->fs = glfs_new(opt->gf_vol);
+       if (!g->fs) {
+               log_err("glfs_new failed.\n");
+               goto cleanup;
        }
-       glfs_set_logging (g->fs, "/tmp/fio_gfapi.log", 7);
+       glfs_set_logging(g->fs, "/tmp/fio_gfapi.log", 7);
        /* default to tcp */
        r = glfs_set_volfile_server(g->fs, "tcp", opt->gf_brick, 0);
-       if (r){
-           log_err("glfs_set_volfile_server failed.\n");
-           goto cleanup;
+       if (r) {
+               log_err("glfs_set_volfile_server failed.\n");
+               goto cleanup;
        }
        r = glfs_init(g->fs);
-       if (r){
-           log_err("glfs_init failed. Is glusterd running on brick?\n");
-           goto cleanup;
+       if (r) {
+               log_err("glfs_init failed. Is glusterd running on brick?\n");
+               goto cleanup;
        }
        sleep(2);
-       r = glfs_lstat (g->fs, ".", &sb);
-       if (r){
-           log_err("glfs_lstat failed.\n");
-           goto cleanup;
+       r = glfs_lstat(g->fs, ".", &sb);
+       if (r) {
+               log_err("glfs_lstat failed.\n");
+               goto cleanup;
        }
        dprint(FD_FILE, "fio setup %p\n", g->fs);
        td->io_ops->data = g;
 cleanup:
-       if (r){
-           if (g){
-            if (g->fs){
-                glfs_fini(g->fs);
-            }
-            free(g);
-            td->io_ops->data = NULL;
-           }
+       if (r) {
+               if (g) {
+                       if (g->fs) {
+                               glfs_fini(g->fs);
+                       }
+                       free(g);
+                       td->io_ops->data = NULL;
+               }
        }
        return r;
 }
@@ -93,154 +95,170 @@ void fio_gf_cleanup(struct thread_data *td)
        struct gf_data *g = td->io_ops->data;
 
        if (g) {
-        if (g->aio_events)
-            free(g->aio_events);
-        if (g->fd)
-            glfs_close(g->fd);
-        if (g->fs)
-            glfs_fini(g->fs);
-        free(g);
-        td->io_ops->data = NULL;
+               if (g->aio_events)
+                       free(g->aio_events);
+               if (g->fd)
+                       glfs_close(g->fd);
+               if (g->fs)
+                       glfs_fini(g->fs);
+               free(g);
+               td->io_ops->data = NULL;
        }
 }
 
 int fio_gf_get_file_size(struct thread_data *td, struct fio_file *f)
 {
-    struct stat buf;
-    int ret;
-    struct gf_data *g = td->io_ops->data;
+       struct stat buf;
+       int ret;
+       struct gf_data *g = td->io_ops->data;
 
-    dprint(FD_FILE, "get file size %s\n", f->file_name);
+       dprint(FD_FILE, "get file size %s\n", f->file_name);
 
-    if (!g || !g->fs)
-    {
-        return 0;
-    }
-    if (fio_file_size_known(f))
-        return 0;
+       if (!g || !g->fs) {
+               return 0;
+       }
+       if (fio_file_size_known(f))
+               return 0;
 
-    ret = glfs_lstat (g->fs, f->file_name, &buf);
-    if (ret < 0){
-        log_err("glfs_lstat failed.\n");
-        return ret;
-    }
+       ret = glfs_lstat(g->fs, f->file_name, &buf);
+       if (ret < 0) {
+               log_err("glfs_lstat failed.\n");
+               return ret;
+       }
 
-    f->real_file_size = buf.st_size;
-    fio_file_set_size_known(f);
+       f->real_file_size = buf.st_size;
+       fio_file_set_size_known(f);
 
-    return 0;
+       return 0;
 
 }
 
 int fio_gf_open_file(struct thread_data *td, struct fio_file *f)
 {
 
-    int flags = 0;
-    int ret = 0;
-    struct gf_data *g = td->io_ops->data;
-    struct stat sb = {0, };
-
-    if (td_write(td)) {
-        if (!read_only)
-            flags = O_RDWR;
-    } else if (td_read(td)) {
-        if (!read_only)
-            flags = O_RDWR;
-        else
-            flags = O_RDONLY;
-    }
-    dprint(FD_FILE, "fio file %s open mode %s td rw %s\n", f->file_name,
-           flags == O_RDONLY? "ro":"rw", td_read(td)? "read":"write");
-    g->fd = glfs_creat(g->fs, f->file_name, flags, 0644);    
-    if (!g->fd){
-        log_err("glfs_creat failed.\n");
-        ret = errno;
-    }
-    /* file for read doesn't exist or shorter than required, create/extend it */
-    if (td_read(td)){
-        if (glfs_lstat (g->fs, f->file_name, &sb) || sb.st_size < f->real_file_size){
-            dprint(FD_FILE, "fio extend file %s from %ld to %ld\n", f->file_name, sb.st_size, f->real_file_size);
-            ret = glfs_ftruncate (g->fd, f->real_file_size);
-            if (ret){
-                log_err("failed fio extend file %s to %ld\n", f->file_name, f->real_file_size);
-            }else{
-                unsigned long long left;
-                unsigned int bs;
-                char *b;
-                int r;
-
-                /* fill the file, copied from extend_file */
-                b = malloc(td->o.max_bs[DDIR_WRITE]);
-
-                left = f->real_file_size;
-                while (left && !td->terminate) {
-                    bs = td->o.max_bs[DDIR_WRITE];
-                    if (bs > left)
-                        bs = left;
-
-                    fill_io_buffer(td, b, bs, bs);
-
-                    r = glfs_write(g->fd, b, bs, 0);
-                    dprint(FD_IO, "fio write %d of %ld file %s\n", r, f->real_file_size, f->file_name);
-
-                    if (r > 0) {
-                        left -= r;
-                        continue;
-                    } else {
-                        if (r < 0) {
-                            int __e = errno;
-
-                            if (__e == ENOSPC) {
-                                if (td->o.fill_device)
-                                    break;
-                                log_info("fio: ENOSPC on laying out "
-                                         "file, stopping\n");
-                                break;
-                            }
-                            td_verror(td, errno, "write");
-                        } else
-                            td_verror(td, EIO, "write");
-
-                        break;
-                    }
-                }
-
-                if (b) free(b);
-                glfs_lseek(g->fd, 0, SEEK_SET);
-
-                if (td->terminate) {
-                    dprint(FD_FILE, "terminate unlink %s\n", f->file_name);
-                    unlink(f->file_name);
-                } else if (td->o.create_fsync) {
-                    if (glfs_fsync(g->fd) < 0) {
-                        dprint(FD_FILE, "failed to sync, close %s\n", f->file_name);
-                        td_verror(td, errno, "fsync");
-                        glfs_close(g->fd);
-                        g->fd = NULL;
-                        return 1;
-                    }
-                }
-            }
-        }
-    }
+       int flags = 0;
+       int ret = 0;
+       struct gf_data *g = td->io_ops->data;
+       struct stat sb = { 0, };
+
+       if (td_write(td)) {
+               if (!read_only)
+                       flags = O_RDWR;
+       } else if (td_read(td)) {
+               if (!read_only)
+                       flags = O_RDWR;
+               else
+                       flags = O_RDONLY;
+       }
+       dprint(FD_FILE, "fio file %s open mode %s td rw %s\n", f->file_name,
+              flags == O_RDONLY ? "ro" : "rw", td_read(td) ? "read" : "write");
+       g->fd = glfs_creat(g->fs, f->file_name, flags, 0644);
+       if (!g->fd) {
+               log_err("glfs_creat failed.\n");
+               ret = errno;
+       }
+       /* file for read doesn't exist or shorter than required, create/extend it */
+       if (td_read(td)) {
+               if (glfs_lstat(g->fs, f->file_name, &sb)
+                   || sb.st_size < f->real_file_size) {
+                       dprint(FD_FILE, "fio extend file %s from %ld to %ld\n",
+                              f->file_name, sb.st_size, f->real_file_size);
+                       ret = glfs_ftruncate(g->fd, f->real_file_size);
+                       if (ret) {
+                               log_err("failed fio extend file %s to %ld\n",
+                                       f->file_name, f->real_file_size);
+                       } else {
+                               unsigned long long left;
+                               unsigned int bs;
+                               char *b;
+                               int r;
+
+                               /* fill the file, copied from extend_file */
+                               b = malloc(td->o.max_bs[DDIR_WRITE]);
+
+                               left = f->real_file_size;
+                               while (left && !td->terminate) {
+                                       bs = td->o.max_bs[DDIR_WRITE];
+                                       if (bs > left)
+                                               bs = left;
+
+                                       fill_io_buffer(td, b, bs, bs);
+
+                                       r = glfs_write(g->fd, b, bs, 0);
+                                       dprint(FD_IO,
+                                              "fio write %d of %ld file %s\n",
+                                              r, f->real_file_size,
+                                              f->file_name);
+
+                                       if (r > 0) {
+                                               left -= r;
+                                               continue;
+                                       } else {
+                                               if (r < 0) {
+                                                       int __e = errno;
+
+                                                       if (__e == ENOSPC) {
+                                                               if (td->o.
+                                                                   fill_device)
+                                                                       break;
+                                                               log_info
+                                                                   ("fio: ENOSPC on laying out "
+                                                                    "file, stopping\n");
+                                                               break;
+                                                       }
+                                                       td_verror(td, errno,
+                                                                 "write");
+                                               } else
+                                                       td_verror(td, EIO,
+                                                                 "write");
+
+                                               break;
+                                       }
+                               }
+
+                               if (b)
+                                       free(b);
+                               glfs_lseek(g->fd, 0, SEEK_SET);
+
+                               if (td->terminate) {
+                                       dprint(FD_FILE, "terminate unlink %s\n",
+                                              f->file_name);
+                                       unlink(f->file_name);
+                               } else if (td->o.create_fsync) {
+                                       if (glfs_fsync(g->fd) < 0) {
+                                               dprint(FD_FILE,
+                                                      "failed to sync, close %s\n",
+                                                      f->file_name);
+                                               td_verror(td, errno, "fsync");
+                                               glfs_close(g->fd);
+                                               g->fd = NULL;
+                                               return 1;
+                                       }
+                               }
+                       }
+               }
+       }
 #if defined(GFAPI_USE_FADVISE)
-    {
-        int r = 0; 
-        if (td_random(td)){
-            r = glfs_fadvise(g->fd, 0, f->real_file_size, POSIX_FADV_RANDOM);
-        }else{
-            r = glfs_fadvise(g->fd, 0, f->real_file_size, POSIX_FADV_SEQUENTIAL);
-        }
-        if (r){
-            dprint(FD_FILE, "fio %p fadvise %s status %d\n", g->fs, f->file_name, r);
-        }
-    }
+       {
+               int r = 0;
+               if (td_random(td)) {
+                       r = glfs_fadvise(g->fd, 0, f->real_file_size,
+                                        POSIX_FADV_RANDOM);
+               } else {
+                       r = glfs_fadvise(g->fd, 0, f->real_file_size,
+                                        POSIX_FADV_SEQUENTIAL);
+               }
+               if (r) {
+                       dprint(FD_FILE, "fio %p fadvise %s status %d\n", g->fs,
+                              f->file_name, r);
+               }
+       }
 #endif
-    dprint(FD_FILE, "fio %p created %s\n", g->fs, f->file_name);
-    f->fd = -1;
-    f->shadow_fd = -1;    
+       dprint(FD_FILE, "fio %p created %s\n", g->fs, f->file_name);
+       f->fd = -1;
+       f->shadow_fd = -1;
 
-    return ret;
+       return ret;
 }
 
 int fio_gf_close_file(struct thread_data *td, struct fio_file *f)
@@ -250,19 +268,18 @@ int fio_gf_close_file(struct thread_data *td, struct fio_file *f)
 
        dprint(FD_FILE, "fd close %s\n", f->file_name);
 
-    if (g){
-        if (g->fd && glfs_close(g->fd) < 0)
-            ret = errno;
+       if (g) {
+               if (g->fd && glfs_close(g->fd) < 0)
+                       ret = errno;
 
-        if (g->fs)
-            glfs_fini(g->fs);
+               if (g->fs)
+                       glfs_fini(g->fs);
 
-        g->fd = NULL;
-        free(g);
-    }
+               g->fd = NULL;
+               free(g);
+       }
        td->io_ops->data = NULL;
        f->engine_data = 0;
 
        return ret;
 }
-
index bea95497a480a53a090f1cd790af26bba3dc2ef9..30f1719df6177b3166b87976cb68155719958953 100644 (file)
@@ -20,7 +20,7 @@ static struct io_u *fio_gf_event(struct thread_data *td, int event)
 }
 
 static int fio_gf_getevents(struct thread_data *td, unsigned int min,
-                            unsigned int max, struct timespec *t)
+                           unsigned int max, struct timespec *t)
 {
        struct gf_data *g = td->io_ops->data;
        unsigned int events = 0;
@@ -41,8 +41,8 @@ static int fio_gf_getevents(struct thread_data *td, unsigned int min,
                                g->aio_events[events] = io_u;
                                events++;
 
-                if (events >= max) 
-                    break;
+                               if (events >= max)
+                                       break;
                        }
 
                }
@@ -61,13 +61,13 @@ static void fio_gf_io_u_free(struct thread_data *td, struct io_u *io_u)
        struct fio_gf_iou *io = io_u->engine_data;
 
        if (io) {
-        if (io->io_complete){
-            log_err("incomplete IO found.\n");
-        }
+               if (io->io_complete) {
+                       log_err("incomplete IO found.\n");
+               }
                io_u->engine_data = NULL;
                free(io);
        }
-    fprintf(stderr, "issued %lu finished %lu\n", issued, cb_count);
+       fprintf(stderr, "issued %lu finished %lu\n", issued, cb_count);
 }
 
 static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u)
@@ -76,59 +76,63 @@ static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u)
 
        dprint(FD_FILE, "%s\n", __FUNCTION__);
 
-    if (!io_u->engine_data){
-        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;
-    }
+       if (!io_u->engine_data) {
+               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;
 }
 
-static void gf_async_cb(glfs_fd_t *fd, ssize_t ret, void *data) 
+static void gf_async_cb(glfs_fd_t * fd, ssize_t ret, void *data)
 {
        struct io_u *io_u = (struct io_u *)data;
-       struct fio_gf_iou *iou =
-           (struct fio_gf_iou *)io_u->engine_data;
+       struct fio_gf_iou *iou = (struct fio_gf_iou *)io_u->engine_data;
 
-    dprint(FD_IO, "%s ret %lu\n", __FUNCTION__, ret);    
-    iou->io_complete = 1;
-    cb_count ++;
+       dprint(FD_IO, "%s ret %lu\n", __FUNCTION__, ret);
+       iou->io_complete = 1;
+       cb_count++;
 }
 
-static int fio_gf_async_queue(struct thread_data fio_unused *td, struct io_u *io_u)
+static int fio_gf_async_queue(struct thread_data fio_unused * td,
+                             struct io_u *io_u)
 {
        struct gf_data *g = td->io_ops->data;
-    int r = 0;
+       int r = 0;
 
-    dprint(FD_IO, "%s op %s\n", __FUNCTION__,  
-           io_u->ddir == DDIR_READ? "read": io_u->ddir == DDIR_WRITE? "write":io_u->ddir == DDIR_SYNC? "sync":"unknown");    
+       dprint(FD_IO, "%s op %s\n", __FUNCTION__,
+              io_u->ddir == DDIR_READ ? "read" : io_u->ddir ==
+              DDIR_WRITE ? "write" : io_u->ddir ==
+              DDIR_SYNC ? "sync" : "unknown");
 
        fio_ro_check(td, io_u);
 
        if (io_u->ddir == DDIR_READ)
-               r = glfs_pread_async(g->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset,
-                         0, gf_async_cb, (void *)io_u);
+               r = glfs_pread_async(g->fd, io_u->xfer_buf, io_u->xfer_buflen,
+                                    io_u->offset, 0, gf_async_cb,
+                                    (void *)io_u);
        else if (io_u->ddir == DDIR_WRITE)
-               r = glfs_pwrite_async(g->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset,
-                         0, gf_async_cb, (void *)io_u);
-    else if (io_u->ddir == DDIR_SYNC) {
-        r = glfs_fsync_async(g->fd, gf_async_cb, (void *)io_u);
-    }else {        
-        log_err("unsupported operation.\n");
-        io_u->error = -EINVAL;
-        goto failed;
-    }
-    if (r){
-        log_err("glfs failed.\n");
-        io_u->error = r;
-        goto failed;
-    }
-    issued ++;
+               r = glfs_pwrite_async(g->fd, io_u->xfer_buf, io_u->xfer_buflen,
+                                     io_u->offset, 0, gf_async_cb,
+                                     (void *)io_u);
+       else if (io_u->ddir == DDIR_SYNC) {
+               r = glfs_fsync_async(g->fd, gf_async_cb, (void *)io_u);
+       } else {
+               log_err("unsupported operation.\n");
+               io_u->error = -EINVAL;
+               goto failed;
+       }
+       if (r) {
+               log_err("glfs failed.\n");
+               io_u->error = r;
+               goto failed;
+       }
+       issued++;
        return FIO_Q_QUEUED;
 
 failed:
@@ -142,24 +146,24 @@ int fio_gf_async_setup(struct thread_data *td)
        int r = 0;
        struct gf_data *g = NULL;
 #if defined(NOT_YET)
-    fprintf(stderr, "the async interface is still very experimental...\n");
+       fprintf(stderr, "the async interface is still very experimental...\n");
 #endif
-    r = fio_gf_setup(td);
-    if (r){
-        return r;
-    }
+       r = fio_gf_setup(td);
+       if (r) {
+               return r;
+       }
        td->o.use_thread = 1;
-    g = td->io_ops->data;
-    g->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *));
-       if (!g->aio_events){
-        r = -ENOMEM;
-        fio_gf_cleanup(td);
-        return r;
-    }
+       g = td->io_ops->data;
+       g->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *));
+       if (!g->aio_events) {
+               r = -ENOMEM;
+               fio_gf_cleanup(td);
+               return r;
+       }
 
        memset(g->aio_events, 0, td->o.iodepth * sizeof(struct io_u *));
 
-    return r;
+       return r;
 
 }
 
@@ -174,30 +178,30 @@ static int fio_gf_async_prep(struct thread_data *td, struct io_u *io_u)
 }
 
 static struct ioengine_ops ioengine = {
-       .name               = "gfapi_async",
-       .version            = FIO_IOOPS_VERSION,
-       .init           = fio_gf_async_setup,
-       .cleanup        = fio_gf_cleanup,
-    .prep           = fio_gf_async_prep,
-       .queue              = fio_gf_async_queue,
-       .open_file          = fio_gf_open_file,
-       .close_file         = fio_gf_close_file,
-       .get_file_size  = fio_gf_get_file_size,
-       .getevents      = fio_gf_getevents,
-       .event          = fio_gf_event,
-       .io_u_init      = fio_gf_io_u_init,
-       .io_u_free      = fio_gf_io_u_free,
-       .options        = gfapi_options,
+       .name = "gfapi_async",
+       .version = FIO_IOOPS_VERSION,
+       .init = fio_gf_async_setup,
+       .cleanup = fio_gf_cleanup,
+       .prep = fio_gf_async_prep,
+       .queue = fio_gf_async_queue,
+       .open_file = fio_gf_open_file,
+       .close_file = fio_gf_close_file,
+       .get_file_size = fio_gf_get_file_size,
+       .getevents = fio_gf_getevents,
+       .event = fio_gf_event,
+       .io_u_init = fio_gf_io_u_init,
+       .io_u_free = fio_gf_io_u_free,
+       .options = gfapi_options,
        .option_struct_size = sizeof(struct gf_options),
-       .flags              = FIO_DISKLESSIO,
+       .flags = FIO_DISKLESSIO,
 };
 
 static void fio_init fio_gf_register(void)
 {
-    register_ioengine(&ioengine);
+       register_ioengine(&ioengine);
 }
 
 static void fio_exit fio_gf_unregister(void)
 {
-    unregister_ioengine(&ioengine);
+       unregister_ioengine(&ioengine);
 }
index cff642774f12d5bb454b8b0ce679e30dd8d31572..938baf46d0eeac32ac9b7178ece129d8c17581a7 100644 (file)
@@ -31,63 +31,63 @@ static int fio_gf_prep(struct thread_data *td, struct io_u *io_u)
 
 static int fio_gf_queue(struct thread_data *td, struct io_u *io_u)
 {
-    struct gf_data *g = td->io_ops->data;
-    int ret = 0;
-
-    dprint(FD_FILE, "fio queue len %lu\n", io_u->xfer_buflen);
-    fio_ro_check(td, io_u);
-
-    if (io_u->ddir == DDIR_READ)
-        ret = glfs_read(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0);
-    else if (io_u->ddir == DDIR_WRITE)
-        ret = glfs_write(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0);
-    else {         
-        log_err("unsupported operation.\n");
-        return -EINVAL;
-    }
-    dprint(FD_FILE, "fio len %lu ret %d\n", io_u->xfer_buflen, ret);
-    if (io_u->file && ret >= 0 && ddir_rw(io_u->ddir))
-        LAST_POS(io_u->file) = io_u->offset + ret;
-
-    if (ret != (int) io_u->xfer_buflen) {
-        if (ret >= 0) {
-            io_u->resid = io_u->xfer_buflen - ret;
-            io_u->error = 0;
-            return FIO_Q_COMPLETED;
-        } else
-            io_u->error = errno;
-    }
-
-    if (io_u->error){
-        log_err("IO failed.\n");
-        td_verror(td, io_u->error, "xfer");
-    }
-
-    return FIO_Q_COMPLETED;
+       struct gf_data *g = td->io_ops->data;
+       int ret = 0;
+
+       dprint(FD_FILE, "fio queue len %lu\n", io_u->xfer_buflen);
+       fio_ro_check(td, io_u);
+
+       if (io_u->ddir == DDIR_READ)
+               ret = glfs_read(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0);
+       else if (io_u->ddir == DDIR_WRITE)
+               ret = glfs_write(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0);
+       else {
+               log_err("unsupported operation.\n");
+               return -EINVAL;
+       }
+       dprint(FD_FILE, "fio len %lu ret %d\n", io_u->xfer_buflen, ret);
+       if (io_u->file && ret >= 0 && ddir_rw(io_u->ddir))
+               LAST_POS(io_u->file) = io_u->offset + ret;
+
+       if (ret != (int)io_u->xfer_buflen) {
+               if (ret >= 0) {
+                       io_u->resid = io_u->xfer_buflen - ret;
+                       io_u->error = 0;
+                       return FIO_Q_COMPLETED;
+               } else
+                       io_u->error = errno;
+       }
+
+       if (io_u->error) {
+               log_err("IO failed.\n");
+               td_verror(td, io_u->error, "xfer");
+       }
+
+       return FIO_Q_COMPLETED;
 
 }
 
 static struct ioengine_ops ioengine = {
-       .name               = "gfapi",
-       .version            = FIO_IOOPS_VERSION,
-       .init           = fio_gf_setup,
-       .cleanup        = fio_gf_cleanup,
-       .prep               = fio_gf_prep,
-       .queue              = fio_gf_queue,
-       .open_file          = fio_gf_open_file,
-       .close_file         = fio_gf_close_file,
-       .get_file_size  = fio_gf_get_file_size,
-       .options        = gfapi_options,
+       .name = "gfapi",
+       .version = FIO_IOOPS_VERSION,
+       .init = fio_gf_setup,
+       .cleanup = fio_gf_cleanup,
+       .prep = fio_gf_prep,
+       .queue = fio_gf_queue,
+       .open_file = fio_gf_open_file,
+       .close_file = fio_gf_close_file,
+       .get_file_size = fio_gf_get_file_size,
+       .options = gfapi_options,
        .option_struct_size = sizeof(struct gf_options),
-       .flags              = FIO_SYNCIO | FIO_DISKLESSIO,
+       .flags = FIO_SYNCIO | FIO_DISKLESSIO,
 };
 
 static void fio_init fio_gf_register(void)
 {
-    register_ioengine(&ioengine);
+       register_ioengine(&ioengine);
 }
 
 static void fio_exit fio_gf_unregister(void)
 {
-    unregister_ioengine(&ioengine);
+       unregister_ioengine(&ioengine);
 }