[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 7/9] cow: convert to .bdrv_co_is_allocated()
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v2 7/9] cow: convert to .bdrv_co_is_allocated() |
Date: |
Mon, 14 Nov 2011 12:44:24 +0000 |
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 <address@hidden>
---
block/cow.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/cow.c b/block/cow.c
index 9858d71..7ae887b 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_read = cow_co_read,
.bdrv_write = cow_co_write,
.bdrv_co_flush_to_disk = 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
- [Qemu-devel] [PATCH v2 0/9] block: replace .bdrv_is_allocated() with .bdrv_co_is_allocated(), Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 3/9] qed: convert to .bdrv_co_is_allocated(), Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 2/9] block: add .bdrv_co_is_allocated(), Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 9/9] block: add bdrv_co_is_allocated() interface, Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 5/9] vvfat: convert to .bdrv_co_is_allocated(), Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 6/9] vdi: convert to .bdrv_co_is_allocated(), Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 4/9] block: convert qcow2, qcow2, and vmdk to .bdrv_co_is_allocated(), Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 1/9] block: use public bdrv_is_allocated() interface, Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 8/9] block: drop .bdrv_is_allocated() interface, Stefan Hajnoczi, 2011/11/14
- [Qemu-devel] [PATCH v2 7/9] cow: convert to .bdrv_co_is_allocated(),
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PATCH v2 0/9] block: replace .bdrv_is_allocated() with .bdrv_co_is_allocated(), Kevin Wolf, 2011/11/23