From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQed8-000311-LL for qemu-devel@nongnu.org; Tue, 02 Feb 2016 12:20:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQed3-0004Ii-Qt for qemu-devel@nongnu.org; Tue, 02 Feb 2016 12:20:42 -0500 References: <1452653434-14879-1-git-send-email-famz@redhat.com> <1452653434-14879-2-git-send-email-famz@redhat.com> From: Max Reitz Message-ID: <56B0E55D.1000808@redhat.com> Date: Tue, 2 Feb 2016 18:20:29 +0100 MIME-Version: 1.0 In-Reply-To: <1452653434-14879-2-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qINIcDVOGkd8ARq0dthrADL7lrAnd5Is2" Subject: Re: [Qemu-devel] [PATCH v10 1/2] mirror: Rewrite mirror_iteration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , pbonzini@redhat.com, Jeff Cody , qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qINIcDVOGkd8ARq0dthrADL7lrAnd5Is2 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 13.01.2016 03:50, Fam Zheng wrote: > The "pnum < nb_sectors" condition in deciding whether to actually copy > data is unnecessarily strict, and the qiov initialization is > unnecessarily for bdrv_aio_write_zeroes and bdrv_aio_discard. >=20 > Rewrite mirror_iteration to fix both flaws. >=20 > The output of iotests 109 is updated because we now report the offset > and len slightly differently in mirroring progress. >=20 > Signed-off-by: Fam Zheng > --- > block/mirror.c | 333 +++++++++++++++++++++++++++----------= -------- > tests/qemu-iotests/109.out | 80 +++++------ > trace-events | 1 - > 3 files changed, 242 insertions(+), 172 deletions(-) Unfortunately, this patch now conflicts with your series that added the @file parameter to bdrv_get_block_status(): >=20 > diff --git a/block/mirror.c b/block/mirror.c > index f201f2b..7606aea 100644 > --- a/block/mirror.c > +++ b/block/mirror.c [...] > @@ -158,115 +159,79 @@ static void mirror_read_complete(void *opaque, i= nt ret) > mirror_write_complete, op); [...] > +static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num, > + int nb_sectors) > { > BlockDriverState *source =3D s->common.bs; > - int nb_sectors, sectors_per_chunk, nb_chunks, max_iov; > - int64_t end, sector_num, next_chunk, next_sector, hbitmap_next_sec= tor; > - uint64_t delay_ns =3D 0; > + int sectors_per_chunk, nb_chunks; > + int ret =3D nb_sectors; > MirrorOp *op; > - int pnum; > - int64_t ret; I guess a - BlockDriverState *file; is needed here. > =20 > - max_iov =3D MIN(source->bl.max_iov, s->target->bl.max_iov); [...] > /* Copy the dirty cluster. */ > s->in_flight++; > s->sectors_in_flight +=3D nb_sectors; > trace_mirror_one_iteration(s, sector_num, nb_sectors); > =20 > - ret =3D bdrv_get_block_status_above(source, NULL, sector_num, > - nb_sectors, &pnum); This should now be: - nb_sectors, &pnum, &file); > - if (ret < 0 || pnum < nb_sectors || > - (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { > - bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > - mirror_read_complete, op); > - } else if (ret & BDRV_BLOCK_ZERO) { > + bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > + mirror_read_complete, op); > + return ret; > +} [...] > + /* Clear dirty bits before querying the block status, because > + * calling bdrv_get_block_status_above could yield - if some block= s are > + * marked dirty in this window, we need to know. > + */ > + bdrv_reset_dirty_bitmap(s->dirty_bitmap, sector_num, > + nb_chunks * sectors_per_chunk); > + bitmap_set(s->in_flight_bitmap, sector_num / sectors_per_chunk, nb= _chunks); > + while (nb_chunks > 0 && sector_num < end) { > + int ret; > + int io_sectors; + BlockDriverState *file; > + enum MirrorMethod { > + MIRROR_METHOD_COPY, > + MIRROR_METHOD_ZERO, > + MIRROR_METHOD_DISCARD > + } mirror_method =3D MIRROR_METHOD_COPY; > + > + assert(!(sector_num % sectors_per_chunk)); > + ret =3D bdrv_get_block_status_above(source, NULL, sector_num, > + nb_chunks * sectors_per_chun= k, > + &io_sectors); + &io_sectors, &file); So it's not too difficult but it's not trivial either, so I was afraid to do these changes myself while applying. Max > + if (ret < 0) { > + io_sectors =3D nb_chunks * sectors_per_chunk; > + } [...] --qINIcDVOGkd8ARq0dthrADL7lrAnd5Is2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWsOVdAAoJEDuxQgLoOKyt09IIAJD49q5XKV02HixlvhjQxzMG Of4J4lgI+0L/As2R3XFrZydZb98WIkmGj690kri3d4bTqI6B6AnBrBsDJ2d7ZwNi 3LdNW/+MYNr9sG89pJKK/pG2Vw4mcnImdchptqCQqoh4ilXDP6EvfrlRx+TV7p5F 3nL3vCbncL/ZHTdv6whW14CVzg34YuFjfV6yKJzG6VTlRpFHC8S6C05atCtca7h5 ILv8NsaTdo3SiUgt3R9bWpI23NDPGmPL8QJSGnnUPkg7jgWaBDSTFrYsl/4YgN/S p/ZIIsVjX1otQAOxhU3dz2igPuCXthw4XOnmDGCz086bvHvFmCSbbUu5EsjCopM= =1t6/ -----END PGP SIGNATURE----- --qINIcDVOGkd8ARq0dthrADL7lrAnd5Is2--