ports/158876: [PATCH] zfs-stats devides by zero if $demand_data_total = 0

Leon Meßner l.messner at physik.tu-berlin.de
Wed Jul 13 18:30:09 UTC 2011


>Number:         158876
>Category:       ports
>Synopsis:       [PATCH] zfs-stats devides by zero if $demand_data_total = 0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 13 18:30:08 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Leon Meßner
>Release:        8-STABLE
>Organization:
>Environment:
FreeBSD siloneu.physik-pool.tu-berlin.de 8.2-STABLE FreeBSD 8.2-STABLE #0: Mon Jun 20 00:49:56 CEST 2011     master at siloneu.physik-pool.tu-berlin.de:/usr/obj/usr/src/sys/DEBUG  amd64
>Description:
Running zfs-stats version 1.0

20:02_root at siloneu:/usr/local/bin# zfs-stats -V
zfs-stats version 1.0

i get the following output

20:01_root at siloneu:/usr/local/bin# zfs-stats -A
[...]
Illegal division by zero at /usr/local/bin/zfs-stats line 385.

This is easily fixed by the attached patch, which employs the same catch as has been for $prefetch_data_perc. Although i don't know if this logic is right in this place.
>How-To-Repeat:
Install sysutils/zfs-stat, invoke with "-A" flag and have no load? thus $demand_data_total be zero.
>Fix:
--- zfs-stats.orig      2011-07-13 19:46:41.000000000 +0200
+++ zfs-stats   2011-07-13 20:11:45.000000000 +0200
@@ -382,7 +382,10 @@ if ($showarc != 0) {
        }
 
        my $demand_data_total = ($demand_data_hits + $demand_data_misses);
-       my $demand_data_perc = 100*($demand_data_hits / $demand_data_total);
+       my $demand_data_perc = "00";
+       if ($demand_data_total > 0) {
+               $demand_data_perc = 100*($demand_data_hits / $demand_data_total);
+       }
 
        print "ARC Efficiency:\n";
        printf("\tCache Access Total:\t\t\t%d\n",

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list