Skip to contentSkip to conversation

mountstats: Fix nfsstat command to handle RPC iostats version >= 1.1

PATCH In review Dave Wysochanski 2 participants 2 messages Jun 26, 2019 – Aug 1, 2019

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

PATCH 1/1 mountstats: Fix nfsstat command to handle RPC iostats version >= 1.1

Later kernels with RPC iostats version >= 1.1 have an additional errors count for each op. Lengthen the array of values created inside DeviceData and then in __parse_rpc_line just zero this value out for prior kernels where this count is not present. The count is not used for nfsstat, but this keeps DeviceData consistent with the new count as well as proper functioning of accumulate_iostats.

Before this patch, nfsstat will backtrace on a kernel with RPC iostats version >= 1.1 due to the fixed array inside DeviceData. This patch fixes this backtrace and also allows nfsstat to work with these new kernels.

---
 tools/mountstats/mountstats.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/mountstats/mountstats.py +3 -1
index c5e8f506..6ac83ccb 100755
@@ -308,6 +308,8 @@ class DeviceData:
             op = words[0][:-1]
             self.__rpc_data['ops'] += [op]
             self.__rpc_data[op] = [int(word) for word in words[1:]]
+            if len(self.__rpc_data[op]) < 9:
+                self.__rpc_data[op] += [0]
 
     def parse_stats(self, lines):
         """Turn a list of lines from a mount stat file into a 
@@ -582,7 +584,7 @@ class DeviceData:
             self.__nfs_data['fstype'] = 'nfs4'
         self.__rpc_data['ops'] = ops
         for op in ops:
-            self.__rpc_data[op] = [0 for i in range(8)]
+            self.__rpc_data[op] = [0 for i in range(9)]
 
     def accumulate_iostats(self, new_stats):
         """Accumulate counters from all RPC op buckets in new_stats.  This is
Signature · 1 line
2.20.1
#1 lore raw
Quoted 7 lines · Dave Wysochanski

Later kernels with RPC iostats version >= 1.1 have an additional errors count for each op. Lengthen the array of values created inside DeviceData and then in __parse_rpc_line just zero this value out for prior kernels where this count is not present. The count is not used for nfsstat, but this keeps DeviceData consistent with the new count as well as proper functioning of accumulate_iostats.

Quoted 6 lines

Before this patch, nfsstat will backtrace on a kernel with RPC iostats version >= 1.1 due to the fixed array inside DeviceData. This patch fixes this backtrace and also allows nfsstat to work with these new kernels.

Committed...

steved

Quoted 27 lines
---
 tools/mountstats/mountstats.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/mountstats/mountstats.py +3 -1
index c5e8f506..6ac83ccb 100755
@@ -308,6 +308,8 @@ class DeviceData:
             op = words[0][:-1]
             self.__rpc_data['ops'] += [op]
             self.__rpc_data[op] = [int(word) for word in words[1:]]
+            if len(self.__rpc_data[op]) < 9:
+                self.__rpc_data[op] += [0]
 
     def parse_stats(self, lines):
         """Turn a list of lines from a mount stat file into a 
@@ -582,7 +584,7 @@ class DeviceData:
             self.__nfs_data['fstype'] = 'nfs4'
         self.__rpc_data['ops'] = ops
         for op in ops:
-            self.__rpc_data[op] = [0 for i in range(8)]
+            self.__rpc_data[op] = [0 for i in range(9)]
 
     def accumulate_iostats(self, new_stats):
         """Accumulate counters from all RPC op buckets in new_stats.  This is