2021-06-08 17:49:51

by Anna Schumaker

[permalink] [raw]
Subject: [RFC PATCH 0/6] 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

--
2.32.0


2021-06-08 17:49:52

by Anna Schumaker

[permalink] [raw]
Subject: [RFC PATCH 2/6] nfs-sysfs.py: Add a command for printing xprt switch information

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

Signed-off-by: Anna Schumaker <[email protected]>
---
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

diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py
index 8ff59ea9e81b..90efcbed7ac8 100755
--- a/tools/nfs-sysfs/nfs-sysfs.py
+++ b/tools/nfs-sysfs/nfs-sysfs.py
@@ -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)
diff --git a/tools/nfs-sysfs/switch.py b/tools/nfs-sysfs/switch.py
new file mode 100644
index 000000000000..afb6963a0a1f
--- /dev/null
+++ b/tools/nfs-sysfs/switch.py
@@ -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)
diff --git a/tools/nfs-sysfs/sysfs.py b/tools/nfs-sysfs/sysfs.py
index 0b358f57bb28..32dcf74438de 100644
--- a/tools/nfs-sysfs/sysfs.py
+++ b/tools/nfs-sysfs/sysfs.py
@@ -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
diff --git a/tools/nfs-sysfs/xprt.py b/tools/nfs-sysfs/xprt.py
new file mode 100644
index 000000000000..d37537771c1d
--- /dev/null
+++ b/tools/nfs-sysfs/xprt.py
@@ -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)
--
2.32.0

2021-06-08 17:50:09

by Anna Schumaker

[permalink] [raw]
Subject: [RFC PATCH 4/6] nfs-sysfs.py: Add a command for printing rpc-client information

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.

Signed-off-by: Anna Schumaker <[email protected]>
---
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

diff --git a/tools/nfs-sysfs/client.py b/tools/nfs-sysfs/client.py
new file mode 100644
index 000000000000..5192cc226aed
--- /dev/null
+++ b/tools/nfs-sysfs/client.py
@@ -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)
diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py
index dfad6ac08fa0..e2172cdfa4c1 100755
--- a/tools/nfs-sysfs/nfs-sysfs.py
+++ b/tools/nfs-sysfs/nfs-sysfs.py
@@ -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)

diff --git a/tools/nfs-sysfs/switch.py b/tools/nfs-sysfs/switch.py
index afb6963a0a1f..5384f970235c 100644
--- a/tools/nfs-sysfs/switch.py
+++ b/tools/nfs-sysfs/switch.py
@@ -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
--
2.32.0

2021-06-08 17:50:49

by Anna Schumaker

[permalink] [raw]
Subject: [RFC PATCH 5/6] nfs-sysfs.py: Add a command for changing xprt dstaddr

From: Anna Schumaker <[email protected]>

Using the socket module for dns resolution

Signed-off-by: Anna Schumaker <[email protected]>
---
tools/nfs-sysfs/xprt.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/tools/nfs-sysfs/xprt.py b/tools/nfs-sysfs/xprt.py
index b95fb2d48829..167e5fa69df7 100644
--- a/tools/nfs-sysfs/xprt.py
+++ b/tools/nfs-sysfs/xprt.py
@@ -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)
--
2.32.0

2021-06-08 17:50:57

by Anna Schumaker

[permalink] [raw]
Subject: [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.

Signed-off-by: Anna Schumaker <[email protected]>
---
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

diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py
new file mode 100755
index 000000000000..8ff59ea9e81b
--- /dev/null
+++ b/tools/nfs-sysfs/nfs-sysfs.py
@@ -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)
diff --git a/tools/nfs-sysfs/sysfs.py b/tools/nfs-sysfs/sysfs.py
new file mode 100644
index 000000000000..0b358f57bb28
--- /dev/null
+++ b/tools/nfs-sysfs/sysfs.py
@@ -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)
--
2.32.0

2021-06-14 13:17:51

by Steve Dickson

[permalink] [raw]
Subject: Re: [RFC PATCH 0/6] Add a tool for using the new sysfs files



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.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?
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.

> 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
>

2021-06-14 13:44:25

by Anna Schumaker

[permalink] [raw]
Subject: Re: [RFC PATCH 0/6] Add a tool for using the new sysfs files

Hi Steve,

On Mon, Jun 14, 2021 at 9:16 AM Steve Dickson <[email protected]> wrote:
>
>
>
> 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.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?
> 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.
>
> 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!

>
> Nice work!

Thanks!
Anna
>
> steved.
>
> > 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
> >
>