Received: from eggs.gnu.org ([2001:4830:134:3::10]:46001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDoc4-0007vx-Mz for qemu-devel@nongnu.org; Mon, 05 Dec 2016 03:27:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDoc3-0006iU-OA for qemu-devel@nongnu.org; Mon, 05 Dec 2016 03:27:04 -0500 Date: Mon, 5 Dec 2016 09:26:39 +0100 From: Wolfgang Bumiller Message-ID: <20161205082639.GA17546@olga.wb> References: <1480589964-29411-1-git-send-email-w.bumiller@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Subject: Re: [Qemu-devel] [RFC PATCH] glusterfs: allow partial reads List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Kevin Wolf , Jeff Cody , qemu-block@nongnu.org, Max Reitz On Fri, Dec 02, 2016 at 01:13:28PM -0600, Eric Blake wrote: > On 12/01/2016 04:59 AM, Wolfgang Bumiller wrote: > > Fixes #1644754. > >=20 > > Signed-off-by: Wolfgang Bumiller > > --- > > I'm not sure what the original rationale was to treat both partial > > reads as well as well as writes as I/O error. (Seems to have happened > > from original glusterfs v1 to v2 series with a note but no reasoning > > for the read side as far as I could see.) > > The general direction lately seems to be to move away from sector > > based block APIs. Also eg. the NFS code allows partial reads. (It > > does, however, have an old patch (c2eb918e3) dedicated to aligning > > sizes to 512 byte boundaries for file creation for compatibility to > > other parts of qemu like qcow2. This already happens in glusterfs, > > though, but if you move a file from a different storage over to > > glusterfs you may end up with a qcow2 file with eg. the L1 table in > > the last 80 bytes of the file aligned to _begin_ at a 512 boundary, > > but not _end_ at one.) > >=20 > > block/gluster.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > >=20 > > diff --git a/block/gluster.c b/block/gluster.c > > index 891c13b..3db0bf8 100644 > > --- a/block/gluster.c > > +++ b/block/gluster.c > > @@ -41,6 +41,7 @@ typedef struct GlusterAIOCB { > > int ret; > > Coroutine *coroutine; > > AioContext *aio_context; > > + bool is_write; > > } GlusterAIOCB; > > =20 > > typedef struct BDRVGlusterState { > > @@ -716,8 +717,10 @@ static void gluster_finish_aiocb(struct glfs_fd *f= d, ssize_t ret, void *arg) > > acb->ret =3D 0; /* Success */ > > } else if (ret < 0) { > > acb->ret =3D -errno; /* Read/Write failed */ > > + } else if (acb->is_write) { > > + acb->ret =3D -EIO; /* Partial write - fail it */ > > } else { > > - acb->ret =3D -EIO; /* Partial read/write - fail it */ > > + acb->ret =3D 0; /* Success */ >=20 > Does this properly guarantee that the portion beyond EOF reads as zero? I'd argue this wasn't necessarily the case before either, considering the first check starts with `!ret`: if (!ret || ret =3D=3D acb->size) { acb->ret =3D 0; /* Success */ A read right at EOF would return 0 and be treated as success there, no? Iow. it wouldn't zero out the destination buffer as far as I can see. Come to think of it, I'm not too fond of this part of the check for the write case either. > Would it be better to switch to byte-based interfaces rather than > continue to force gluster interaction in 512-byte sector chunks, since > gluster can obviously store files that are not 512-aligned?