dsched_fq - Avoid a rare div by 0
authorAlex Hornung <ahornung@gmail.com>
Tue, 13 Apr 2010 18:47:51 +0000 (18:47 +0000)
committerAlex Hornung <ahornung@gmail.com>
Thu, 15 Apr 2010 20:24:51 +0000 (20:24 +0000)
* Avoid a rare division by 0 when calculating how busy the disk has
  been. It seems that sometimes the total disk time is 0, so when this
  happens, just assume that at least 1 us has passed.

sys/dsched/fq/dsched_fq_core.c

index c2bbf6f..cec852f 100644 (file)
@@ -454,6 +454,10 @@ fq_balance_thread(struct dsched_fq_dpriv *dpriv)
 
                total_disk_time = (int)(1000000*((tv.tv_sec - old_tv.tv_sec)) +
                    (tv.tv_usec - old_tv.tv_usec));
+
+               if (total_disk_time == 0)
+                       total_disk_time = 1;
+
                dsched_debug(LOG_INFO, "total_disk_time = %d\n", total_disk_time);
 
                old_tv = tv;