Date: Wed, 13 Jul 2011 18:23:05 GMT From: Leon Meßner <l.messner@physik.tu-berlin.de> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/158876: [PATCH] zfs-stats devides by zero if $demand_data_total = 0 Message-ID: <201107131823.p6DIN503000551@red.freebsd.org> Resent-Message-ID: <201107131830.p6DIU8Gm009270@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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@siloneu.physik-pool.tu-berlin.de:/usr/obj/usr/src/sys/DEBUG amd64 >Description: Running zfs-stats version 1.0 20:02_root@siloneu:/usr/local/bin# zfs-stats -V zfs-stats version 1.0 i get the following output 20:01_root@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107131823.p6DIN503000551>