Run the gluster engines through indent
[fio.git] / engines / glusterfs_async.c
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);
 }