diff mbox

[v17,2/4] block/gluster: code cleanup

Message ID 1465979147-1993-3-git-send-email-prasanna.kalever@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prasanna Kumar Kalever June 15, 2016, 8:25 a.m. UTC
unified coding styles of multiline function arguments and other error functions
moved random declarations of structures and other list variables

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/gluster.c | 113 ++++++++++++++++++++++++++++++--------------------------
 1 file changed, 60 insertions(+), 53 deletions(-)

Comments

Jeff Cody June 17, 2016, 5:32 p.m. UTC | #1
On Wed, Jun 15, 2016 at 01:55:45PM +0530, Prasanna Kumar Kalever wrote:
> unified coding styles of multiline function arguments and other error functions
> moved random declarations of structures and other list variables
> 
> Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Jeff Cody <jcody@redhat.com>

> ---
>  block/gluster.c | 113 ++++++++++++++++++++++++++++++--------------------------
>  1 file changed, 60 insertions(+), 53 deletions(-)
> 
> diff --git a/block/gluster.c b/block/gluster.c
> index 0c711a3..45072b1 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -26,6 +26,11 @@ typedef struct BDRVGlusterState {
>      struct glfs_fd *fd;
>  } BDRVGlusterState;
>  
> +typedef struct BDRVGlusterReopenState {
> +    struct glfs *glfs;
> +    struct glfs_fd *fd;
> +} BDRVGlusterReopenState;
> +
>  typedef struct GlusterConf {
>      char *host;
>      int port;
> @@ -34,6 +39,39 @@ typedef struct GlusterConf {
>      char *transport;
>  } GlusterConf;
>  
> +
> +static QemuOptsList qemu_gluster_create_opts = {
> +    .name = "qemu-gluster-create-opts",
> +    .head = QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_opts.head),
> +    .desc = {
> +        {
> +            .name = BLOCK_OPT_SIZE,
> +            .type = QEMU_OPT_SIZE,
> +            .help = "Virtual disk size"
> +        },
> +        {
> +            .name = BLOCK_OPT_PREALLOC,
> +            .type = QEMU_OPT_STRING,
> +            .help = "Preallocation mode (allowed values: off, full)"
> +        },
> +        { /* end of list */ }
> +    }
> +};
> +
> +static QemuOptsList runtime_opts = {
> +    .name = "gluster",
> +    .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
> +    .desc = {
> +        {
> +            .name = "filename",
> +            .type = QEMU_OPT_STRING,
> +            .help = "URL to the gluster image",
> +        },
> +        { /* end of list */ }
> +    },
> +};
> +
> +
>  static void qemu_gluster_gconf_free(GlusterConf *gconf)
>  {
>      if (gconf) {
> @@ -178,7 +216,7 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
>      ret = qemu_gluster_parseuri(gconf, filename);
>      if (ret < 0) {
>          error_setg(errp, "Usage: file=gluster[+transport]://[host[:port]]/"
> -                   "volume/path[?socket=...]");
> +                         "volume/path[?socket=...]");
>          errno = -ret;
>          goto out;
>      }
> @@ -256,20 +294,6 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
>      qemu_bh_schedule(acb->bh);
>  }
>  
> -/* TODO Convert to fine grained options */
> -static QemuOptsList runtime_opts = {
> -    .name = "gluster",
> -    .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
> -    .desc = {
> -        {
> -            .name = "filename",
> -            .type = QEMU_OPT_STRING,
> -            .help = "URL to the gluster image",
> -        },
> -        { /* end of list */ }
> -    },
> -};
> -
>  static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
>  {
>      assert(open_flags != NULL);
> @@ -287,7 +311,7 @@ static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
>      }
>  }
>  
> -static int qemu_gluster_open(BlockDriverState *bs,  QDict *options,
> +static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
>                               int bdrv_flags, Error **errp)
>  {
>      BDRVGlusterState *s = bs->opaque;
> @@ -353,12 +377,6 @@ out:
>      return ret;
>  }
>  
> -typedef struct BDRVGlusterReopenState {
> -    struct glfs *glfs;
> -    struct glfs_fd *fd;
> -} BDRVGlusterReopenState;
> -
> -
>  static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
>                                         BlockReopenQueue *queue, Error **errp)
>  {
> @@ -455,7 +473,9 @@ static void qemu_gluster_reopen_abort(BDRVReopenState *state)
>  
>  #ifdef CONFIG_GLUSTERFS_ZEROFILL
>  static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
> -        int64_t offset, int size, BdrvRequestFlags flags)
> +                                                      int64_t offset,
> +                                                      int size,
> +                                                      BdrvRequestFlags flags)
>  {
>      int ret;
>      GlusterAIOCB acb;
> @@ -481,7 +501,7 @@ static inline bool gluster_supports_zerofill(void)
>  }
>  
>  static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,
> -        int64_t size)
> +                                        int64_t size)
>  {
>      return glfs_zerofill(fd, offset, size);
>  }
> @@ -493,7 +513,7 @@ static inline bool gluster_supports_zerofill(void)
>  }
>  
>  static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,
> -        int64_t size)
> +                                        int64_t size)
>  {
>      return 0;
>  }
> @@ -522,19 +542,17 @@ static int qemu_gluster_create(const char *filename,
>      tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
>      if (!tmp || !strcmp(tmp, "off")) {
>          prealloc = 0;
> -    } else if (!strcmp(tmp, "full") &&
> -               gluster_supports_zerofill()) {
> +    } else if (!strcmp(tmp, "full") && gluster_supports_zerofill()) {
>          prealloc = 1;
>      } else {
>          error_setg(errp, "Invalid preallocation mode: '%s'"
> -            " or GlusterFS doesn't support zerofill API",
> -            tmp);
> +                         " or GlusterFS doesn't support zerofill API", tmp);
>          ret = -EINVAL;
>          goto out;
>      }
>  
>      fd = glfs_creat(glfs, gconf->path,
> -        O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
> +                    O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
>      if (!fd) {
>          ret = -errno;
>      } else {
> @@ -560,7 +578,8 @@ out:
>  }
>  
>  static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
> -        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int write)
> +                                           int64_t sector_num, int nb_sectors,
> +                                           QEMUIOVector *qiov, int write)
>  {
>      int ret;
>      GlusterAIOCB acb;
> @@ -575,10 +594,10 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
>  
>      if (write) {
>          ret = glfs_pwritev_async(s->fd, qiov->iov, qiov->niov, offset, 0,
> -            gluster_finish_aiocb, &acb);
> +                                 gluster_finish_aiocb, &acb);
>      } else {
>          ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
> -            gluster_finish_aiocb, &acb);
> +                                gluster_finish_aiocb, &acb);
>      }
>  
>      if (ret < 0) {
> @@ -603,13 +622,17 @@ static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset)
>  }
>  
>  static coroutine_fn int qemu_gluster_co_readv(BlockDriverState *bs,
> -        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
> +                                              int64_t sector_num,
> +                                              int nb_sectors,
> +                                              QEMUIOVector *qiov)
>  {
>      return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 0);
>  }
>  
>  static coroutine_fn int qemu_gluster_co_writev(BlockDriverState *bs,
> -        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
> +                                               int64_t sector_num,
> +                                               int nb_sectors,
> +                                               QEMUIOVector *qiov)
>  {
>      return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 1);
>  }
> @@ -671,7 +694,8 @@ error:
>  
>  #ifdef CONFIG_GLUSTERFS_DISCARD
>  static coroutine_fn int qemu_gluster_co_discard(BlockDriverState *bs,
> -        int64_t sector_num, int nb_sectors)
> +                                                int64_t sector_num,
> +                                                int nb_sectors)
>  {
>      int ret;
>      GlusterAIOCB acb;
> @@ -727,23 +751,6 @@ static int qemu_gluster_has_zero_init(BlockDriverState *bs)
>      return 0;
>  }
>  
> -static QemuOptsList qemu_gluster_create_opts = {
> -    .name = "qemu-gluster-create-opts",
> -    .head = QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_opts.head),
> -    .desc = {
> -        {
> -            .name = BLOCK_OPT_SIZE,
> -            .type = QEMU_OPT_SIZE,
> -            .help = "Virtual disk size"
> -        },
> -        {
> -            .name = BLOCK_OPT_PREALLOC,
> -            .type = QEMU_OPT_STRING,
> -            .help = "Preallocation mode (allowed values: off, full)"
> -        },
> -        { /* end of list */ }
> -    }
> -};
>  
>  static BlockDriver bdrv_gluster = {
>      .format_name                  = "gluster",
> -- 
> 2.5.5
>
diff mbox

Patch

diff --git a/block/gluster.c b/block/gluster.c
index 0c711a3..45072b1 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -26,6 +26,11 @@  typedef struct BDRVGlusterState {
     struct glfs_fd *fd;
 } BDRVGlusterState;
 
+typedef struct BDRVGlusterReopenState {
+    struct glfs *glfs;
+    struct glfs_fd *fd;
+} BDRVGlusterReopenState;
+
 typedef struct GlusterConf {
     char *host;
     int port;
@@ -34,6 +39,39 @@  typedef struct GlusterConf {
     char *transport;
 } GlusterConf;
 
+
+static QemuOptsList qemu_gluster_create_opts = {
+    .name = "qemu-gluster-create-opts",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_opts.head),
+    .desc = {
+        {
+            .name = BLOCK_OPT_SIZE,
+            .type = QEMU_OPT_SIZE,
+            .help = "Virtual disk size"
+        },
+        {
+            .name = BLOCK_OPT_PREALLOC,
+            .type = QEMU_OPT_STRING,
+            .help = "Preallocation mode (allowed values: off, full)"
+        },
+        { /* end of list */ }
+    }
+};
+
+static QemuOptsList runtime_opts = {
+    .name = "gluster",
+    .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
+    .desc = {
+        {
+            .name = "filename",
+            .type = QEMU_OPT_STRING,
+            .help = "URL to the gluster image",
+        },
+        { /* end of list */ }
+    },
+};
+
+
 static void qemu_gluster_gconf_free(GlusterConf *gconf)
 {
     if (gconf) {
@@ -178,7 +216,7 @@  static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
     ret = qemu_gluster_parseuri(gconf, filename);
     if (ret < 0) {
         error_setg(errp, "Usage: file=gluster[+transport]://[host[:port]]/"
-                   "volume/path[?socket=...]");
+                         "volume/path[?socket=...]");
         errno = -ret;
         goto out;
     }
@@ -256,20 +294,6 @@  static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
     qemu_bh_schedule(acb->bh);
 }
 
-/* TODO Convert to fine grained options */
-static QemuOptsList runtime_opts = {
-    .name = "gluster",
-    .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
-    .desc = {
-        {
-            .name = "filename",
-            .type = QEMU_OPT_STRING,
-            .help = "URL to the gluster image",
-        },
-        { /* end of list */ }
-    },
-};
-
 static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
 {
     assert(open_flags != NULL);
@@ -287,7 +311,7 @@  static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
     }
 }
 
