From patchwork Wed Jul 20 00:20:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9238585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 96FE26075D for ; Wed, 20 Jul 2016 00:33:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 830521FF15 for ; Wed, 20 Jul 2016 00:33:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7670E268AE; Wed, 20 Jul 2016 00:33:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AF3BB1FF15 for ; Wed, 20 Jul 2016 00:33:03 +0000 (UTC) Received: from localhost ([::1]:59752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPfRe-0007qr-LP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Jul 2016 20:33:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPfGa-0000h7-Ao for qemu-devel@nongnu.org; Tue, 19 Jul 2016 20:21:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPfGX-0000vI-Tr for qemu-devel@nongnu.org; Tue, 19 Jul 2016 20:21:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPfGR-0000tY-1A; Tue, 19 Jul 2016 20:21:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4ADF70AA5; Wed, 20 Jul 2016 00:21:26 +0000 (UTC) Received: from localhost (ovpn-112-23.phx2.redhat.com [10.3.112.23]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6K0LOMW022560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 19 Jul 2016 20:21:25 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 19 Jul 2016 20:20:59 -0400 Message-Id: <1468974062-7726-12-git-send-email-jcody@redhat.com> In-Reply-To: <1468974062-7726-1-git-send-email-jcody@redhat.com> References: <1468974062-7726-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Jul 2016 00:21:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/14] block/gluster: code cleanup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Prasanna Kumar Kalever 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 Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Message-id: 1468947453-5433-3-git-send-email-prasanna.kalever@redhat.com Signed-off-by: Jeff Cody --- block/gluster.c | 143 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 75 insertions(+), 68 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 26478b0..4fce2ee 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -13,6 +13,12 @@ #include "qapi/error.h" #include "qemu/uri.h" +#define GLUSTER_OPT_FILENAME "filename" +#define GLUSTER_OPT_DEBUG "debug" +#define GLUSTER_DEBUG_DEFAULT 4 +#define GLUSTER_DEBUG_MAX 9 + + typedef struct GlusterAIOCB { int64_t size; int ret; @@ -28,6 +34,11 @@ typedef struct BDRVGlusterState { int debug_level; } BDRVGlusterState; +typedef struct BDRVGlusterReopenState { + struct glfs *glfs; + struct glfs_fd *fd; +} BDRVGlusterReopenState; + typedef struct GlusterConf { char *host; int port; @@ -37,6 +48,49 @@ typedef struct GlusterConf { int debug_level; } 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)" + }, + { + .name = GLUSTER_OPT_DEBUG, + .type = QEMU_OPT_NUMBER, + .help = "Gluster log level, valid range is 0-9", + }, + { /* end of list */ } + } +}; + +static QemuOptsList runtime_opts = { + .name = "gluster", + .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), + .desc = { + { + .name = GLUSTER_OPT_FILENAME, + .type = QEMU_OPT_STRING, + .help = "URL to the gluster image", + }, + { + .name = GLUSTER_OPT_DEBUG, + .type = QEMU_OPT_NUMBER, + .help = "Gluster log level, valid range is 0-9", + }, + { /* end of list */ } + }, +}; + + static void qemu_gluster_gconf_free(GlusterConf *gconf) { if (gconf) { @@ -181,7 +235,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; } @@ -255,30 +309,6 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg) qemu_bh_schedule(acb->bh); } -#define GLUSTER_OPT_FILENAME "filename" -#define GLUSTER_OPT_DEBUG "debug" -#define GLUSTER_DEBUG_DEFAULT 4 -#define GLUSTER_DEBUG_MAX 9 - -/* TODO Convert to fine grained options */ -static QemuOptsList runtime_opts = { - .name = "gluster", - .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), - .desc = { - { - .name = GLUSTER_OPT_FILENAME, - .type = QEMU_OPT_STRING, - .help = "URL to the gluster image", - }, - { - .name = GLUSTER_OPT_DEBUG, - .type = QEMU_OPT_NUMBER, - .help = "Gluster log level, valid range is 0-9", - }, - { /* end of list */ } - }, -}; - static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags) { assert(open_flags != NULL); @@ -395,12 +425,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) { @@ -501,7 +525,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; @@ -527,7 +553,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); } @@ -539,7 +565,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; } @@ -576,19 +602,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 { @@ -614,7 +638,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; @@ -629,10 +654,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) { @@ -657,13 +682,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); } @@ -725,7 +754,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; @@ -934,29 +964,6 @@ static int64_t coroutine_fn qemu_gluster_co_get_block_status( } -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)" - }, - { - .name = GLUSTER_OPT_DEBUG, - .type = QEMU_OPT_NUMBER, - .help = "Gluster log level, valid range is 0-9", - }, - { /* end of list */ } - } -}; - static BlockDriver bdrv_gluster = { .format_name = "gluster", .protocol_name = "gluster",