public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank Sorenson <sorenson@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: steved@redhat.com, chuck.lever@oracle.com
Subject: [nfs-utils PATCH 3/8] nfsiostat: mirror how mountstats iostat prints the stats
Date: Thu, 30 Jan 2025 08:20:02 -0600	[thread overview]
Message-ID: <20250130142008.3600334-4-sorenson@redhat.com> (raw)
In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com>

Currently, nfsiostat assumes that if old mountstats are provided,
then 'old' will contain all the new devices as well, and will
therefore crash if outputting multiple iterations and a new nfs
mount occurs between iterations.

'mountstats iostat' covers the new-nfs-mount situation by checking
that the old mountstats contains the device before referencing it.
It also verifies both old and new mountpoints are the same type.
Therefore, make the nfsiostat output function like mountstats.

However nfsiostat also has to allow sorting, so we can't just
output the full/diff stats as we go.  Instead, put the stats to
output into a list to display, sort the list if necessary, then
output the stats at the end.

Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
 tools/nfs-iostat/nfs-iostat.py | 42 ++++++++++++----------------------
 1 file changed, 14 insertions(+), 28 deletions(-)

diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
index 95176a4b..bf5eead9 100755
--- a/tools/nfs-iostat/nfs-iostat.py
+++ b/tools/nfs-iostat/nfs-iostat.py
@@ -476,41 +476,27 @@ def parse_stats_file(filename):
     return ms_dict
 
 def print_iostat_summary(old, new, devices, time, options):
-    stats = {}
-    diff_stats = {}
-    devicelist = []
-    if old:
-        # Trim device list to only include intersection of old and new data,
-        # this addresses umounts due to autofs mountpoints
-        for device in devices:
-            if "fstype autofs" not in str(old[device]):
-                devicelist.append(device)
-    else:
-        devicelist = devices
+    display_stats = {}
 
-    for device in devicelist:
-        stats[device] = DeviceData()
-        stats[device].parse_stats(new[device])
-        if old:
+    for device in devices:
+        stats = DeviceData()
+        stats.parse_stats(new[device])
+        if old and device in old:
             old_stats = DeviceData()
             old_stats.parse_stats(old[device])
-            diff_stats[device] = stats[device].compare_iostats(old_stats)
+            if stats.fstype() == old_stats.fstype():
+                display_stats[device] = stats.compare_iostats(old_stats)
+            else: # device is in old, but fstypes are different
+                display_stats[device] = stats
+        else: # device is only in new
+            display_stats[device] = stats
 
     if options.sort:
-        if old:
-            # We now have compared data and can print a comparison
-            # ordered by mountpoint ops per second
-            devicelist.sort(key=lambda x: diff_stats[x].ops(time), reverse=True)
-        else:
-            # First iteration, just sort by newly parsed ops/s
-            devicelist.sort(key=lambda x: stats[x].ops(time), reverse=True)
+        devices.sort(key=lambda x: display_stats[x].ops(time), reverse=True)
 
     count = 1
-    for device in devicelist:
-        if old:
-            diff_stats[device].display_iostats(time, options.which)
-        else:
-            stats[device].display_iostats(time, options.which)
+    for device in devices:
+        display_stats[device].display_iostats(time, options.which)
 
         count += 1
         if (count > options.list):
-- 
2.48.1


  parent reply	other threads:[~2025-01-30 14:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 14:19 [nfs-utils PATCH 0/8] mountstats/nfsiostat: bugfixes for iostat Frank Sorenson
2025-01-30 14:20 ` [nfs-utils PATCH 1/8] mountstats/nfsiostat: add a function to return the fstype Frank Sorenson
2025-01-30 14:20 ` [nfs-utils PATCH 2/8] mountstats: when printing iostats, verify that old and new types are the same Frank Sorenson
2025-01-30 14:20 ` Frank Sorenson [this message]
2025-01-30 14:20 ` [nfs-utils PATCH 4/8] nfsiostat: fix crash when filtering mountstats after unmount Frank Sorenson
2025-01-30 14:20 ` [nfs-utils PATCH 5/8] nfsiostat: make comment explain mount/unmount more broadly Frank Sorenson
2025-01-30 14:20 ` [nfs-utils PATCH 6/8] mountstats: filter for nfs mounts in a function, each iostat iteration Frank Sorenson
2025-01-30 14:20 ` [nfs-utils PATCH 7/8] mountstats/nfsiostat: Move the checks for empty mountpoint list into the print function Frank Sorenson
2025-01-30 14:20 ` [nfs-utils PATCH 8/8] mountstats/nfsiostat: merge and rework the infinite and counted loops Frank Sorenson
2025-01-30 14:28 ` [nfs-utils PATCH 0/8] mountstats/nfsiostat: bugfixes for iostat Chuck Lever
2025-02-05 22:53 ` Steve Dickson

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=20250130142008.3600334-4-sorenson@redhat.com \
    --to=sorenson@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.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