[Sheepdog] [PATCH] collie: fix vdi_object() read size

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Nov 24 06:09:30 CET 2011


At Thu, 24 Nov 2011 11:48:40 +0800,
Liu Yuan wrote:
> 
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> This fixes the bug for command 'collie vdi object image -i x'
> 
> Since now we don't support short read, for data object, we have
> to pass the exact size, or we'll sheep daemon will error out.
> 
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  collie/vdi.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/collie/vdi.c b/collie/vdi.c
> index d9f8bdb..444e8a4 100644
> --- a/collie/vdi.c
> +++ b/collie/vdi.c
> @@ -246,7 +246,7 @@ static void get_data_oid(char *sheep, uint64_t oid, struct sd_obj_rsp *rsp,
>  	}
>  }
>  
> -static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data)
> +static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data, unsigned size)
>  {
>  	char name[128];
>  	int i, fd, ret;
> @@ -259,7 +259,7 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data)
>  	}
>  
>  	for (i = 0; i < nr_nodes; i++) {
> -		unsigned wlen = 0, rlen = sizeof(struct sheepdog_inode);
> +		unsigned wlen = 0, rlen = size;
>  		struct sd_obj_req hdr;
>  		struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&hdr;

Good catch, but we also need to allocate the proper size to 'buf'.

Thanks,

Kazutaka



More information about the sheepdog mailing list