-static int qemu_gluster_open(BlockDriverState *bs,  QDict *options,
+static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
                              int bdrv_flags, Error **errp)
 {
     BDRVGlusterState *s = bs->opaque;
@@ -353,12 +377,6 @@  out:
     return ret;
 }
 
-typedef struct BDRVGlusterReopenState {
-    struct glfs *glfs;
-    struct glfs_fd *fd;
-} BDRVGlusterReopenState;
-
-
 static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
                                        BlockReopenQueue *queue, Error **errp)
 {
@@ -455,7 +473,9 @@  static void qemu_gluster_reopen_abort(BDRVReopenState *state)
 
 #ifdef CONFIG_GLUSTERFS_ZEROFILL
 static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
-        int64_t offset, int size, BdrvRequestFlags flags)
+                                                      int64_t offset,
+                                                      int size,
+                                                      BdrvRequestFlags flags)
 {
     int ret;
     GlusterAIOCB acb;
@@ -481,7 +501,7 @@  static inline bool gluster_supports_zerofill(void)
 }
 
 static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,
-        int64_t size)
+                                        int64_t size)
 {
     return glfs_zerofill(fd, offset, size);
 }
@@ -493,7 +513,7 @@  static inline bool gluster_supports_zerofill(void)
 }
 
 static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,
