All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mountstats: division by zero error on new mount when 0==rpcsends
@ 2021-09-22 15:44 Stig
  2021-09-23 16:39 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Stig @ 2021-09-22 15:44 UTC (permalink / raw)
  To: linux-nfs

For https://bugzilla.linux-nfs.org/show_bug.cgi?id=367

When rpcsends is 0 this is the error seen when mounstats is run on a
NFSv4.2 mount:

> sudo umount /fsx ; sudo mount /fsx ; mountstats /fsx
...
RPC statistics:
  0 RPC requests sent, 0 RPC replies received (0 XIDs not found)

SERVER_CAPS:
Traceback (most recent call last):
  File "mountstats.py.orig", line 1134, in <module>
    res = main()
  File "mountstats.py.orig", line 1123, in main
    return args.func(args)
  File "mountstats.py.orig", line 863, in mountstats_command
    print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw,
args.xprt_only)
  File "mountstats.py.orig", line 825, in print_mountstats
    stats.display_rpc_op_stats()
  File "mountstats.py.orig", line 486, in display_rpc_op_stats
    (count, ((count * 100) / sends)), end=' ')
ZeroDivisionError: division by zero

Fixed with:

diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index 23876fc..8e129c8 100755
--- a/tools/mountstats/mountstats.py
+++ b/tools/mountstats/mountstats.py
@@ -482,8 +482,11 @@ class DeviceData:
             count = stats[1]
             if count != 0:
                 print('%s:' % stats[0])
+                ops_pcnt = 0
+                if sends != 0:
+                    ops_pcnt = (count * 100) / sends
                 print('\t%d ops (%d%%)' % \
-                    (count, ((count * 100) / sends)), end=' ')
+                    (count, ops_pcnt), end=' ')
                 retrans = stats[2] - count
                 if retrans != 0:
                     print('\t%d retrans (%d%%)' % (retrans, ((retrans
* 100) / count)), end=' ')

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] mountstats: division by zero error on new mount when 0==rpcsends
  2021-09-22 15:44 [PATCH 1/1] mountstats: division by zero error on new mount when 0==rpcsends Stig
@ 2021-09-23 16:39 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2021-09-23 16:39 UTC (permalink / raw)
  To: Stig, linux-nfs



On 9/22/21 11:44 AM, Stig wrote:
> For https://bugzilla.linux-nfs.org/show_bug.cgi?id=367
> 
> When rpcsends is 0 this is the error seen when mounstats is run on a
> NFSv4.2 mount:
> 
>> sudo umount /fsx ; sudo mount /fsx ; mountstats /fsx
Committed... (tag: nfs-utils-2-5-5-rc3)

On future patches please use the proper 'Signed-off-by:' tag.

steved.

> ...
> RPC statistics:
>    0 RPC requests sent, 0 RPC replies received (0 XIDs not found)
> 
> SERVER_CAPS:
> Traceback (most recent call last):
>    File "mountstats.py.orig", line 1134, in <module>
>      res = main()
>    File "mountstats.py.orig", line 1123, in main
>      return args.func(args)
>    File "mountstats.py.orig", line 863, in mountstats_command
>      print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw,
> args.xprt_only)
>    File "mountstats.py.orig", line 825, in print_mountstats
>      stats.display_rpc_op_stats()
>    File "mountstats.py.orig", line 486, in display_rpc_op_stats
>      (count, ((count * 100) / sends)), end=' ')
> ZeroDivisionError: division by zero
> 
> Fixed with:
> 
> diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
> index 23876fc..8e129c8 100755
> --- a/tools/mountstats/mountstats.py
> +++ b/tools/mountstats/mountstats.py
> @@ -482,8 +482,11 @@ class DeviceData:
>               count = stats[1]
>               if count != 0:
>                   print('%s:' % stats[0])
> +                ops_pcnt = 0
> +                if sends != 0:
> +                    ops_pcnt = (count * 100) / sends
>                   print('\t%d ops (%d%%)' % \
> -                    (count, ((count * 100) / sends)), end=' ')
> +                    (count, ops_pcnt), end=' ')
>                   retrans = stats[2] - count
>                   if retrans != 0:
>                       print('\t%d retrans (%d%%)' % (retrans, ((retrans
> * 100) / count)), end=' ')
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-23 16:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 15:44 [PATCH 1/1] mountstats: division by zero error on new mount when 0==rpcsends Stig
2021-09-23 16:39 ` Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.