Message ID | 20250130142008.3600334-5-sorenson@redhat.com (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | mountstats/nfsiostat: bugfixes for iostat | expand |
diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index bf5eead9..08b827c0 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -511,10 +511,11 @@ def list_nfs_mounts(givenlist, mountstats): devicelist = [] if len(givenlist) > 0: for device in givenlist: - stats = DeviceData() - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - devicelist += [device] + if device in mountstats: + stats = DeviceData() + stats.parse_stats(mountstats[device]) + if stats.is_nfs_mountpoint(): + devicelist += [device] else: for device, descr in mountstats.items(): stats = DeviceData()
If an unmount occurs between iterations, the filter function will crash when referencing the 'device' in the new mountstats. Verify it exists before trying to access it. Signed-off-by: Frank Sorenson <sorenson@redhat.com> --- tools/nfs-iostat/nfs-iostat.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)