-        int64_t size)
+                                        int64_t size)
 {
     return 0;
 }
@@ -522,19 +542,17 @@  static int qemu_gluster_create(const char *filename,
     tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
     if (!tmp || !strcmp(tmp, "off")) {
         prealloc = 0;
-    } else if (!strcmp(tmp, "full") &&
-               gluster_supports_zerofill()) {
+    } else if (!strcmp(tmp, "full") && gluster_supports_zerofill()) {
         prealloc = 1;
     } else {
         error_setg(errp, "Invalid preallocation mode: '%s'"
-            " or GlusterFS doesn't support zerofill API",
-            tmp);
+                         " or GlusterFS doesn't support zerofill API", tmp);
         ret = -EINVAL;
         goto out;
     }
 
     fd = glfs_creat(glfs, gconf->path,
-        O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
+                    O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
     if (!fd) {
         ret = -errno;
     } else {
@@ -560,7 +578,8 @@  out:
 }
 
 static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
-        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int write)
+                                           int64_t sector_num, int nb_sectors,
+                                           QEMUIOVector *qiov, int write)
 {
     int ret;
     GlusterAIOCB acb;
@@ -575,10 +594,10 @@  static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
 
     if (write) {
         ret = glfs_pwritev_async(s->fd, qiov->iov, qiov->niov, offset, 0,
-            gluster_finish_aiocb, &acb);
+                                 gluster_finish_aiocb, &acb);
     } else {
         ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
-            gluster_finish_aiocb, &acb);
+                                gluster_finish_aiocb, &acb);
     }
 
     if (ret < 0) {
@@ -603,13 +622,17 @@  static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset)
 }
 
 static coroutine_fn int qemu_gluster_co_readv(BlockDriverState *bs,
-        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
+                                              int64_t sector_num,
+                                              int nb_sectors,
+                                              QEMUIOVector *qiov)
 {
     return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 0);
 }
 
 static coroutine_fn int qemu_gluster_co_writev(BlockDriverState *bs,
-        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
+                                               int64_t sector_num,
+                                               int nb_sectors,
+                                               QEMUIOVector *qiov)
 {
     return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 1);
 }
@@ -671,7 +694,8 @@  error:
 
 #ifdef CONFIG_GLUSTERFS_DISCARD
 static coroutine_fn int qemu_gluster_co_discard(BlockDriverState *bs,
-        int64_t sector_num, int nb_sectors)
+                                                int64_t sector_num,
+                                                int nb_sectors)
 {
     int ret;
     GlusterAIOCB acb;
@@ -727,23 +751,6 @@  static int qemu_gluster_has_zero_init(BlockDriverState *bs)
     return 0;
 }
 
-static QemuOptsList qemu_gluster_create_opts = {
-    .name = "qemu-gluster-create-opts",
-    .head = QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_opts.head),
-    .desc = {
-        {
-            .name = BLOCK_OPT_SIZE,
-            .type = QEMU_OPT_SIZE,
-            .help = "Virtual disk size"
-        },
-        {
-            .name = BLOCK_OPT_PREALLOC,
-            .type = QEMU_OPT_STRING,
-            .help = "Preallocation mode (allowed values: off, full)"
-        },
-        { /* end of list */ }
-    }
-};
 
 static BlockDriver bdrv_gluster = {
     .format_name                  = "gluster",