From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1F9I-0002oR-TN for qemu-devel@nongnu.org; Fri, 13 May 2016 11:37:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1F9H-0001Lu-DD for qemu-devel@nongnu.org; Fri, 13 May 2016 11:37:08 -0400 References: <1462354765-14037-1-git-send-email-kwolf@redhat.com> <1462354765-14037-14-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: Date: Fri, 13 May 2016 17:36:57 +0200 MIME-Version: 1.0 In-Reply-To: <1462354765-14037-14-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TPwcMXxf9TxQMcKVgO253DsQH3rTaML3R" Subject: Re: [Qemu-devel] [PATCH 13/14] commit: Use BlockBackend for I/O List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: jcody@redhat.com, jsnow@redhat.com, berto@igalia.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TPwcMXxf9TxQMcKVgO253DsQH3rTaML3R From: Max Reitz To: Kevin Wolf , qemu-block@nongnu.org Cc: jcody@redhat.com, jsnow@redhat.com, berto@igalia.com, qemu-devel@nongnu.org Message-ID: Subject: Re: [PATCH 13/14] commit: Use BlockBackend for I/O References: <1462354765-14037-1-git-send-email-kwolf@redhat.com> <1462354765-14037-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1462354765-14037-14-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.05.2016 11:39, Kevin Wolf wrote: > This changes the commit block job to use the job's BlockBackend for > performing its I/O. job->bs isn't used by the commit code any more > afterwards. >=20 > Signed-off-by: Kevin Wolf > --- > block/commit.c | 42 +++++++++++++++++++++++++++--------------- > 1 file changed, 27 insertions(+), 15 deletions(-) >=20 > diff --git a/block/commit.c b/block/commit.c > index f308c8c..863e059 100644 > --- a/block/commit.c > +++ b/block/commit.c > @@ -36,28 +36,34 @@ typedef struct CommitBlockJob { > BlockJob common; > RateLimit limit; > BlockDriverState *active; > - BlockDriverState *top; > - BlockDriverState *base; > + BlockBackend *top; > + BlockBackend *base; > BlockdevOnError on_error; > int base_flags; > int orig_overlay_flags; > char *backing_file_str; > } CommitBlockJob; > =20 > -static int coroutine_fn commit_populate(BlockDriverState *bs, > - BlockDriverState *base, > +static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend= *base, > int64_t sector_num, int nb_sec= tors, > void *buf) > { > int ret =3D 0; > + QEMUIOVector qiov; > + struct iovec iov =3D { > + .iov_base =3D (void *)buf, Why the cast? > + .iov_len =3D nb_sectors * BDRV_SECTOR_SIZE, > + }; > =20 > - ret =3D bdrv_read(bs, sector_num, buf, nb_sectors); > - if (ret) { > + qemu_iovec_init_external(&qiov, &iov, 1); > + > + ret =3D blk_co_readv(bs, sector_num, nb_sectors, &qiov); > + if (ret < 0) { > return ret; > } > =20 > - ret =3D bdrv_write(base, sector_num, buf, nb_sectors); > - if (ret) { > + ret =3D blk_co_writev(base, sector_num, nb_sectors, &qiov); > + if (ret < 0) { > return ret; > } > =20 > @@ -73,8 +79,8 @@ static void commit_complete(BlockJob *job, void *opaq= ue) > CommitBlockJob *s =3D container_of(job, CommitBlockJob, common); > CommitCompleteData *data =3D opaque; > BlockDriverState *active =3D s->active; > - BlockDriverState *top =3D s->top; > - BlockDriverState *base =3D s->base; > + BlockDriverState *top =3D blk_bs(s->top); > + BlockDriverState *base =3D blk_bs(s->base); > BlockDriverState *overlay_bs; > int ret =3D data->ret; > =20 > @@ -94,6 +100,8 @@ static void commit_complete(BlockJob *job, void *opa= que) > bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL); > } > g_free(s->backing_file_str); > + blk_unref(s->top); > + blk_unref(s->base); > block_job_completed(&s->common, ret); > g_free(data); > } > @@ -102,8 +110,8 @@ static void coroutine_fn commit_run(void *opaque) > { > CommitBlockJob *s =3D opaque; > CommitCompleteData *data; > - BlockDriverState *top =3D s->top; > - BlockDriverState *base =3D s->base; > + BlockDriverState *top =3D blk_bs(s->top); > + BlockDriverState *base =3D blk_bs(s->base); I think for this function it would definitely be nicer to drop these variables (or make them BlockBackend pointers) and use them with the blk_* functions. The only function where this is not possible is bdrv_is_allocated_above(), and I think it won't be too ugly to use blk_bs() in its parameter list there. > int64_t sector_num, end; > int ret =3D 0; > int n =3D 0; > @@ -158,7 +166,7 @@ wait: > goto wait; > } > } > - ret =3D commit_populate(top, base, sector_num, n, buf); > + ret =3D commit_populate(s->top, s->base, sector_num, n, bu= f); > bytes_written +=3D n * BDRV_SECTOR_SIZE; > } > if (ret < 0) { > @@ -253,8 +261,12 @@ void commit_start(BlockDriverState *bs, BlockDrive= rState *base, > return; > } > =20 > - s->base =3D base; > - s->top =3D top; > + s->base =3D blk_new(&error_abort); > + blk_insert_bs(s->base, base); > + > + s->top =3D blk_new(&error_abort); > + blk_insert_bs(s->top, top); > + But again, this is why I'm hesitant to give an R-b for this patch. Max > s->active =3D bs; > =20 > s->base_flags =3D orig_base_flags; >=20 --TPwcMXxf9TxQMcKVgO253DsQH3rTaML3R 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 iQEcBAEBCAAGBQJXNfSZAAoJEDuxQgLoOKytEZsIAJEo1Ufw1ZSfVMpA4L8UbA1t CKTFbZNp6hpfr1J20RWoAoV4Emljo2sNGupb+WfG02bQmabEW/nYq6ENUbZv7T6H JQWlbpPF2xnjHWYeXgxBJj6Wx80apuXCq74Jzfj9EMBpsHwJAA3iqgHZ8CjoatLf ceIanU8GBruqKAKWZsFjoycfsT+BYyF2yHCbhGveiRA5eqt4D5jLRIFQB/SkTgMV XqOfGAMxvTmEc5WBcF/TvnotgZecjDpe3R5XYK1FiWj4meUptBM8CNPuICfYUG1k 92ppte7WBFRs1w2Z1CtS3pWThYWWFkxeDuooP0eeaAbYkFVrrTnmM+ipTAYeDxM= =KHR0 -----END PGP SIGNATURE----- --TPwcMXxf9TxQMcKVgO253DsQH3rTaML3R--