* [PATCH v3 1/4] rpcctl: Rename {read,write}_addr_file()
2025-04-29 18:33 [PATCH v3 0/4] rpcctl: Various Improvements Anna Schumaker
@ 2025-04-29 18:33 ` Anna Schumaker
2025-04-29 18:33 ` [PATCH v3 2/4] rpcctl: Add support for the xprtsec sysfs attribute Anna Schumaker
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anna Schumaker @ 2025-04-29 18:33 UTC (permalink / raw)
To: linux-nfs, steved; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
There is nothing address specific about these functions, so name them
something more generic so they can be reused.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
tools/rpcctl/rpcctl.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index 0221fbb68be1..654b2f60a894 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -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."""
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 2/4] rpcctl: Add support for the xprtsec sysfs attribute
2025-04-29 18:33 [PATCH v3 0/4] rpcctl: Various Improvements Anna Schumaker
2025-04-29 18:33 ` [PATCH v3 1/4] rpcctl: Rename {read,write}_addr_file() Anna Schumaker
@ 2025-04-29 18:33 ` Anna Schumaker
2025-04-29 18:33 ` [PATCH v3 3/4] rpcctl: Display new rpc_clnt sysfs attributes Anna Schumaker
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anna Schumaker @ 2025-04-29 18:33 UTC (permalink / raw)
To: linux-nfs, steved; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
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.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
tools/rpcctl/rpcctl.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index 654b2f60a894..ce22e424b804 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -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']}, " \
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 3/4] rpcctl: Display new rpc_clnt sysfs attributes
2025-04-29 18:33 [PATCH v3 0/4] rpcctl: Various Improvements Anna Schumaker
2025-04-29 18:33 ` [PATCH v3 1/4] rpcctl: Rename {read,write}_addr_file() Anna Schumaker
2025-04-29 18:33 ` [PATCH v3 2/4] rpcctl: Add support for the xprtsec sysfs attribute Anna Schumaker
@ 2025-04-29 18:33 ` Anna Schumaker
2025-04-29 18:33 ` [PATCH v3 4/4] rpcctl: Add support for `rpcctl switch add-xprt` Anna Schumaker
2025-05-07 14:04 ` [PATCH v3 0/4] rpcctl: Various Improvements Steve Dickson
4 siblings, 0 replies; 6+ messages in thread
From: Anna Schumaker @ 2025-04-29 18:33 UTC (permalink / raw)
To: linux-nfs, steved; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
This includes the rpc program name, rpc version, and maximum number of
connections.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
tools/rpcctl/rpcctl.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index ce22e424b804..130f245a64e8 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -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."""
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 4/4] rpcctl: Add support for `rpcctl switch add-xprt`
2025-04-29 18:33 [PATCH v3 0/4] rpcctl: Various Improvements Anna Schumaker
` (2 preceding siblings ...)
2025-04-29 18:33 ` [PATCH v3 3/4] rpcctl: Display new rpc_clnt sysfs attributes Anna Schumaker
@ 2025-04-29 18:33 ` Anna Schumaker
2025-05-07 14:04 ` [PATCH v3 0/4] rpcctl: Various Improvements Steve Dickson
4 siblings, 0 replies; 6+ messages in thread
From: Anna Schumaker @ 2025-04-29 18:33 UTC (permalink / raw)
To: linux-nfs, steved; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
This is used to add an xprt to the switch at runtime.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
tools/rpcctl/rpcctl.man | 4 ++++
tools/rpcctl/rpcctl.py | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/tools/rpcctl/rpcctl.man b/tools/rpcctl/rpcctl.man
index b87ba0df41c0..2ee168c8f3c5 100644
--- a/tools/rpcctl/rpcctl.man
+++ b/tools/rpcctl/rpcctl.man
@@ -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).
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index 130f245a64e8..29ae7d26f50e 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -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):
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v3 0/4] rpcctl: Various Improvements
2025-04-29 18:33 [PATCH v3 0/4] rpcctl: Various Improvements Anna Schumaker
` (3 preceding siblings ...)
2025-04-29 18:33 ` [PATCH v3 4/4] rpcctl: Add support for `rpcctl switch add-xprt` Anna Schumaker
@ 2025-05-07 14:04 ` Steve Dickson
4 siblings, 0 replies; 6+ messages in thread
From: Steve Dickson @ 2025-05-07 14:04 UTC (permalink / raw)
To: Anna Schumaker, linux-nfs
On 4/29/25 2:33 PM, Anna Schumaker wrote:
> From: Anna Schumaker <anna.schumaker@oracle.com>
>
> These patches depend on kernel patches that have been included in
> v6.15. They update the rpcctl tool to use the new sunrpc sysfs features,
> in a backwards compatible way that won't crash on older kernels.
>
> v3:
> * Rebase on top of the 2.8.3 release.
All patches have been committed... (tag: nfs-utils-2-8-4-rc1)
steved.
>
> 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(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread