From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W63oh-0005Lc-PQ for qemu-devel@nongnu.org; Wed, 22 Jan 2014 14:50:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W63oc-0006dl-OQ for qemu-devel@nongnu.org; Wed, 22 Jan 2014 14:50:27 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:48070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W63oc-0006de-E2 for qemu-devel@nongnu.org; Wed, 22 Jan 2014 14:50:22 -0500 Date: Wed, 22 Jan 2014 20:50:21 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140122195021.GB3053@irqsave.net> References: <1389968119-24771-1-git-send-email-kwolf@redhat.com> <1389968119-24771-17-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1389968119-24771-17-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 16/29] block: Make zero-after-EOF work with larger alignment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: pl@kamp.de, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, xiawenc@linux.vnet.ibm.com Le Friday 17 Jan 2014 =E0 15:15:06 (+0100), Kevin Wolf a =E9crit : > Odd file sizes could make bdrv_aligned_preadv() shorten the request in > non-aligned ways. Fix it by rounding to the required alignment instead > of 512 bytes. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) >=20 > diff --git a/block.c b/block.c > index 18dcd43..d7156ce 100644 > --- a/block.c > +++ b/block.c > @@ -2730,7 +2730,7 @@ err: > */ > static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs, > BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, > - QEMUIOVector *qiov, int flags) > + int64_t align, QEMUIOVector *qiov, int flags) > { > BlockDriver *drv =3D bs->drv; > int ret; > @@ -2778,7 +2778,8 @@ static int coroutine_fn bdrv_aligned_preadv(Block= DriverState *bs, > } > =20 > total_sectors =3D DIV_ROUND_UP(len, BDRV_SECTOR_SIZE); > - max_nb_sectors =3D MAX(0, total_sectors - sector_num); > + max_nb_sectors =3D MAX(0, ROUND_UP(total_sectors - sector_num, > + align >> BDRV_SECTOR_BITS)); > if (max_nb_sectors > 0) { > ret =3D drv->bdrv_co_readv(bs, sector_num, > MIN(nb_sectors, max_nb_sectors), = qiov); > @@ -2864,7 +2865,7 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDr= iverState *bs, > } > =20 > tracked_request_begin(&req, bs, offset, bytes, false); > - ret =3D bdrv_aligned_preadv(bs, &req, offset, bytes, > + ret =3D bdrv_aligned_preadv(bs, &req, offset, bytes, align, > use_local_qiov ? &local_qiov : qiov, > flags); > tracked_request_end(&req); > --=20 > 1.8.1.4 >=20 >=20 Reviewed-by: Benoit Canet