Patchwork [v3,03/19] cow: do not call bdrv_co_is_allocated

login
register
mail settings
Submitter Paolo Bonzini
Date July 25, 2013, 2:23 p.m.
Message ID <1374762197-7261-4-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/261726/
State New
Headers show

Comments

Paolo Bonzini - July 25, 2013, 2:23 p.m.
As we change bdrv_is_allocated to gather more information from bs and
bs->file, it will become a bit slower.  It is still appropriate for online
jobs, but not for reads/writes.  Call the internal function instead.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/cow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Kevin Wolf - July 29, 2013, 1:22 p.m.
Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben:
> As we change bdrv_is_allocated to gather more information from bs and
> bs->file, it will become a bit slower.  It is still appropriate for online
> jobs, but not for reads/writes.  Call the internal function instead.
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/cow.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/cow.c b/block/cow.c
> index 9ae2d6a..9797f71 100644
> --- a/block/cow.c
> +++ b/block/cow.c
> @@ -46,6 +46,9 @@ typedef struct BDRVCowState {
>      int64_t cow_sectors_offset;
>  } BDRVCowState;
>  
> +static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs,
> +        int64_t sector_num, int nb_sectors, int *num_same);

This forward declaration seems unnecessary.

Kevin

Patch

diff --git a/block/cow.c b/block/cow.c
index 9ae2d6a..9797f71 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -46,6 +46,9 @@  typedef struct BDRVCowState {
     int64_t cow_sectors_offset;
 } BDRVCowState;
 
+static int coroutine_fn cow_co_is_allocated(BlockDriverState *bs,
+        int64_t sector_num, int nb_sectors, int *num_same);
+
 static int cow_probe(const uint8_t *buf, int buf_size, const char *filename)
 {
     const struct cow_header_v2 *cow_header = (const void *)buf;
@@ -212,7 +215,7 @@  static int coroutine_fn cow_read(BlockDriverState *bs, int64_t sector_num,
     int ret, n;
 
     while (nb_sectors > 0) {
-        if (bdrv_co_is_allocated(bs, sector_num, nb_sectors, &n)) {
+        if (cow_co_is_allocated(bs, sector_num, nb_sectors, &n)) {
             ret = bdrv_pread(bs->file,
                         s->cow_sectors_offset + sector_num * 512,
                         buf, n * 512);