From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W63l8-0003bv-5q for qemu-devel@nongnu.org; Wed, 22 Jan 2014 14:46:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W63l3-0005cv-3y for qemu-devel@nongnu.org; Wed, 22 Jan 2014 14:46:46 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:48064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W63l2-0005cV-Jh for qemu-devel@nongnu.org; Wed, 22 Jan 2014 14:46:41 -0500 Date: Wed, 22 Jan 2014 20:46:36 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140122194636.GA3053@irqsave.net> References: <1389968119-24771-1-git-send-email-kwolf@redhat.com> <1389968119-24771-16-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-16-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 15/29] block: Allow waiting for overlapping requests between begin/end 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:05 (+0100), Kevin Wolf a =E9crit : > Previously, it was not possible to use wait_for_overlapping_requests() > between tracked_request_begin()/end() because it would wait for itself. >=20 > Ignore the current request in the overlap check and run more of the > bdrv_co_do_preadv/pwritev code with a BdrvTrackedRequest present. >=20 > Signed-off-by: Kevin Wolf > Reviewed-by: Max Reitz > --- > block.c | 38 ++++++++++++++++++++------------------ > 1 file changed, 20 insertions(+), 18 deletions(-) >=20 > diff --git a/block.c b/block.c > index 85f28ab..18dcd43 100644 > --- a/block.c > +++ b/block.c > @@ -2106,7 +2106,7 @@ static bool tracked_request_overlaps(BdrvTrackedR= equest *req, > } > =20 > static void coroutine_fn wait_for_overlapping_requests(BlockDriverStat= e *bs, > - int64_t offset, unsigned int bytes) > + BdrvTrackedRequest *self, int64_t offset, unsigned int bytes) > { > BdrvTrackedRequest *req; > int64_t cluster_offset; > @@ -2124,6 +2124,9 @@ static void coroutine_fn wait_for_overlapping_req= uests(BlockDriverState *bs, > do { > retry =3D false; > QLIST_FOREACH(req, &bs->tracked_requests, list) { > + if (req =3D=3D self) { > + continue; > + } > if (tracked_request_overlaps(req, cluster_offset, cluster_= bytes)) { > /* Hitting this means there was a reentrant request, f= or > * example, a block driver issuing nested requests. T= his must > @@ -2726,10 +2729,10 @@ err: > * implemented by the caller. > */ > static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs, > - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags) > + BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, > + QEMUIOVector *qiov, int flags) > { > BlockDriver *drv =3D bs->drv; > - BdrvTrackedRequest req; > int ret; > =20 > int64_t sector_num =3D offset >> BDRV_SECTOR_BITS; > @@ -2744,11 +2747,9 @@ static int coroutine_fn bdrv_aligned_preadv(Bloc= kDriverState *bs, > } > =20 > if (bs->copy_on_read_in_flight) { > - wait_for_overlapping_requests(bs, offset, bytes); > + wait_for_overlapping_requests(bs, req, offset, bytes); > } > =20 > - tracked_request_begin(&req, bs, offset, bytes, false); > - > if (flags & BDRV_REQ_COPY_ON_READ) { > int pnum; > =20 > @@ -2795,8 +2796,6 @@ static int coroutine_fn bdrv_aligned_preadv(Block= DriverState *bs, > } > =20 > out: > - tracked_request_end(&req); > - > if (flags & BDRV_REQ_COPY_ON_READ) { > bs->copy_on_read_in_flight--; > } > @@ -2812,6 +2811,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDr= iverState *bs, > BdrvRequestFlags flags) > { > BlockDriver *drv =3D bs->drv; > + BdrvTrackedRequest req; > + > /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface= */ > uint64_t align =3D MAX(BDRV_SECTOR_SIZE, bs->request_alignment); > uint8_t *head_buf =3D NULL; > @@ -2862,9 +2863,11 @@ static int coroutine_fn bdrv_co_do_preadv(BlockD= riverState *bs, > bytes =3D ROUND_UP(bytes, align); > } > =20 > - ret =3D bdrv_aligned_preadv(bs, offset, bytes, > + tracked_request_begin(&req, bs, offset, bytes, false); > + ret =3D bdrv_aligned_preadv(bs, &req, offset, bytes, > use_local_qiov ? &local_qiov : qiov, > flags); > + tracked_request_end(&req); > =20 > if (use_local_qiov) { > qemu_iovec_destroy(&local_qiov); > @@ -2983,10 +2986,10 @@ static int coroutine_fn bdrv_co_do_write_zeroes= (BlockDriverState *bs, > * Forwards an already correctly aligned write request to the BlockDri= ver. > */ > static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, > - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags) > + BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, > + QEMUIOVector *qiov, int flags) > { > BlockDriver *drv =3D bs->drv; > - BdrvTrackedRequest req; > int ret; > =20 > int64_t sector_num =3D offset >> BDRV_SECTOR_BITS; > @@ -2996,12 +2999,10 @@ static int coroutine_fn bdrv_aligned_pwritev(Bl= ockDriverState *bs, > assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); > =20 > if (bs->copy_on_read_in_flight) { > - wait_for_overlapping_requests(bs, offset, bytes); > + wait_for_overlapping_requests(bs, req, offset, bytes); > } > =20 > - tracked_request_begin(&req, bs, offset, bytes, true); > - > - ret =3D notifier_with_return_list_notify(&bs->before_write_notifie= rs, &req); > + ret =3D notifier_with_return_list_notify(&bs->before_write_notifie= rs, req); > =20 > if (ret < 0) { > /* Do nothing, write notifier decided to fail this request */ > @@ -3024,8 +3025,6 @@ static int coroutine_fn bdrv_aligned_pwritev(Bloc= kDriverState *bs, > bs->total_sectors =3D MAX(bs->total_sectors, sector_num + nb_s= ectors); > } > =20 > - tracked_request_end(&req); > - > return ret; > } > =20 > @@ -3036,6 +3035,7 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockD= riverState *bs, > int64_t offset, unsigned int bytes, QEMUIOVector *qiov, > BdrvRequestFlags flags) > { > + BdrvTrackedRequest req; > int ret; > =20 > if (!bs->drv) { > @@ -3054,7 +3054,9 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockD= riverState *bs, > bdrv_io_limits_intercept(bs, bytes >> BDRV_SECTOR_BITS, true); > } > =20 > - ret =3D bdrv_aligned_pwritev(bs, offset, bytes, qiov, flags); > + tracked_request_begin(&req, bs, offset, bytes, true); > + ret =3D bdrv_aligned_pwritev(bs, &req, offset, bytes, qiov, flags)= ; > + tracked_request_end(&req); > =20 > return ret; > } > --=20 > 1.8.1.4 >=20 >=20 Reviewed-by: Benoit Canet