[Sheepdog] [PATCH] collie: fix offset in vdi_read/vdi_write

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sat Nov 5 17:26:39 CET 2011


At Thu,  3 Nov 2011 18:57:35 +0900,
MORITA Kazutaka wrote:
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
>  collie/vdi.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)

Applied.

Kazutaka

> 
> diff --git a/collie/vdi.c b/collie/vdi.c
> index c582654..c624131 100644
> --- a/collie/vdi.c
> +++ b/collie/vdi.c
> @@ -1017,8 +1017,9 @@ static int vdi_read(int argc, char **argv)
>  	total = min(total, inode->vdi_size - offset);
>  	total = roundup(total, 512);
>  	idx = offset / SD_DATA_OBJ_SIZE;
> +	offset %= SD_DATA_OBJ_SIZE;
>  	while (done < total) {
> -		len = min(total - done, SD_DATA_OBJ_SIZE - offset % SD_DATA_OBJ_SIZE);
> +		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
>  
>  		if (inode->data_vdi_id[idx]) {
>  			oid = vid_to_data_oid(inode->data_vdi_id[idx], idx);
> @@ -1115,11 +1116,12 @@ static int vdi_write(int argc, char **argv)
>  	total = min(total, inode->vdi_size - offset);
>  	total = roundup(total, 512);
>  	idx = offset / SD_DATA_OBJ_SIZE;
> +	offset %= SD_DATA_OBJ_SIZE;
>  	while (done < total) {
>  		create = 0;
>  		old_oid = 0;
>  		flags = 0;
> -		len = min(total - done, SD_DATA_OBJ_SIZE - offset % SD_DATA_OBJ_SIZE);
> +		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
>  
>  		if (!inode->data_vdi_id[idx])
>  			create = 1;
> -- 
> 1.7.2.5
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list