From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROuGS-0007hc-0w for qemu-devel@nongnu.org; Fri, 11 Nov 2011 11:47:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROuGQ-0000qO-RO for qemu-devel@nongnu.org; Fri, 11 Nov 2011 11:47:39 -0500 Received: from mtagate3.uk.ibm.com ([194.196.100.163]:33868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROuGQ-0000pm-Er for qemu-devel@nongnu.org; Fri, 11 Nov 2011 11:47:38 -0500 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id pABGlaFu029846 for ; Fri, 11 Nov 2011 16:47:36 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pABGla6q2277530 for ; Fri, 11 Nov 2011 16:47:36 GMT Received: from d06av07.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pABGlZBC030917 for ; Fri, 11 Nov 2011 09:47:36 -0700 From: Stefan Hajnoczi Date: Fri, 11 Nov 2011 16:47:20 +0000 Message-Id: <1321030042-20446-9-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1321030042-20446-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1321030042-20446-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 08/10] cow: convert to .bdrv_co_is_allocated() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Marcelo Tosatti , Stefan Hajnoczi The cow block driver does not keep internal state for cluster lookups. This means it is safe to perform cluster lookups in coroutine context without risk of race conditions that corrupt internal state. Signed-off-by: Stefan Hajnoczi --- block/cow.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/cow.c b/block/cow.c index 707c0aa..9ab21f6 100644 --- a/block/cow.c +++ b/block/cow.c @@ -132,8 +132,8 @@ static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum) /* Return true if first block has been changed (ie. current version is * in COW file). Set the number of continuous blocks for which that * is true. */ -static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num, - int nb_sectors, int *num_same) +static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, int *num_same) { int changed; @@ -178,7 +178,7 @@ static int cow_read(BlockDriverState *bs, int64_t sector_num, int ret, n; while (nb_sectors > 0) { - if (cow_is_allocated(bs, sector_num, nb_sectors, &n)) { + if (bdrv_is_allocated(bs, sector_num, nb_sectors, &n)) { ret = bdrv_pread(bs->file, s->cow_sectors_offset + sector_num * 512, buf, n * 512); @@ -335,7 +335,7 @@ static BlockDriver bdrv_cow = { .bdrv_close = cow_close, .bdrv_create = cow_create, .bdrv_co_flush = cow_co_flush, - .bdrv_is_allocated = cow_is_allocated, + .bdrv_co_is_allocated = cow_co_is_allocated, .create_options = cow_create_options, }; -- 1.7.7.1