From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
bharata@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 1/2] block: gluster - code movements, state storage changes
Date: Wed, 5 Feb 2014 20:25:36 +0100 [thread overview]
Message-ID: <20140205192535.GA3440@irqsave.net> (raw)
In-Reply-To: <925f4c0a62291c070991d1b3e75a770de986a686.1391541706.git.jcody@redhat.com>
Le Tuesday 04 Feb 2014 à 14:26:58 (-0500), Jeff Cody a écrit :
> In preparation for supporting reopen on gluster, move flag
> parsing out to a function. Also, store open_flags and filename
> in the gluster state storage struct, and add a NULL check in the
> gconf cleanup.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> block/gluster.c | 48 ++++++++++++++++++++++++++++++++----------------
> 1 file changed, 32 insertions(+), 16 deletions(-)
>
> diff --git a/block/gluster.c b/block/gluster.c
> index a009b15..79af3fd 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -30,6 +30,8 @@ typedef struct GlusterAIOCB {
> typedef struct BDRVGlusterState {
> struct glfs *glfs;
> struct glfs_fd *fd;
> + int open_flags;
> + char *filename;
> } BDRVGlusterState;
>
> #define GLUSTER_FD_READ 0
> @@ -45,11 +47,13 @@ typedef struct GlusterConf {
>
> static void qemu_gluster_gconf_free(GlusterConf *gconf)
> {
> - g_free(gconf->server);
> - g_free(gconf->volname);
> - g_free(gconf->image);
> - g_free(gconf->transport);
> - g_free(gconf);
> + if (gconf) {
> + g_free(gconf->server);
> + g_free(gconf->volname);
> + g_free(gconf->image);
> + g_free(gconf->transport);
> + g_free(gconf);
> + }
> }
>
> static int parse_volume_options(GlusterConf *gconf, char *path)
> @@ -269,11 +273,27 @@ static QemuOptsList runtime_opts = {
> },
> };
>
> +static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
> +{
> + assert(open_flags != NULL);
> +
> + *open_flags |= O_BINARY;
> +
> + if (bdrv_flags & BDRV_O_RDWR) {
> + *open_flags |= O_RDWR;
> + } else {
> + *open_flags |= O_RDONLY;
> + }
> +
> + if ((bdrv_flags & BDRV_O_NOCACHE)) {
> + *open_flags |= O_DIRECT;
> + }
> +}
I saw the enable-O_SYNC option here.
http://www.gluster.org/community/documentation/index.php/Translators/performance
Why the gluster driver does not allow to enable O_SYNC ?
> +
> static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
> int bdrv_flags, Error **errp)
> {
> BDRVGlusterState *s = bs->opaque;
> - int open_flags = O_BINARY;
> int ret = 0;
> GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
> QemuOpts *opts;
> @@ -291,23 +311,17 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
>
> filename = qemu_opt_get(opts, "filename");
>
> + s->filename = g_strdup(filename);
> +
> s->glfs = qemu_gluster_init(gconf, filename);
> if (!s->glfs) {
> ret = -errno;
> goto out;
> }
>
> - if (bdrv_flags & BDRV_O_RDWR) {
> - open_flags |= O_RDWR;
> - } else {
> - open_flags |= O_RDONLY;
> - }
> -
> - if ((bdrv_flags & BDRV_O_NOCACHE)) {
> - open_flags |= O_DIRECT;
> - }
> + qemu_gluster_parse_flags(bdrv_flags, &s->open_flags);
>
> - s->fd = glfs_open(s->glfs, gconf->image, open_flags);
> + s->fd = glfs_open(s->glfs, gconf->image, s->open_flags);
> if (!s->fd) {
> ret = -errno;
> }
> @@ -324,6 +338,7 @@ out:
> if (s->glfs) {
> glfs_fini(s->glfs);
> }
> + g_free(s->filename);
> return ret;
> }
>
> @@ -589,6 +604,7 @@ static void qemu_gluster_close(BlockDriverState *bs)
> s->fd = NULL;
> }
> glfs_fini(s->glfs);
> + g_free(s->filename);
> }
>
> static int qemu_gluster_has_zero_init(BlockDriverState *bs)
> --
> 1.8.3.1
>
>
next prev parent reply other threads:[~2014-02-05 19:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-04 19:26 [Qemu-devel] [PATCH 0/2] block: add support for gluster reopen Jeff Cody
2014-02-04 19:26 ` [Qemu-devel] [PATCH 1/2] block: gluster - code movements, state storage changes Jeff Cody
2014-02-05 19:25 ` Benoît Canet [this message]
2014-02-07 3:44 ` Bharata B Rao
2014-02-07 14:22 ` Benoît Canet
2014-02-07 15:27 ` Bharata B Rao
2014-02-07 15:57 ` Jeff Cody
2014-02-10 17:49 ` Benoît Canet
2014-02-07 15:59 ` Benoît Canet
2014-02-14 14:12 ` Stefan Hajnoczi
2014-02-14 14:44 ` Jeff Cody
2014-02-14 14:21 ` Stefan Hajnoczi
2014-02-14 14:41 ` Jeff Cody
2014-02-14 15:38 ` Stefan Hajnoczi
2014-02-14 16:20 ` Jeff Cody
2014-02-14 16:28 ` Kevin Wolf
2014-02-04 19:26 ` [Qemu-devel] [PATCH 2/2] block: gluster - add reopen support Jeff Cody
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140205192535.GA3440@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=bharata@linux.vnet.ibm.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).