From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bD2Aq-00015L-Eo for qemu-devel@nongnu.org; Wed, 15 Jun 2016 00:11:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bD2Ap-0001ig-74 for qemu-devel@nongnu.org; Wed, 15 Jun 2016 00:11:28 -0400 References: <1465917916-22348-1-git-send-email-den@openvz.org> <1465917916-22348-8-git-send-email-den@openvz.org> From: Eric Blake Message-ID: <5760D565.9070204@redhat.com> Date: Tue, 14 Jun 2016 22:11:17 -0600 MIME-Version: 1.0 In-Reply-To: <1465917916-22348-8-git-send-email-den@openvz.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bODUTOUcA9cH7lwB8sTjrbBFVu97OBqCJ" Subject: Re: [Qemu-devel] [PATCH 7/9] mirror: allow to save buffer for QEMUIOVector in MirrorOp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, Stefan Hajnoczi , Fam Zheng , Kevin Wolf , Max Reitz , Jeff Cody This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --bODUTOUcA9cH7lwB8sTjrbBFVu97OBqCJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/14/2016 09:25 AM, Denis V. Lunev wrote: In the subject: 'allow to save buffer' is not idiomatic English; better would be 'allow saving the buffer' or simply 'save the buffer' > Properly cook MirrorOp initialization/deinitialization. The field is no= t > yet used actually. Another "what" but not "why" - expanding the commit message to mention "why" makes it easier to review. >=20 > Signed-off-by: Denis V. Lunev > Reviewed-by: Vladimir Sementsov-Ogievskiy > CC: Stefan Hajnoczi > CC: Fam Zheng > CC: Kevin Wolf > CC: Max Reitz > CC: Jeff Cody > CC: Eric Blake > --- > block/mirror.c | 32 +++++++++++++++++++------------- > 1 file changed, 19 insertions(+), 13 deletions(-) >=20 > diff --git a/block/mirror.c b/block/mirror.c > index d8be80a..7471211 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -73,6 +73,7 @@ typedef struct MirrorOp { > QEMUIOVector qiov; > int64_t sector_num; > int nb_sectors; > + void *buf; > } MirrorOp; > =20 > static BlockErrorAction mirror_error_action(MirrorBlockJob *s, bool re= ad, > @@ -100,24 +101,28 @@ static void mirror_iteration_done(MirrorOp *op, i= nt ret) > s->in_flight--; > s->sectors_in_flight -=3D op->nb_sectors; > iov =3D op->qiov.iov; > - for (i =3D 0; i < op->qiov.niov; i++) { > - MirrorBuffer *buf =3D (MirrorBuffer *) iov[i].iov_base; > - QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); > - s->buf_free_count++; > - } > =20 > - sectors_per_chunk =3D s->granularity >> BDRV_SECTOR_BITS; > - chunk_num =3D op->sector_num / sectors_per_chunk; > - nb_chunks =3D DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk); > - bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks); > - if (ret >=3D 0) { > - if (s->cow_bitmap) { > - bitmap_set(s->cow_bitmap, chunk_num, nb_chunks); > + if (op->buf =3D=3D NULL) { > + for (i =3D 0; i < op->qiov.niov; i++) { > + MirrorBuffer *buf =3D (MirrorBuffer *) iov[i].iov_base; > + QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); > + s->buf_free_count++; > + } > + > + sectors_per_chunk =3D s->granularity >> BDRV_SECTOR_BITS; > + chunk_num =3D op->sector_num / sectors_per_chunk; > + nb_chunks =3D DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk);= > + bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks); I still think it might be smarter to fix bitmap operations to work on byte inputs (still sectors, or rather granularity chunks, under the hood, but no need to make users scale things just to have it scaled again= ). > + if (ret >=3D 0) { > + if (s->cow_bitmap) { > + bitmap_set(s->cow_bitmap, chunk_num, nb_chunks); > + } > + s->common.offset +=3D (uint64_t)op->nb_sectors * BDRV_SECT= OR_SIZE; > } > - s->common.offset +=3D (uint64_t)op->nb_sectors * BDRV_SECTOR_S= IZE; > } > =20 > qemu_iovec_destroy(&op->qiov); > + g_free(op->buf); > g_free(op); > =20 > if (s->waiting_for_io) { > @@ -255,6 +260,7 @@ static int mirror_do_read(MirrorBlockJob *s, int64_= t sector_num, > op->s =3D s; > op->sector_num =3D sector_num; > op->nb_sectors =3D nb_sectors; > + op->buf =3D NULL; > =20 > /* Now make a QEMUIOVector taking enough granularity-sized chunks > * from s->buf_free. >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --bODUTOUcA9cH7lwB8sTjrbBFVu97OBqCJ 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXYNVlAAoJEKeha0olJ0Nqpf8H/AtVHQEfPlvMs0y7sSa+rl8o T02YGY0vTn0sfIkxiPLeRWGwFnx7VLQXVJKKJplQDehw3guCnyN7NjVXrNWGILkD jKCpB1kAg9Dsbq23axA6n5YZvfhEXRmEPv2QToQ9ta1mrL+Ho6a7RQbgP7SgsKbx IeOLp9AxOswMcW6h/6pOYGGlgw9EQlYqDKP442yjIhcgMSL4nALG+xOOi0Won2VS /2t2Hp/BivHuqq91W0yoUMzUK7QdNolK1+c1LvAczpTS0MAgn9XuToKW9PLCNqGR EjkrLhgVUliD5QDt8/sADICM4XeDEcHDMiz/ngYcXQPDENtkrqWz2rTH8ZuTQxI= =r2YM -----END PGP SIGNATURE----- --bODUTOUcA9cH7lwB8sTjrbBFVu97OBqCJ--