From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1hP1-0004Qf-DH for qemu-devel@nongnu.org; Fri, 10 Jan 2014 14:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1hOv-0007YJ-9F for qemu-devel@nongnu.org; Fri, 10 Jan 2014 14:05:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1hOu-0007Y9-JE for qemu-devel@nongnu.org; Fri, 10 Jan 2014 14:05:49 -0500 Message-ID: <52D044E7.1020702@redhat.com> Date: Fri, 10 Jan 2014 20:07:19 +0100 From: Max Reitz MIME-Version: 1.0 References: <1386940979-3824-1-git-send-email-kwolf@redhat.com> <1386940979-3824-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1386940979-3824-17-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 16/24] block: Make zero-after-EOF work with larger alignment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, pl@kamp.de, stefanha@redhat.com On 13.12.2013 14:22, Kevin Wolf wrote: > 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. > > Signed-off-by: Kevin Wolf > --- > block.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/block.c b/block.c > index b4f6ead..6dddb7c 100644 > --- a/block.c > +++ b/block.c > @@ -2725,7 +2725,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; > @@ -2773,7 +2773,7 @@ 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)); It appears this should be an alignment given in sectors=85 > if (max_nb_sectors > 0) { > ret =3D drv->bdrv_co_readv(bs, sector_num, > MIN(nb_sectors, max_nb_sectors),= qiov); > @@ -2858,7 +2858,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, Whereas this one is an alignment given in bytes. Max > use_local_qiov ? &local_qiov : qiov, > flags); > tracked_request_end(&req);