Add a tool for using the new sysfs files
Subsystems (2)
cover Add a tool for using the new sysfs files
From: Anna Schumaker <[email protected]>
These patches implement a tool that can be used to read and write the sysfs files, with subcommands! They need Olga's most recent patches to run.
The following subcommands are implemented:
nfs-sysfs.py rpc-client
nfs-sysfs.py xprt
nfs-sysfs.py xprt set
nfs-sysfs.py xprt-switch
nfs-sysfs.py xprt-switch set
So you can print out information about every xprt-switch with:
anna@client % ./nfs-sysfs.py xprt-switch switch 0: num_xprts 1, num_active 1, queue_len 0
xprt 0: local, /var/run/gssproxy.sock
switch 1: num_xprts 1, num_active 1, queue_len 0
xprt 1: local, /var/run/rpcbind.sock
switch 2: num_xprts 4, num_active 4, queue_len 0
xprt 2: tcp, 192.168.111.188
xprt 3: tcp, 192.168.111.188
xprt 5: tcp, 192.168.111.188
xprt 6: tcp, 192.168.111.188
switch 3: num_xprts 1, num_active 1, queue_len 0
xprt 7: tcp, 192.168.111.1
switch 4: num_xprts 1, num_active 1, queue_len 0
xprt 4: tcp, 192.168.111.188
And information about each xprt:
anna@client % ./nfs-sysfs.py xprt xprt 0: local, /var/run/gssproxy.sock, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 1: local, /var/run/rpcbind.sock, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 2: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 3: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 4: tcp, 192.168.111.188, state <BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 5: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 6: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 7: tcp, 192.168.111.1, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0
You can use the set subcommand to change the dstaddr of individual xprts:
anna@client % ./nfs-sysfs.py xprt --id 2 xprt 2: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 anna@client % sudo ./nfs-sysfs.py xprt set --id 2 --dstaddr server2.nowheycreamery.vm xprt 2: tcp, 192.168.111.186, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0
Or for changing the dstaddr of all xprts attached to a switch:
anna@client % ./nfs-sysfs.py xprt-switch --id 2 switch 2: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.188 xprt 3: tcp, 192.168.111.188 xprt 5: tcp, 192.168.111.188 xprt 6: tcp, 192.168.111.188 anna@client % sudo ./nfs-sysfs.py xprt-switch set --id 2 --dstaddr server2.nowheycreamery.vm switch 2: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.186 xprt 3: tcp, 192.168.111.186 xprt 5: tcp, 192.168.111.186 xprt 6: tcp, 192.168.111.186
I'm sure this needs lots of polish before it's ready for inclusion, along with needing a Makefile so it can be installed (I've just been running it out of the nfs-utils/tools/nfs-sysfs/ directory). But it's still a start, and I wanted to post it before going on New Baby Leave Part 2 (June 12 - July 11).
What does everybody think?
Anna
Anna Schumaker (6):
nfs-sysfs: Add an nfs-sysfs.py tool
nfs-sysfs.py: Add a command for printing xprt switch information nfs-sysfs.py: Add a command for printing individual xprts nfs-sysfs.py: Add a command for printing rpc-client information nfs-sysfs.py: Add a command for changing xprt dstaddr nfs-sysfs.py: Add a command for changing xprt-switch dstaddrs
tools/nfs-sysfs/client.py | 27 ++++++++++++++ tools/nfs-sysfs/nfs-sysfs.py | 23 ++++++++++++ tools/nfs-sysfs/switch.py | 51 +++++++++++++++++++++++++++ tools/nfs-sysfs/sysfs.py | 28 +++++++++++++++ tools/nfs-sysfs/xprt.py | 68 ++++++++++++++++++++++++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 tools/nfs-sysfs/client.py create mode 100755 tools/nfs-sysfs/nfs-sysfs.py create mode 100644 tools/nfs-sysfs/switch.py create mode 100644 tools/nfs-sysfs/sysfs.py create mode 100644 tools/nfs-sysfs/xprt.py
Signature · 1 line
2.32.0
RFC PATCH 1/6 nfs-sysfs: Add an nfs-sysfs.py tool
From: Anna Schumaker <[email protected]>
This will be used to print and manipulate the sunrpc sysfs directory files. Running without arguments prints both usage information and the location of the sunrpc sysfs directory.
--- tools/nfs-sysfs/nfs-sysfs.py | 13 +++++++++++++ tools/nfs-sysfs/sysfs.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 tools/nfs-sysfs/nfs-sysfs.py create mode 100644 tools/nfs-sysfs/sysfs.py
tools/nfs-sysfs/nfs-sysfs.py new file +13 -0
@@ -0,0 +1,13 @@ +#!/usr/bin/python +import argparse +import sysfs + +parser = argparse.ArgumentParser() + +def show_small_help(args): + parser.print_usage() + print("sunrpc dir:", sysfs.SUNRPC) +parser.set_defaults(func=show_small_help) + +args = parser.parse_args() +args.func(args)
tools/nfs-sysfs/sysfs.py new file +18 -0
@@ -0,0 +1,18 @@ +import pathlib +import sys + +MOUNT = None +with open("/proc/mounts", 'r') as f: + for line in f: + if "sysfs" in line: + MOUNT = line.split()[1] + break + +if MOUNT == None: + print("ERROR: sysfs is not mounted") + sys.exit(1) + +SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" +if not SUNRPC.is_dir(): + print("ERROR: sysfs does not have sunrpc directory") + sys.exit(1)
Signature · 1 line
2.32.0
RFC PATCH 2/6 nfs-sysfs.py: Add a command for printing xprt switch information
In reply to [email protected]From: Anna Schumaker <[email protected]>
This combines the information found in xprt_switch_info with a subset of the information found in each xprt subdirectory
--- tools/nfs-sysfs/nfs-sysfs.py | 6 ++++++ tools/nfs-sysfs/switch.py | 35 +++++++++++++++++++++++++++++++++++ tools/nfs-sysfs/sysfs.py | 10 ++++++++++ tools/nfs-sysfs/xprt.py | 12 ++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tools/nfs-sysfs/switch.py create mode 100644 tools/nfs-sysfs/xprt.py
tools/nfs-sysfs/nfs-sysfs.py +6 -0
@@ -9,5 +9,11 @@ def show_small_help(args): print("sunrpc dir:", sysfs.SUNRPC) parser.set_defaults(func=show_small_help) + +import switch +subparser = parser.add_subparsers(title="commands") +switch.add_command(subparser) + + args = parser.parse_args() args.func(args)
tools/nfs-sysfs/switch.py new file +35 -0
@@ -0,0 +1,35 @@ +import sysfs +import xprt + +class XprtSwitch: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 1)[1]) + + self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] + self.xprts.sort() + + self.__dict__.update(sysfs.read_info_file(path / "xprt_switch_info")) + + def __lt__(self, rhs): + return self.path < rhs.path + + def __str__(self): + line = "switch %s: num_xprts %s, num_active %s, queue_len %s" % \ + (self.id, self.num_xprts, self.num_active, self.queue_len) + for x in self.xprts: + line += "\n %s" % x.small_str() + return line + + +def list_xprt_switches(args): + switches = [ XprtSwitch(f) for f in (sysfs.SUNRPC / "xprt-switches").iterdir() ] + switches.sort() + for xs in switches: + if args.id == None or xs.id == args.id[0]: + print(xs) + +def add_command(subparser): + parser = subparser.add_parser("xprt-switch", help="Commands for xprt switches") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") + parser.set_defaults(func=list_xprt_switches)
tools/nfs-sysfs/sysfs.py +10 -0
@@ -16,3 +16,13 @@ SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" if not SUNRPC.is_dir(): print("ERROR: sysfs does not have sunrpc directory") sys.exit(1) + + +def read_info_file(path): + res = dict() + with open(path) as info: + for line in info: + if "=" in line: + (key, val) = line.strip().split("=") + res[key] = int(val) + return res
tools/nfs-sysfs/xprt.py new file +12 -0
@@ -0,0 +1,12 @@ +class Xprt: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 2)[1]) + self.type = str(path).rsplit("-", 2)[2] + self.dstaddr = open(path / "dstaddr", 'r').readline().strip() + + def __lt__(self, rhs): + return self.id < rhs.id + + def small_str(self): + return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr)
Signature · 1 line
2.32.0
RFC PATCH 3/6 nfs-sysfs.py: Add a command for printing individual xprts
In reply to [email protected]From: Anna Schumaker <[email protected]>
This shows more detailed information than what is presented with xprt switches.
--- tools/nfs-sysfs/nfs-sysfs.py | 2 ++ tools/nfs-sysfs/xprt.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
tools/nfs-sysfs/nfs-sysfs.py +2 -0
@@ -11,8 +11,10 @@ parser.set_defaults(func=show_small_help) import switch +import xprt subparser = parser.add_subparsers(title="commands") switch.add_command(subparser) +xprt.add_command(subparser) args = parser.parse_args()
tools/nfs-sysfs/xprt.py +28 -0
@@ -1,3 +1,5 @@ +import sysfs + class Xprt: def __init__(self, path): self.path = path
@@ -5,8 +7,34 @@ class Xprt: self.type = str(path).rsplit("-", 2)[2] self.dstaddr = open(path / "dstaddr", 'r').readline().strip() + with open(path / "xprt_state") as f: + self.state = ','.join(f.readline().split()[1:]) + self.__dict__.update(sysfs.read_info_file(path / "xprt_info")) + def __lt__(self, rhs): return self.id < rhs.id + def __str__(self): + line = "xprt %s: %s, %s, state <%s>, num_reqs %s" % \ + (self.id, self.type, self.dstaddr, self.state, self.num_reqs) + line += "\n cur_cong %s, cong_win %s, min_num_slots %s, max_num_slots %s" % \ + (self.cur_cong, self.cong_win, self.min_num_slots, self.max_num_slots) + line += "\n binding_q_len %s, sending_q_len %s, pending_q_len %s, backlog_q_len %s" % \ + (self.binding_q_len, self.sending_q_len, self.pending_q_len, self.backlog_q_len) + return line + def small_str(self): return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr) + + +def list_xprts(args): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + xprts.sort() + for xprt in xprts: + if args.id == None or xprt.id == args.id[0]: + print(xprt) + +def add_command(subparser): + parser = subparser.add_parser("xprt", help="Commands for individual xprts") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") + parser.set_defaults(func=list_xprts)
Signature · 1 line
2.32.0
RFC PATCH 4/6 nfs-sysfs.py: Add a command for printing rpc-client information
In reply to [email protected]From: Anna Schumaker <[email protected]>
It's mostly the same information as with xprt-switches, except with rpc-client id prepended to the first line.
--- tools/nfs-sysfs/client.py | 27 +++++++++++++++++++++++++++ tools/nfs-sysfs/nfs-sysfs.py | 2 ++ tools/nfs-sysfs/switch.py | 7 ++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tools/nfs-sysfs/client.py
tools/nfs-sysfs/client.py new file +27 -0
@@ -0,0 +1,27 @@ +import sysfs +import switch + +class RpcClient: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 1)[1]) + self.switch = switch.XprtSwitch(path / (path / "switch").readlink(), sep=",") + + def __lt__(self, rhs): + return self.id < rhs.id + + def __str__(self): + return "client %s: %s" % (self.id, self.switch) + + +def list_rpc_clients(args): + clients = [ RpcClient(f) for f in (sysfs.SUNRPC / "rpc-clients").iterdir() ] + clients.sort() + for client in clients: + if args.id == None or client.id == args.id[0]: + print(client) + +def add_command(subparser): + parser = subparser.add_parser("rpc-client", help="Commands for rpc clients") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific client to show") + parser.set_defaults(func=list_rpc_clients)
tools/nfs-sysfs/nfs-sysfs.py +2 -0
@@ -10,9 +10,11 @@ def show_small_help(args): parser.set_defaults(func=show_small_help) +import client import switch import xprt subparser = parser.add_subparsers(title="commands") +client.add_command(subparser) switch.add_command(subparser) xprt.add_command(subparser)
tools/nfs-sysfs/switch.py +4 -3
@@ -2,9 +2,10 @@ import sysfs import xprt class XprtSwitch: - def __init__(self, path): + def __init__(self, path, sep=":"): self.path = path self.id = int(str(path).rsplit("-", 1)[1]) + self.sep = sep self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] self.xprts.sort()
@@ -15,8 +16,8 @@ class XprtSwitch: return self.path < rhs.path def __str__(self): - line = "switch %s: num_xprts %s, num_active %s, queue_len %s" % \ - (self.id, self.num_xprts, self.num_active, self.queue_len) + line = "switch %s%s num_xprts %s, num_active %s, queue_len %s" % \ + (self.id, self.sep, self.num_xprts, self.num_active, self.queue_len) for x in self.xprts: line += "\n %s" % x.small_str() return line
Signature · 1 line
2.32.0
RFC PATCH 5/6 nfs-sysfs.py: Add a command for changing xprt dstaddr
In reply to [email protected]From: Anna Schumaker <[email protected]>
Using the socket module for dns resolution
--- tools/nfs-sysfs/xprt.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
tools/nfs-sysfs/xprt.py +28 -0
@@ -1,3 +1,4 @@ +import socket import sysfs class Xprt:
@@ -26,6 +27,12 @@ class Xprt: def small_str(self): return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr) + def set_dstaddr(self, newaddr): + resolved = socket.gethostbyname(newaddr) + with open(self.path / "dstaddr", 'w') as f: + f.write(resolved) + self.dstaddr = open(self.path / "dstaddr", 'r').readline().strip() + def list_xprts(args): xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ]
@@ -34,7 +41,28 @@ def list_xprts(args): if args.id == None or xprt.id == args.id[0]: print(xprt) +def get_xprt(id): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + for xprt in xprts: + if xprt.id == id: + return xprt + +def set_xprt_property(args): + xprt = get_xprt(args.id[0]) + try: + if args.dstaddr != None: + xprt.set_dstaddr(args.dstaddr[0]) + print(xprt) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") parser.set_defaults(func=list_xprts) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of a specific xprt to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_property)
Signature · 1 line
2.32.0
RFC PATCH 6/6 nfs-sysfs.py: Add a command for changing xprt-switch dstaddrs
In reply to [email protected]From: Anna Schumaker <[email protected]>
This is basically the same as for xprts, but it iterates through all xprts attached to the switch to apply the new address.
--- tools/nfs-sysfs/switch.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/nfs-sysfs/switch.py +15 -0
@@ -30,7 +30,22 @@ def list_xprt_switches(args): if args.id == None or xs.id == args.id[0]: print(xs) +def set_xprt_switch_property(args): + switch = XprtSwitch(sysfs.SUNRPC / "xprt-switches" / f"switch-{args.id[0]}") + try: + for xprt in switch.xprts: + xprt.set_dstaddr(args.dstaddr[0]) + print(switch) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt-switch", help="Commands for xprt switches") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") parser.set_defaults(func=list_xprt_switches) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt switch property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of an xprt-switch to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_switch_property)
Signature · 1 line
2.32.0
Quoted 81 lines · On 6/8/21 1:46 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
These patches implement a tool that can be used to read and write the sysfs files, with subcommands! They need Olga's most recent patches to run.
The following subcommands are implemented:
nfs-sysfs.pyrpc-client
nfs-sysfs.pyxprt
nfs-sysfs.pyxprt set
nfs-sysfs.pyxprt-switch
nfs-sysfs.pyxprt-switch setSo you can print out information about every xprt-switch with:
anna@client % ./nfs-sysfs.py xprt-switch switch 0:num_xprts1,num_active1,queue_len0
xprt 0: local,/var/run/gssproxy.sock
switch 1:num_xprts1,num_active1,queue_len0
xprt 1: local,/var/run/rpcbind.sock
switch 2:num_xprts4,num_active4,queue_len0
xprt 2: tcp, 192.168.111.188
xprt 3: tcp, 192.168.111.188
xprt 5: tcp, 192.168.111.188
xprt 6: tcp, 192.168.111.188
switch 3:num_xprts1,num_active1,queue_len0
xprt 7: tcp, 192.168.111.1
switch 4:num_xprts1,num_active1,queue_len0
xprt 4: tcp, 192.168.111.188And information about each xprt:
anna@client % ./nfs-sysfs.py xprt xprt 0: local, /var/run/gssproxy.sock, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 1: local, /var/run/rpcbind.sock, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 2: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 3: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 4: tcp, 192.168.111.188, state <BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 5: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 6: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 7: tcp, 192.168.111.1, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0You can use the
setsubcommand to change the dstaddr of individual xprts:anna@client % ./nfs-sysfs.py xprt --id 2 xprt 2: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 anna@client % sudo ./nfs-sysfs.py xprt set --id 2 --dstaddr server2.nowheycreamery.vm xprt 2: tcp, 192.168.111.186, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0Or for changing the dstaddr of all xprts attached to a switch:
anna@client % ./nfs-sysfs.py xprt-switch --id 2 switch 2: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.188 xprt 3: tcp, 192.168.111.188 xprt 5: tcp, 192.168.111.188 xprt 6: tcp, 192.168.111.188 anna@client % sudo ./nfs-sysfs.py xprt-switch set --id 2 --dstaddr server2.nowheycreamery.vm switch 2: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.186 xprt 3: tcp, 192.168.111.186 xprt 5: tcp, 192.168.111.186 xprt 6: tcp, 192.168.111.186
Quoted 7 lines
I'm sure this needs lots of polish before it's ready for inclusion, along with needing a
Makefileso it can be installed (I've just been running it out of the nfs-utils/tools/nfs-sysfs/ directory). But it's still a start, and I wanted to post it before going on New Baby Leave Part 2 (June 12 - July 11).What does everybody think?
The first thing that popped in my was is where is the man page, but this being a developers tool, maybe one is not needed?? (ala pynfs). Although if its going to be installed from nfs-utils, it would be nice to have a man page.
The second thing was I was thinking... it would be good if we could run this command on a kernel dump... to see what was going on when things crashed...
Nice work!
steved.
Quoted 23 lines
Anna
Anna Schumaker (6):
nfs-sysfs: Add annfs-sysfs.pytool
nfs-sysfs.py: Add a command for printing xprt switch informationnfs-sysfs.py: Add a command for printing individual xprtsnfs-sysfs.py: Add a command for printing rpc-client informationnfs-sysfs.py: Add a command for changing xprt dstaddrnfs-sysfs.py: Add a command for changing xprt-switch dstaddrstools/nfs-sysfs/client.py | 27 ++++++++++++++ tools/nfs-sysfs/nfs-sysfs.py | 23 ++++++++++++ tools/nfs-sysfs/switch.py | 51 +++++++++++++++++++++++++++ tools/nfs-sysfs/sysfs.py | 28 +++++++++++++++ tools/nfs-sysfs/xprt.py | 68 ++++++++++++++++++++++++++++++++++++ 5 files changed, 197 insertions(+)create mode 100644
tools/nfs-sysfs/client.py
create mode 100755tools/nfs-sysfs/nfs-sysfs.py
create mode 100644tools/nfs-sysfs/switch.py
create mode 100644tools/nfs-sysfs/sysfs.py
create mode 100644tools/nfs-sysfs/xprt.py
Hi Steve,
Quoted 91 lines · Steve Dickson
Quoted 87 lines · On 6/8/21 1:46 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
These patches implement a tool that can be used to read and write the sysfs files, with subcommands! They need Olga's most recent patches to run.
The following subcommands are implemented:
nfs-sysfs.pyrpc-client
nfs-sysfs.pyxprt
nfs-sysfs.pyxprt set
nfs-sysfs.pyxprt-switch
nfs-sysfs.pyxprt-switch setSo you can print out information about every xprt-switch with:
anna@client % ./nfs-sysfs.py xprt-switch switch 0:num_xprts1,num_active1,queue_len0
xprt 0: local,/var/run/gssproxy.sock
switch 1:num_xprts1,num_active1,queue_len0
xprt 1: local,/var/run/rpcbind.sock
switch 2:num_xprts4,num_active4,queue_len0
xprt 2: tcp, 192.168.111.188
xprt 3: tcp, 192.168.111.188
xprt 5: tcp, 192.168.111.188
xprt 6: tcp, 192.168.111.188
switch 3:num_xprts1,num_active1,queue_len0
xprt 7: tcp, 192.168.111.1
switch 4:num_xprts1,num_active1,queue_len0
xprt 4: tcp, 192.168.111.188And information about each xprt:
anna@client % ./nfs-sysfs.py xprt xprt 0: local, /var/run/gssproxy.sock, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 1: local, /var/run/rpcbind.sock, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 2: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 3: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 4: tcp, 192.168.111.188, state <BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 5: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 6: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 xprt 7: tcp, 192.168.111.1, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0You can use the
setsubcommand to change the dstaddr of individual xprts:anna@client % ./nfs-sysfs.py xprt --id 2 xprt 2: tcp, 192.168.111.188, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0 anna@client % sudo ./nfs-sysfs.py xprt set --id 2 --dstaddr server2.nowheycreamery.vm xprt 2: tcp, 192.168.111.186, state <CONNECTED,BOUND>, num_reqs 2 cur_cong 0, cong_win 256, min_num_slots 2, max_num_slots 65536 binding_q_len 0, sending_q_len 0, pending_q_len 0, backlog_q_len 0Or for changing the dstaddr of all xprts attached to a switch:
anna@client % ./nfs-sysfs.py xprt-switch --id 2 switch 2: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.188 xprt 3: tcp, 192.168.111.188 xprt 5: tcp, 192.168.111.188 xprt 6: tcp, 192.168.111.188 anna@client % sudo ./nfs-sysfs.py xprt-switch set --id 2 --dstaddr server2.nowheycreamery.vm switch 2: num_xprts 4, num_active 4, queue_len 0 xprt 2: tcp, 192.168.111.186 xprt 3: tcp, 192.168.111.186 xprt 5: tcp, 192.168.111.186 xprt 6: tcp, 192.168.111.186I'm sure this needs lots of polish before it's ready for inclusion, along with needing a
Makefileso it can be installed (I've just been running it out of the nfs-utils/tools/nfs-sysfs/ directory). But it's still a start, and I wanted to post it before going on New Baby Leave Part 2 (June 12 - July 11).
Quoted 5 lines
Quoted 1 line
What does everybody think?
The first thing that popped in my was is where is the man page, but this being a developers tool, maybe one is not needed?? (ala pynfs). Although if its going to be installed from nfs-utils, it would be nice to have a man page.
Yeah, I was expecting to write a man page at some point before a non-RFC submission, since commands and options might change after hearing feedback from everyone.
Quoted 4 lines
The second thing was I was thinking... it would be good if we could run this command on a kernel dump... to see what was going on when things crashed...
That would be useful, but I'm having trouble conceptualizing how that would work since the contents of each file are generated by the kernel when the files are read. If there is a way to do it, then the tool could definitely be expanded to add it in!
Quoted 2 lines
Nice work!
Thanks!
Anna
Quoted 27 lines
steved.
Quoted 23 lines
Anna
Anna Schumaker (6):
nfs-sysfs: Add annfs-sysfs.pytool
nfs-sysfs.py: Add a command for printing xprt switch informationnfs-sysfs.py: Add a command for printing individual xprtsnfs-sysfs.py: Add a command for printing rpc-client informationnfs-sysfs.py: Add a command for changing xprt dstaddrnfs-sysfs.py: Add a command for changing xprt-switch dstaddrstools/nfs-sysfs/client.py | 27 ++++++++++++++ tools/nfs-sysfs/nfs-sysfs.py | 23 ++++++++++++ tools/nfs-sysfs/switch.py | 51 +++++++++++++++++++++++++++ tools/nfs-sysfs/sysfs.py | 28 +++++++++++++++ tools/nfs-sysfs/xprt.py | 68 ++++++++++++++++++++++++++++++++++++ 5 files changed, 197 insertions(+)create mode 100644
tools/nfs-sysfs/client.py
create mode 100755tools/nfs-sysfs/nfs-sysfs.py
create mode 100644tools/nfs-sysfs/switch.py
create mode 100644tools/nfs-sysfs/sysfs.py
create mode 100644tools/nfs-sysfs/xprt.py