[Sheepdog] fix calculation of free disk spaces

Piavlo piavka at cs.bgu.ac.il
Mon Feb 15 08:40:14 CET 2010


MORITA Kazutaka wrote:
> On Sat, Feb 13, 2010 at 5:02 AM, Piavlo <piavka at cs.bgu.ac.il> wrote:
>   
>> I've just build against the current next branch. The fd leak seems to be
>> solved,
>>     
>
> Thanks!
> I've applied the fixes to the master branch.
>   
Looks ok now, thanks
>   
>> but  disk spaces are still not reported correctly
>>
>> fire-srv3 ~ # shepherd info -t sheep
>> Id      Size    Used    Use%
>>  0      12G     0G        0%
>>  1      11G     0G        0%
>>  2      13G     0G        0%
>>
>> Total   36G     0G        0%, total virtual VDI Size    5G
>>     
>
> Thanks for your reporting.
> Can you apply the following patch or pull the current next branch?
>
> Regards,
>
> Kazutaka Morita
>
> ==
> >From ff5a9ac9761350f7a118dd49e6aa8e9ecc679437 Mon Sep 17 00:00:00 2001
> From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> Date: Mon, 15 Feb 2010 11:18:38 +0900
> Subject: [PATCH] collie: fix a calculation of disk usage
>
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
>  collie/store.c |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/collie/store.c b/collie/store.c
> index 4761ce5..131b9e8 100644
> --- a/collie/store.c
> +++ b/collie/store.c
> @@ -37,7 +37,7 @@ static mode_t def_fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
>  int nr_sobjs;
>  struct work_queue *dobj_queue;
>  
> -static int stat_sheep(uint64_t *store_size, uint64_t *store_free)
> +static int stat_sheep(uint64_t *store_size, uint64_t *store_free, uint32_t epoch)
>  {
>  	struct statvfs vs;
>  	int ret;
> @@ -45,13 +45,14 @@ static int stat_sheep(uint64_t *store_size, uint64_t *store_free)
>  	struct dirent *d;
>  	uint64_t used = 0;
>  	struct stat s;
> -	char path[1024];
> +	char path[1024], store_dir[1024];
>  
>  	ret = statvfs(mnt_path, &vs);
>  	if (ret)
>  		return SD_RES_EIO;
>  
> -	dir = opendir(obj_path);
> +	snprintf(store_dir, sizeof(store_dir), "%s%08u", obj_path, epoch);
> +	dir = opendir(store_dir);
>  	if (!dir)
>  		return SD_RES_EIO;
>  
> @@ -59,7 +60,7 @@ static int stat_sheep(uint64_t *store_size, uint64_t *store_free)
>  		if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
>  			continue;
>  
> -		snprintf(path, sizeof(path), "%s%s", obj_path, d->d_name);
> +		snprintf(path, sizeof(path), "%s/%s", store_dir, d->d_name);
>  
>  		ret = stat(path, &s);
>  		if (ret)
> @@ -560,7 +561,7 @@ void store_queue_request(struct work *work, int idx)
>  	}
>  
>  	if (opcode == SD_OP_STAT_SHEEP) {
> -		ret = stat_sheep(&nrsp->store_size, &nrsp->store_free);
> +		ret = stat_sheep(&nrsp->store_size, &nrsp->store_free, epoch);
>  		goto out;
>  	}
>  
>   




More information about the sheepdog mailing list