blk-iocost: fix divide by 0 error in calc_lcoefs()
[linux-2.6-microblaze.git] / block / blk-iocost.c
index 58ad4e5..a4f1956 100644 (file)
@@ -868,9 +868,14 @@ static void calc_lcoefs(u64 bps, u64 seqiops, u64 randiops,
 
        *page = *seqio = *randio = 0;
 
-       if (bps)
-               *page = DIV64_U64_ROUND_UP(VTIME_PER_SEC,
-                                          DIV_ROUND_UP_ULL(bps, IOC_PAGE_SIZE));
+       if (bps) {
+               u64 bps_pages = DIV_ROUND_UP_ULL(bps, IOC_PAGE_SIZE);
+
+               if (bps_pages)
+                       *page = DIV64_U64_ROUND_UP(VTIME_PER_SEC, bps_pages);
+               else
+                       *page = 1;
+       }
 
        if (seqiops) {
                v = DIV64_U64_ROUND_UP(VTIME_PER_SEC, seqiops);