From: Ruoyu <[email protected]>

Once the recovery count is less than 100, sheep process will crash
because of devided by zero.

The solution is round up the recovery count first to make sure
the result is not zero.

Cc: Saeki Masaki <[email protected]>
Signed-off-by: Ruoyu <[email protected]>
Signed-off-by: Liu Yuan <[email protected]>
---
 sheep/recovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 2f13962..fc6a56b 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -858,7 +858,7 @@ static void recover_object_main(struct work *work)
        wakeup_requests_on_oid(row->oid);
        rinfo->done++;
 
-       if (!(rinfo->done % (rinfo->count/100)))
+       if (!(rinfo->done % DIV_ROUND_UP(rinfo->count, 100)))
                sd_info("object recovery progress %3.0lf%% ",
                        (double)rinfo->done / rinfo->count * 100);
        sd_debug("object %"PRIx64" is recovered (%"PRIu64"/%"PRIu64")",
-- 
1.9.1

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to