mountstats/nfsiostat: when parsing the mountstats file, only keep the nfs mounts
Subsystems (2)
PATCH 1/1 mountstats/nfsiostat: when parsing the mountstats file, only keep the nfs mounts
Don't store the mountstats if the fstype is not nfs
--- tools/mountstats/mountstats.py | 18 +++++++++++++----- tools/nfs-iostat/nfs-iostat.py | 16 +++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-)
tools/mountstats/mountstats.py +13 -5
@@ -783,25 +783,33 @@ def parse_stats_file(f): """pop the contents of a mountstats file into a dictionary, keyed by mount point. each value object is a list of the lines in the mountstats file corresponding to the mount - point named in the key. + point named in the key. Only return nfs mounts. """ ms_dict = dict() key = '' + fstype = '' f.seek(0) for line in f.readlines(): words = line.split() if len(words) == 0: + fstype = '' + continue + if line.startswith("no device mounted"): + fstype = '' continue if words[0] == 'device': + if 'with fstype nfs' in line: + fstype = words[-2] + else: + fstype = words[-1] + key = words[4] new = [ line.strip() ] - elif 'nfs' in words or 'nfs4' in words: - key = words[3] - new = [ line.strip() ] else: new += [ line.strip() ] - ms_dict[key] = new + if fstype in ('nfs', 'nfs4'): + ms_dict[key] = new return ms_dict
tools/nfs-iostat/nfs-iostat.py +11 -5
@@ -445,27 +445,33 @@ def parse_stats_file(filename): """pop the contents of a mountstats file into a dictionary, keyed by mount point. each value object is a list of the lines in the mountstats file corresponding to the mount - point named in the key. + point named in the key. Only return nfs mounts. """ ms_dict = dict() key = '' + fstype = '' f = open(filename) for line in f.readlines(): words = line.split() if len(words) == 0: + fstype = '' continue if line.startswith("no device mounted"): + fstype = '' continue if words[0] == 'device': + if 'with fstype nfs' in line: + fstype = words[-2] + else: + fstype = words[-1] + key = words[4] new = [ line.strip() ] - elif 'nfs' in words or 'nfs4' in words: - key = words[3] - new = [ line.strip() ] else: new += [ line.strip() ] - ms_dict[key] = new + if fstype in ('nfs', 'nfs4'): + ms_dict[key] = new f.close return ms_dict
Signature · 1 line
2.47.1
Hi Frank -
Quoted 1 line · Frank Sorenson
Don't store the mountstats if the fstype is not nfs
The original intent of mountstats is to be agnostic to the file system type. The description must provide a reason why the proposed change needs to be made.
This patch doesn't provide a bug or email link either. There's no context we reviewers can use to help understand the purpose of this patch.
Generally, a patch description needs to explain, among other things, why the change is necessary. The diff already shows /what/ the patch is doing, thus a patch description typically does not need to repeat that.
Quoted 92 lines
Signed-off-by Frank Sorenson <[email protected]>--- tools/mountstats/mountstats.py | 18 +++++++++++++----- tools/nfs-iostat/nfs-iostat.py | 16 +++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-)tools/mountstats/mountstats.py +13
-5@@ -783,25 +783,33 @@ def parse_stats_file(f): """pop the contents of a mountstats file into a dictionary, keyed by mount point. each value object is a list of the lines in the mountstats file corresponding to the mount - point named in the key. + point named in the key. Only return nfs mounts. """ ms_dict = dict() key = '' + fstype = '' f.seek(0) for line in f.readlines(): words = line.split() if len(words) == 0: + fstype = '' + continue + if line.startswith("no device mounted"): + fstype = '' continue if words[0] == 'device': + if 'with fstype nfs' in line: + fstype = words[-2] + else: + fstype = words[-1] + key = words[4] new = [ line.strip() ] - elif 'nfs' in words or 'nfs4' in words: - key = words[3] - new = [ line.strip() ] else: new += [ line.strip() ] - ms_dict[key] = new + if fstype in ('nfs', 'nfs4'): + ms_dict[key] = new return ms_dicttools/nfs-iostat/nfs-iostat.py +11
-5@@ -445,27 +445,33 @@ def parse_stats_file(filename): """pop the contents of a mountstats file into a dictionary, keyed by mount point. each value object is a list of the lines in the mountstats file corresponding to the mount - point named in the key. + point named in the key. Only return nfs mounts. """ ms_dict = dict() key = '' + fstype = '' f = open(filename) for line in f.readlines(): words = line.split() if len(words) == 0: + fstype = '' continue if line.startswith("no device mounted"): + fstype = '' continue if words[0] == 'device': + if 'with fstype nfs' in line: + fstype = words[-2] + else: + fstype = words[-1] + key = words[4] new = [ line.strip() ] - elif 'nfs' in words or 'nfs4' in words: - key = words[3] - new = [ line.strip() ] else: new += [ line.strip() ] - ms_dict[key] = new + if fstype in ('nfs', 'nfs4'): + ms_dict[key] = new f.close return ms_dict
Signature · 1 line
Chuck Lever
Quoted 6 lines · Chuck Lever
Hi Frank -
Quoted 1 line · Frank Sorenson
Don't store the mountstats if the fstype is not nfs
The original intent of mountstats is to be agnostic to the file system
Ah, I see. Yes, this patch certainly would have taken things the opposite direction then. Thank you for the correction.
This patch would have made fixing some nfs-related bugs easier ('mountstats iostat' crashes after unmount, and 'nfsiostat' crashes after new mount), but it doesn't directly fix either. I'll re-evaluate my approach, and see if I can fix them without making them (at least mountstats) nfs-specific.
Quoted 10 lines
type. The description must provide a reason why the proposed change needs to be made.
This patch doesn't provide a bug or email link either. There's no context we reviewers can use to help understand the purpose of this patch.
Generally, a patch description needs to explain, among other things, why the change is necessary. The diff already shows /what/ the patch is doing, thus a patch description typically does not need to repeat that.
Understood; explain the problem leading to the need for the fix, instead. I failed to do that.
There was a purpose, but I neglected to explain it. In light of my misunderstanding of the intent of mountstats, it's not important at this point.
Sorry, I'll do better.
Frank
Quoted 90 lines
Quoted 88 lines
Signed-off-by Frank Sorenson <[email protected]>---
tools/mountstats/mountstats.py| 18 +++++++++++++-----tools/nfs-iostat/nfs-iostat.py| 16 +++++++++++-----2 files changed, 24 insertions(+), 10 deletions(-)tools/mountstats/mountstats.py +0
-0@@ -783,25 +783,33 @@ def parse_stats_file(f): """pop the contents of a mountstats file into a dictionary,keyed by mount point. each value object is a list of the lines in the mountstats file corresponding to the mount
- point named in the key.
+ point named in the key. Only return nfs mounts.
"""
ms_dict=dict()
key = ''
+ fstype = ''
f.seek(0)
for line inf.readlines():
words =line.split()
if len(words) == 0:
+ fstype = ''
+ continue
+ ifline.startswith("no device mounted"):
+ fstype = ''
continue
if words[0] == 'device':
+ if 'with fstype nfs' in line:
+ fstype = words[-2]
+ else:
+ fstype = words[-1]
+
key = words[4]
new = [line.strip()]
- elif 'nfs' in words or 'nfs4' in words:
- key = words[3]
- new = [line.strip()]
else:
new += [line.strip()]
- ms_dict[key] = new
+ if fstype in ('nfs', 'nfs4'):
+ ms_dict[key] = new
returnms_dict
diff --gita/tools/nfs-iostat/nfs-iostat.pyb/tools/nfs-iostat/nfs-iostat.pyindex 31587370..f97b23c0 100755tools/nfs-iostat/nfs-iostat.py +0
-0@@ -445,27 +445,33 @@ def parse_stats_file(filename): """pop the contents of a mountstats file into a dictionary,keyed by mount point. each value object is a list of the lines in the mountstats file corresponding to the mount - point named in the key.
+ point named in the key. Only return nfs mounts. """
ms_dict=dict()
key = ''
+ fstype = ''
f = open(filename)
for line inf.readlines():
words =line.split()
if len(words) == 0:
+ fstype = ''
continue
ifline.startswith("no device mounted"):
+ fstype = ''
continue
if words[0] == 'device':
+ if 'with fstype nfs' in line:
+ fstype = words[-2]
+ else:
+ fstype = words[-1]
+
key = words[4]
new = [line.strip()]
- elif 'nfs' in words or 'nfs4' in words:
- key = words[3]
- new = [line.strip()]
else:
new += [line.strip()]
- ms_dict[key] = new
+ if fstype in ('nfs', 'nfs4'):
+ ms_dict[key] = new
f.close
returnms_dict
Signature · 4 lines
Frank Sorenson [email protected] Principal Software Maintenance Engineer, filesystems Red Hat