qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 08/12] VMDK: change get_cluster_offset return


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH v6 08/12] VMDK: change get_cluster_offset return type
Date: Fri, 01 Jul 2011 18:40:43 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Thunderbird/3.1.10

Am 01.07.2011 06:55, schrieb Fam Zheng:
> The return type of get_cluster_offset was an offset that use 0 to denote
> 'not allocated', this will be no longer true for flat extents, as we see
> flat extent file as a single huge cluster whose offset is 0 and length
> is the whole file length.
> So now we use int return value, 0 means success and otherwise offset
> invalid.
> 
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  block/vmdk.c |   73 
> +++++++++++++++++++++++++++++++---------------------------
>  1 files changed, 39 insertions(+), 34 deletions(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 8783629..40e4464 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -685,18 +685,23 @@ static int vmdk_L2update(VmdkExtent *extent, 
> VmdkMetaData *m_data)
>      return 0;
>  }
>  
> -static uint64_t get_cluster_offset(BlockDriverState *bs,
> +static int get_cluster_offset(BlockDriverState *bs,
>                                      VmdkExtent *extent,
>                                      VmdkMetaData *m_data,
> -                                    uint64_t offset, int allocate)
> +                                    uint64_t offset,
> +                                    int allocate,
> +                                    uint64_t *cluster_offset)
>  {
>      unsigned int l1_index, l2_offset, l2_index;
>      int min_index, i, j;
>      uint32_t min_count, *l2_table, tmp = 0;
> -    uint64_t cluster_offset;
>  
>      if (m_data)
>          m_data->valid = 0;
> +    if (extent->flat) {
> +        *cluster_offset = 0;
> +        return 0;
> +    }
>  
>      l1_index = (offset >> 9) / extent->l1_entry_sectors;
>      if (l1_index >= extent->l1_size) {

Let me complete what comes next:

    l1_index = (offset >> 9) / extent->l1_entry_sectors;
    if (l1_index >= extent->l1_size) {
        return 0;
    }
    l2_offset = extent->l1_table[l1_index];
    if (!l2_offset) {
        return 0;
    }

Shouldn't these returns be changed to -1? Also there is a return 0;
after a failed read, which doesn't seem to be changed.

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]