rpcctl: Various Improvements
Subsystems (2)
Anna Schumaker
maintainerv2 cover rpcctl: Various Improvements
From: Anna Schumaker <[email protected]>
These patches depend on the corresponding kernel patches posted at the same time. They update the rpcctl tool to use the new sunrpc sysfs features, in a backwards compatible way that will run on older kernels.
v2:
* Update rpcctl client output to include rpc program and version
Thanks,
Anna
Anna Schumaker (4):
rpcctl: Rename {read,write}_addr_file()
rpcctl: Add support for the xprtsec sysfs attribute
rpcctl: Display new rpc_clnt sysfs attributes
rpcctl: Add support for rpcctl switch add-xprt
tools/rpcctl/rpcctl.man | 4 ++++ tools/rpcctl/rpcctl.py | 50 ++++++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 16 deletions(-)
Signature · 1 line
2.48.1
Anna Schumaker
maintainerPATCH v2 1/4 rpcctl: Rename {read,write}_addr_file()
From: Anna Schumaker <[email protected]>
There is nothing address specific about these functions, so name them something more generic so they can be reused.
--- tools/rpcctl/rpcctl.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/rpcctl/rpcctl.py +9 -9
@@ -20,8 +20,8 @@ if not sunrpc.is_dir(): sys.exit(1) -def read_addr_file(path): - """Read an xprt address file.""" +def read_sysfs_file(path): + """Read a sysfs file.""" try: with open(path, 'r') as f: return f.readline().strip()
@@ -29,11 +29,11 @@ def read_addr_file(path): return "(enoent)" -def write_addr_file(path, newaddr): - """Write a new address to an xprt address file.""" +def write_sysfs_file(path, input): + """Write 'input' to a sysfs file.""" with open(path, 'w') as f: - f.write(newaddr) - return read_addr_file(path) + f.write(input) + return read_sysfs_file(path) def read_info_file(path):
@@ -56,8 +56,8 @@ class Xprt: self.name = path.stem.rsplit("-", 1)[0] self.type = path.stem.split("-")[2] self.info = read_info_file(path / "xprt_info") - self.dstaddr = read_addr_file(path / "dstaddr") - self.srcaddr = read_addr_file(path / "srcaddr") + self.dstaddr = read_sysfs_file(path / "dstaddr") + self.srcaddr = read_sysfs_file(path / "srcaddr") self.read_state() def __lt__(self, rhs):
@@ -106,7 +106,7 @@ class Xprt: def set_dstaddr(self, newaddr): """Change the dstaddr of an xprt.""" - self.dstaddr = write_addr_file(self.path / "dstaddr", newaddr) + self.dstaddr = write_sysfs_file(self.path / "dstaddr", newaddr) def set_state(self, state): """Change the state of an xprt."""
Signature · 1 line
2.48.1
Anna Schumaker
maintainerPATCH v2 2/4 rpcctl: Add support for the xprtsec sysfs attribute
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
This was recently added to the Linux kernel, so running rpcctl on kernels that don't have this attribute will print out "unknown" in its place instead.
--- tools/rpcctl/rpcctl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/rpcctl/rpcctl.py +5 -3
@@ -20,13 +20,13 @@ if not sunrpc.is_dir(): sys.exit(1) -def read_sysfs_file(path): +def read_sysfs_file(path, *, missing="enoent"): """Read a sysfs file.""" try: with open(path, 'r') as f: return f.readline().strip() except FileNotFoundError: - return "(enoent)" + return f"({missing})" def write_sysfs_file(path, input):
@@ -58,6 +58,7 @@ class Xprt: self.info = read_info_file(path / "xprt_info") self.dstaddr = read_sysfs_file(path / "dstaddr") self.srcaddr = read_sysfs_file(path / "srcaddr") + self.xprtsec = read_sysfs_file(path / "xprtsec", missing="unknown") self.read_state() def __lt__(self, rhs):
@@ -67,7 +68,8 @@ class Xprt: def _xprt(self): main = ", main" if self.info.get("main_xprt") else "" return f"{self.name}: {self.type}, {self.dstaddr}, " \ - f"port {self.info['dst_port']}, state <{self.state}>{main}" + f"port {self.info['dst_port']}, sec {self.xprtsec}, " \ + f"state <{self.state}>{main}" def _src_reqs(self): return f" Source: {self.srcaddr}, port {self.info['src_port']}, " \
Signature · 1 line
2.48.1
Anna Schumaker
maintainerPATCH v2 3/4 rpcctl: Display new rpc_clnt sysfs attributes
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
This includes the rpc program name, rpc version, and maximum number of connections.
--- tools/rpcctl/rpcctl.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
tools/rpcctl/rpcctl.py +10 -5
@@ -185,14 +185,13 @@ class Xprt: class XprtSwitch: """Represents a group of xprt connections.""" - def __init__(self, path, sep=":"): + def __init__(self, path): """Read in xprt switch information from sysfs.""" self.path = path self.name = path.stem self.info = read_info_file(path / "xprt_switch_info") self.xprts = sorted([Xprt(p) for p in self.path.iterdir() if p.is_dir()]) - self.sep = sep def __lt__(self, rhs): """Compare the name of two xprt switch instances."""
@@ -200,7 +199,7 @@ class XprtSwitch: def __str__(self): """Return a string representation of an xprt switch.""" - switch = f"{self.name}{self.sep} " \ + switch = f"{self.name}: " \ f"xprts {self.info['num_xprts']}, " \ f"active {self.info['num_active']}, " \ f"queue {self.info['queue_len']}"
@@ -258,7 +257,11 @@ class RpcClient: """Read in rpc client information from sysfs.""" self.path = path self.name = path.stem - self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") + self.switch = XprtSwitch(path / (path / "switch").readlink()) + self.program = read_sysfs_file(path / "program", missing="unknown") + self.version = read_sysfs_file(path / "rpc_version", missing="unknown") + self.max_connect = read_sysfs_file(path / "max_connect", + missing="unknown") def __lt__(self, rhs): """Compare the name of two rpc client instances."""
@@ -266,7 +269,9 @@ class RpcClient: def __str__(self): """Return a string representation of an rpc client.""" - return f"{self.name}: {self.switch}" + return f"{self.name}: {self.program}, rpc version {self.version}, " \ + f"max_connect {self.max_connect}" \ + f"\n {' ' * len(self.name)}{self.switch}" def add_command(subparser): """Add parser options for the `rpcctl client` command."""
Signature · 1 line
2.48.1
Anna Schumaker
maintainerPATCH v2 4/4 rpcctl: Add support for `rpcctl switch add-xprt`
In reply to Anna SchumakerFrom: Anna Schumaker <[email protected]>
This is used to add an xprt to the switch at runtime.
--- tools/rpcctl/rpcctl.man | 4 ++++ tools/rpcctl/rpcctl.py | 11 +++++++++++ 2 files changed, 15 insertions(+)
tools/rpcctl/rpcctl.man +4 -0
@@ -12,6 +12,7 @@ rpcctl \- Displays SunRPC connection information .BR "rpcctl client show " "\fR[ \fB\-h \f| \fB\-\-help \fR] [ \fIXPRT \fR]" .P .BR "rpcctl switch" " \fR[ \fB\-h \fR| \fB\-\-help \fR] { \fBset \fR| \fBshow \fR}" +.BR "rpcctl switch add-xprt" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .BR "rpcctl switch set" " \fR[ \fB\-h \fR| \fB\-\-help \fR] \fISWITCH \fBdstaddr \fINEWADDR" .BR "rpcctl switch show" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .P
@@ -29,6 +30,9 @@ Show detailed information about the RPC clients on this system. If \fICLIENT \fRwas provided, then only show information about a single RPC client. .P .SS rpcctl switch \fR- \fBCommands operating on groups of transports +.IP "\fBadd-xprt \fISWITCH" +Add an aditional transport to the \fISWITCH\fR. +Note that the new transport will take its values from the "main" transport. .IP "\fBset \fISWITCH \fBdstaddr \fINEWADDR" Change the destination address of all transports in the \fISWITCH \fRto \fINEWADDR\fR. \fINEWADDR \fRcan be an IP address, DNS name, or anything else resolvable by \fBgethostbyname\fR(3).
tools/rpcctl/rpcctl.py +11 -0
@@ -213,6 +213,12 @@ class XprtSwitch: parser.set_defaults(func=XprtSwitch.show, switch=None) subparser = parser.add_subparsers() + add = subparser.add_parser("add-xprt", + help="Add an xprt to the switch") + add.add_argument("switch", metavar="SWITCH", nargs=1, + help="Name of a specific xprt switch to modify") + add.set_defaults(func=XprtSwitch.add_xprt) + show = subparser.add_parser("show", help="Show xprt switches") show.add_argument("switch", metavar="SWITCH", nargs='?', help="Name of a specific switch to show")
@@ -236,6 +242,11 @@ class XprtSwitch: return [XprtSwitch(xprt_switches / name)] return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())] + def add_xprt(args): + """Handle the `rpcctl switch add-xprt` command.""" + for switch in XprtSwitch.get_by_name(args.switch[0]): + write_sysfs_file(switch.path / "add_xprt", "1") + def show(args): """Handle the `rpcctl switch show` command.""" for switch in XprtSwitch.get_by_name(args.switch):
Signature · 1 line
2.48.1
Re: [PATCH nfs-utils v2 4/4] rpcctl: Add support for `rpcctl switch add-xprt`
Quoted 51 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
This is used to add an xprt to the switch at runtime.
Signed-off-by Anna Schumaker <[email protected]>--- tools/rpcctl/rpcctl.man | 4 ++++ tools/rpcctl/rpcctl.py | 11 +++++++++++ 2 files changed, 15 insertions(+)tools/rpcctl/rpcctl.man +4
-0@@ -12,6 +12,7 @@ rpcctl \- Displays SunRPC connection information .BR "rpcctl client show " "\fR[ \fB\-h \f| \fB\-\-help \fR] [ \fIXPRT \fR]" .P .BR "rpcctl switch" " \fR[ \fB\-h \fR| \fB\-\-help \fR] { \fBset \fR| \fBshow \fR}" +.BR "rpcctl switch add-xprt" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .BR "rpcctl switch set" " \fR[ \fB\-h \fR| \fB\-\-help \fR] \fISWITCH \fBdstaddr \fINEWADDR" .BR "rpcctl switch show" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .P@@ -29,6 +30,9 @@ Show detailed information about the RPC clients on this system. If \fICLIENT \fRwas provided, then only show information about a single RPC client. .P .SS rpcctl switch \fR- \fBCommands operating on groups of transports +.IP "\fBadd-xprt \fISWITCH" +Add an aditional transport to the \fISWITCH\fR. +Note that the new transport will take its values from the "main" transport. .IP "\fBset \fISWITCH \fBdstaddr \fINEWADDR" Change the destination address of all transports in the \fISWITCH \fRto \fINEWADDR\fR. \fINEWADDR \fRcan be an IP address, DNS name, or anything else resolvable by \fBgethostbyname\fR(3).tools/rpcctl/rpcctl.py +6
-0@@ -213,6 +213,12 @@ class XprtSwitch: parser.set_defaults(func=XprtSwitch.show, switch=None) subparser = parser.add_subparsers() + add = subparser.add_parser("add-xprt", + help="Add an xprt to the switch") + add.add_argument("switch", metavar="SWITCH", nargs=1, + help="Name of a specific xprt switch to modify") + add.set_defaults(func=XprtSwitch.add_xprt) + show = subparser.add_parser("show", help="Show xprt switches") show.add_argument("switch", metavar="SWITCH", nargs='?', help="Name of a specific switch to show")@@ -236,6 +242,11 @@ class XprtSwitch: return [XprtSwitch(xprt_switches / name)]
tools/rpcctl/rpcctl.py class XprtSwitch: · line 252
Quoted 10 lines
tools/rpcctl/rpcctl.py +5
-0return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())] + def add_xprt(args): + """Handle the `rpcctl switch add-xprt` command.""" + for switch in XprtSwitch.get_by_name(args.switch[0]): + write_sysfs_file(switch.path / "add_xprt", "1") + def show(args): """Handle the `rpcctl switch show` command.""" for switch in XprtSwitch.get_by_name(args.switch):
Question... is this support needed by a kernel patch? if so is it in a public kernel?
steved.
Re: [PATCH nfs-utils v2 4/4] rpcctl: Add support for `rpcctl switch add-xprt`
Hi Steve,
Quoted 56 lines · Steve Dickson
Quoted 53 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
This is used to add an xprt to the switch at runtime.
Signed-off-by Anna Schumaker <[email protected]>---
tools/rpcctl/rpcctl.man| 4 ++++
tools/rpcctl/rpcctl.py | 11 +++++++++++2 files changed, 15 insertions(+)tools/rpcctl/rpcctl.man +0
-0@@ -12,6 +12,7 @@ rpcctl \- Displays SunRPC connection information.BR "rpcctl client show " "\fR[ \fB\-h \f| \fB\-\-help \fR] [ \fIXPRT \fR]" .P
.BR "rpcctl switch" " \fR[ \fB\-h \fR| \fB\-\-help \fR] { \fBset \fR| \fBshow \fR}" +.BR "rpcctl switch add-xprt" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .BR "rpcctl switch set" " \fR[ \fB\-h \fR| \fB\-\-help \fR] \fISWITCH \fBdstaddr \fINEWADDR" .BR "rpcctl switch show" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .Ptools/rpcctl/rpcctl.man +0
-0@@ -29,6 +30,9 @@ Show detailed information about the RPC clients on this system.If \fICLIENT \fRwas provided, then only show information about a single RPC client. .P
.SS rpcctl switch \fR- \fBCommands operating on groups of transports +.IP "\fBadd-xprt \fISWITCH"tools/rpcctl/rpcctl.man +2
-0+Add an aditional transport to the \fISWITCH\fR. +Note that the new transport will take its values from the "main" transport..IP "\fBset \fISWITCH \fBdstaddr \fINEWADDR"
Change the destination address of all transports in the \fISWITCH \fRto \fINEWADDR\fR. \fINEWADDR \fRcan be an IP address, DNS name, or anything else resolvable by \fBgethostbyname\fR(3).tools/rpcctl/rpcctl.py +5
-0@@ -213,6 +213,12 @@ class XprtSwitch: parser.set_defaults(func=XprtSwitch.show, switch=None) subparser = parser.add_subparsers() + add = subparser.add_parser("add-xprt", + help="Add an xprt to the switch") + add.add_argument("switch", metavar="SWITCH", nargs=1, + help="Name of a specific xprt switch to modify") + add.set_defaults(func=XprtSwitch.add_xprt) + show = subparser.add_parser("show", help="Show xprt switches") show.add_argument("switch", metavar="SWITCH", nargs='?', help="Name of a specific switch to show")@@ -236,6 +242,11 @@ class XprtSwitch:return [
XprtSwitch(xprt_switches / name)] return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())] + defadd_xprt(args):
+ """Handle therpcctl switch add-xprtcommand."""
Quoted 8 lines
Quoted 6 lines
+ for switch in
XprtSwitch.get_by_name(args.switch[0]):
+write_sysfs_file(switch.path / "add_xprt", "1")+
def show(args):
"""Handle therpcctl switch showcommand.""" for switch inXprtSwitch.get_by_name(args.switch):Question... is this support needed by a kernel patch? if so is it in a public kernel?
I'm about to post v3 of the patchset adding the kernel side of this. I'm hopeful it'll go in with the next merge window.
Anna
Quoted 3 lines
steved.
Re: [PATCH nfs-utils v2 4/4] rpcctl: Add support for `rpcctl switch add-xprt`
Hey Anna!
Quoted 68 lines · Anna Schumaker
Hi Steve,
Quoted 56 lines · Steve Dickson
Quoted 53 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
This is used to add an xprt to the switch at runtime.
Signed-off-by Anna Schumaker <[email protected]>--- tools/rpcctl/rpcctl.man | 4 ++++ tools/rpcctl/rpcctl.py | 11 +++++++++++ 2 files changed, 15 insertions(+)tools/rpcctl/rpcctl.man +4
-0@@ -12,6 +12,7 @@ rpcctl \- Displays SunRPC connection information .BR "rpcctl client show " "\fR[ \fB\-h \f| \fB\-\-help \fR] [ \fIXPRT \fR]" .P .BR "rpcctl switch" " \fR[ \fB\-h \fR| \fB\-\-help \fR] { \fBset \fR| \fBshow \fR}" +.BR "rpcctl switch add-xprt" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .BR "rpcctl switch set" " \fR[ \fB\-h \fR| \fB\-\-help \fR] \fISWITCH \fBdstaddr \fINEWADDR" .BR "rpcctl switch show" " \fR[ \fB\-h \fR| \fB\-\-help \fR] [ \fISWITCH \fR]" .P@@ -29,6 +30,9 @@ Show detailed information about the RPC clients on this system. If \fICLIENT \fRwas provided, then only show information about a single RPC client. .P .SS rpcctl switch \fR- \fBCommands operating on groups of transports +.IP "\fBadd-xprt \fISWITCH" +Add an aditional transport to the \fISWITCH\fR. +Note that the new transport will take its values from the "main" transport. .IP "\fBset \fISWITCH \fBdstaddr \fINEWADDR" Change the destination address of all transports in the \fISWITCH \fRto \fINEWADDR\fR. \fINEWADDR \fRcan be an IP address, DNS name, or anything else resolvable by \fBgethostbyname\fR(3).tools/rpcctl/rpcctl.py +6
-0@@ -213,6 +213,12 @@ class XprtSwitch: parser.set_defaults(func=XprtSwitch.show, switch=None) subparser = parser.add_subparsers() + add = subparser.add_parser("add-xprt", + help="Add an xprt to the switch") + add.add_argument("switch", metavar="SWITCH", nargs=1, + help="Name of a specific xprt switch to modify") + add.set_defaults(func=XprtSwitch.add_xprt) + show = subparser.add_parser("show", help="Show xprt switches") show.add_argument("switch", metavar="SWITCH", nargs='?', help="Name of a specific switch to show")@@ -236,6 +242,11 @@ class XprtSwitch: return [XprtSwitch(xprt_switches / name)] return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())] + def add_xprt(args): + """Handle the `rpcctl switch add-xprt` command."""Quoted 8 lines
tools/rpcctl/rpcctl.py class XprtSwitch: · line 252
Quoted 6 lines
tools/rpcctl/rpcctl.py +3
-0+ for switch in XprtSwitch.get_by_name(args.switch[0]): + write_sysfs_file(switch.path / "add_xprt", "1") + def show(args): """Handle the `rpcctl switch show` command.""" for switch in XprtSwitch.get_by_name(args.switch):Question... is this support needed by a kernel patch? if so is it in a public kernel?
Quoted 2 lines
I'm about to post v3 of the patchset adding the kernel side of this. I'm hopeful it'll go in with the next merge window.
So I'm assuming 'rpcctl switch add-xprt' will fail without the kernel patch.
If that is the case... would it make sense to commit the first 3 patches and deal with this after kernel patch goes in?
steved.