[sheepdog] [PATCH] sheep/recovery: fix floating point error

Liu Yuan namei.unix at gmail.com
Tue Jun 10 06:23:59 CEST 2014


On Tue, Jun 10, 2014 at 12:18:24PM +0800, Ruoyu wrote:
> Once the recovery count is less than 100, sheep process will crash
> because of devided by zero.
> 
> The solution is do not print log message if recover object count
> is less than 100.
> 
> Cc: Saeki Masaki <saeki.masaki at po.ntts.co.jp>
> Signed-off-by: Ruoyu <liangry at ucweb.com>
> ---
>  sheep/recovery.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sheep/recovery.c b/sheep/recovery.c
> index 8d87f4c..8524c86 100644
> --- a/sheep/recovery.c
> +++ b/sheep/recovery.c
> @@ -901,7 +901,7 @@ static void recover_object_main(struct work *work)
>  
>  	wakeup_requests_on_oid(row->oid);
>  
> -	if (!(rinfo->done % (rinfo->count/100)))
> +	if (rinfo->count >= 100 && !(rinfo->done % (rinfo->count/100)))

Use DIV_ROUND_UP(rinfo->count, 100) to make sure it is not 0.

Thanks
Yuan



More information about the sheepdog mailing list