Skip to contentSkip to conversation

nfsdclnts: fix display of stateids where the kernel doesn't provide the superblock

PATCH In review Frank Sorenson 2 participants 2 messages Feb 27 – Mar 6

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

PATCH 1/1 nfsdclnts: fix display of stateids where the kernel doesn't provide the superblock

If the stateid's file can't be found, the kernel will skip printing the superblock and filename in the 'states' procfile. When this happens, nfsdclnts crashes trying to reference the non-existent superblock key while getting the inode.

Fix this by setting the inode field to 'N/A' when the superblock isn't present, as is done with other fields which may be missing.

---
 tools/nfsdclnts/nfsdclnts.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/nfsdclnts/nfsdclnts.py +4 -1
index b7280f2c..183a02ee 100755
@@ -87,7 +87,10 @@ def printer(data_list, argument):
     client_info = file_to_dict(client_info_path)
     for i in data_list:
         for key in i:
-            inode = i[key]['superblock'].split(':')[-1]
+            try:
+                inode = i[key]['superblock'].split(':')[-1]
+            except:
+                inode = 'N/A'
             # The ip address is quoted, so we dequote it.
             try:
                 client_ip = client_info['address'][1:-1]
Signature · 1 line
2.52.0
#1 lore raw
Quoted 9 lines · Frank Sorenson

If the stateid's file can't be found, the kernel will skip printing the superblock and filename in the 'states' procfile. When this happens, nfsdclnts crashes trying to reference the non-existent superblock key while getting the inode.

Fix this by setting the inode field to 'N/A' when the superblock isn't present, as is done with other fields which may be missing.

Committed... (tag: nfs-utils-2-8-6-rc4)

steved.

Quoted 20 lines
---
  tools/nfsdclnts/nfsdclnts.py | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
tools/nfsdclnts/nfsdclnts.py +4 -1
index b7280f2c..183a02ee 100755
@@ -87,7 +87,10 @@ def printer(data_list, argument):
      client_info = file_to_dict(client_info_path)
      for i in data_list:
          for key in i:
-            inode = i[key]['superblock'].split(':')[-1]
+            try:
+                inode = i[key]['superblock'].split(':')[-1]
+            except:
+                inode = 'N/A'
              # The ip address is quoted, so we dequote it.
              try:
                  client_ip = client_info['address'][1:-1]