Skip to contentSkip to conversation

Update nfsiostat to display readahead counts

PATCH In review Dave Wysochanski 2 participants 3 messages Oct 9, 2021 – Oct 24, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Update nfsiostat to display readahead counts

Changes from v1
* Move parsing of 'statsver' into parse routine
* Simplify logic

Dave Wysochanski (1):
nfsiostat: Handle both readahead counts for statsver >= 1.2

 tools/nfs-iostat/nfs-iostat.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 nfsiostat: Handle both readahead counts for statsver >= 1.2

Later kernel versions convert NFS readpages to readahead so update the counts accordingly.

---
 tools/nfs-iostat/nfs-iostat.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
tools/nfs-iostat/nfs-iostat.py +9 -6
index 1df74ba822b5..85294fb9448c 100755
@@ -43,7 +43,7 @@ NfsEventCounters = [
     'vfspermission',
     'vfsupdatepage',
     'vfsreadpage',
-    'vfsreadpages',
+    'vfsreadpages', # or vfsreadahead in statvers=1.2 or above
     'vfswritepage',
     'vfswritepages',
     'vfsreaddir',
@@ -86,14 +86,14 @@ class DeviceData:
             self.__nfs_data['export'] = words[1]
             self.__nfs_data['mountpoint'] = words[4]
             self.__nfs_data['fstype'] = words[7]
-            if words[7] == 'nfs':
-                self.__nfs_data['statvers'] = words[8]
+            if words[7] == 'nfs' or words[7] == 'nfs4':
+                self.__nfs_data['statvers'] = float(words[8].split('=',1)[1])
         elif 'nfs' in words or 'nfs4' in words:
             self.__nfs_data['export'] = words[0]
             self.__nfs_data['mountpoint'] = words[3]
             self.__nfs_data['fstype'] = words[6]
             if words[6] == 'nfs':
-                self.__nfs_data['statvers'] = words[7]
+                self.__nfs_data['statvers'] = float(words[7].split('=',1)[1])
         elif words[0] == 'age:':
             self.__nfs_data['age'] = int(words[1])
         elif words[0] == 'opts:':
@@ -294,8 +294,11 @@ class DeviceData:
         print()
         print('%d nfs_readpage() calls read %d pages' % \
             (vfsreadpage, vfsreadpage))
-        print('%d nfs_readpages() calls read %d pages' % \
-            (vfsreadpages, pages_read - vfsreadpage))
+        multipageread = "readpages"
+        if self.__nfs_data['statvers'] >= 1.2:
+            multipageread = "readahead"
+        print('%d nfs_%s() calls read %d pages' % \
+            (vfsreadpages, multipageread, pages_read - vfsreadpage))
         if vfsreadpages != 0:
             print('(%.1f pages per call)' % \
                 (float(pages_read - vfsreadpage) / vfsreadpages))
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH v2 1/1] nfsiostat: Handle both readahead counts for statsver >= 1.2

Quoted 13 lines · Dave Wysochanski

Subject:
[PATCH v2 1/1] nfsiostat: Handle both readahead counts for statsver >= 1.2 From:
Dave Wysochanski <[email protected]>
Date:
10/9/21, 8:27 AM

To:
[email protected], [email protected]
CC:
[email protected]

Quoted 4 lines

Later kernel versions convert NFS readpages to readahead so update the counts accordingly.

Committed...

steved

Quoted 51 lines
---
  tools/nfs-iostat/nfs-iostat.py | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
tools/nfs-iostat/nfs-iostat.py +9 -7
index 1df74ba822b5..85294fb9448c 100755
@@ -43,7 +43,7 @@ NfsEventCounters = [
      'vfspermission',
      'vfsupdatepage',
      'vfsreadpage',
-    'vfsreadpages',
+    'vfsreadpages', # or vfsreadahead in statvers=1.2 or above
      'vfswritepage',
      'vfswritepages',
      'vfsreaddir',
@@ -86,14 +86,14 @@ class DeviceData:
              self.__nfs_data['export'] = words[1]
              self.__nfs_data['mountpoint'] = words[4]
              self.__nfs_data['fstype'] = words[7]
-            if words[7] == 'nfs':
-                self.__nfs_data['statvers'] = words[8]
+            if words[7] == 'nfs' or words[7] == 'nfs4':
+                self.__nfs_data['statvers'] = float(words[8].split('=',1)[1])
          elif 'nfs' in words or 'nfs4' in words:
              self.__nfs_data['export'] = words[0]
              self.__nfs_data['mountpoint'] = words[3]
              self.__nfs_data['fstype'] = words[6]
              if words[6] == 'nfs':
-                self.__nfs_data['statvers'] = words[7]
+                self.__nfs_data['statvers'] = float(words[7].split('=',1)[1])
          elif words[0] == 'age:':
              self.__nfs_data['age'] = int(words[1])
          elif words[0] == 'opts:':
@@ -294,8 +294,11 @@ class DeviceData:
          print()
          print('%d nfs_readpage() calls read %d pages' % \
              (vfsreadpage, vfsreadpage))
-        print('%d nfs_readpages() calls read %d pages' % \
-            (vfsreadpages, pages_read - vfsreadpage))
+        multipageread = "readpages"
+        if self.__nfs_data['statvers'] >= 1.2:
+            multipageread = "readahead"
+        print('%d nfs_%s() calls read %d pages' % \
+            (vfsreadpages, multipageread, pages_read - vfsreadpage))
          if vfsreadpages != 0:
              print('(%.1f pages per call)' % \
                  (float(pages_read - vfsreadpage) / vfsreadpages))
-- 1.8.3.1