From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB86S-0004EM-1D for qemu-devel@nongnu.org; Wed, 05 Feb 2014 14:25:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB86M-0004p2-Km for qemu-devel@nongnu.org; Wed, 05 Feb 2014 14:25:43 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB86L-0004oW-Uf for qemu-devel@nongnu.org; Wed, 05 Feb 2014 14:25:38 -0500 Date: Wed, 5 Feb 2014 20:25:36 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140205192535.GA3440@irqsave.net> References: <925f4c0a62291c070991d1b3e75a770de986a686.1391541706.git.jcody@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <925f4c0a62291c070991d1b3e75a770de986a686.1391541706.git.jcody@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] block: gluster - code movements, state storage changes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, bharata@linux.vnet.ibm.com Le Tuesday 04 Feb 2014 =E0 14:26:58 (-0500), Jeff Cody a =E9crit : > 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. >=20 > Signed-off-by: Jeff Cody > --- > block/gluster.c | 48 ++++++++++++++++++++++++++++++++---------------- > 1 file changed, 32 insertions(+), 16 deletions(-) >=20 > 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; > =20 > #define GLUSTER_FD_READ 0 > @@ -45,11 +47,13 @@ typedef struct GlusterConf { > =20 > 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); > + } > } > =20 > static int parse_volume_options(GlusterConf *gconf, char *path) > @@ -269,11 +273,27 @@ static QemuOptsList runtime_opts =3D { > }, > }; > =20 > +static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags) > +{ > + assert(open_flags !=3D NULL); > + > + *open_flags |=3D O_BINARY; > + > + if (bdrv_flags & BDRV_O_RDWR) { > + *open_flags |=3D O_RDWR; > + } else { > + *open_flags |=3D O_RDONLY; > + } > + > + if ((bdrv_flags & BDRV_O_NOCACHE)) { > + *open_flags |=3D O_DIRECT; > + } > +} I saw the enable-O_SYNC option here. http://www.gluster.org/community/documentation/index.php/Translators/perf= ormance 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 =3D bs->opaque; > - int open_flags =3D O_BINARY; > int ret =3D 0; > GlusterConf *gconf =3D g_malloc0(sizeof(GlusterConf)); > QemuOpts *opts; > @@ -291,23 +311,17 @@ static int qemu_gluster_open(BlockDriverState *bs= , QDict *options, > =20 > filename =3D qemu_opt_get(opts, "filename"); > =20 > + s->filename =3D g_strdup(filename); > + > s->glfs =3D qemu_gluster_init(gconf, filename); > if (!s->glfs) { > ret =3D -errno; > goto out; > } > =20 > - if (bdrv_flags & BDRV_O_RDWR) { > - open_flags |=3D O_RDWR; > - } else { > - open_flags |=3D O_RDONLY; > - } > - > - if ((bdrv_flags & BDRV_O_NOCACHE)) { > - open_flags |=3D O_DIRECT; > - } > + qemu_gluster_parse_flags(bdrv_flags, &s->open_flags); > =20 > - s->fd =3D glfs_open(s->glfs, gconf->image, open_flags); > + s->fd =3D glfs_open(s->glfs, gconf->image, s->open_flags); > if (!s->fd) { > ret =3D -errno; > } > @@ -324,6 +338,7 @@ out: > if (s->glfs) { > glfs_fini(s->glfs); > } > + g_free(s->filename); > return ret; > } > =20 > @@ -589,6 +604,7 @@ static void qemu_gluster_close(BlockDriverState *bs= ) > s->fd =3D NULL; > } > glfs_fini(s->glfs); > + g_free(s->filename); > } > =20 > static int qemu_gluster_has_zero_init(BlockDriverState *bs) > --=20 > 1.8.3.1 >=20 >=20