linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: Stig <thatsafunnyname@gmail.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/1] mountstats: division by zero error on new mount when 0==rpcsends
Date: Thu, 23 Sep 2021 12:39:24 -0400	[thread overview]
Message-ID: <52652487-e2c5-a7b9-ec87-5a184a48c1ab@redhat.com> (raw)
In-Reply-To: <CAD9POpJSfbBYVgupAFxie_N6g2BQAUZ-qWV=tZFMHMJMmdqoYw@mail.gmail.com>



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=' ')
> 


      reply	other threads:[~2021-09-23 16:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52652487-e2c5-a7b9-ec87-5a184a48c1ab@redhat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=thatsafunnyname@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).