From patchwork Wed Jan 8 21:37:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931560 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 471AF203717 for ; Wed, 8 Jan 2025 21:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372248; cv=none; b=K7lGTiikCWoNymtH8++cb03YEgKPIrrgfUoFcd2bNgZxSG5850L2DCJnGDW79rSFsjkD6Ae+1X7rXAAgQxpB3eVcx+3X7PO8gpXylIJAGcTm9Wvj7uzHIE786W2iMijebjNr6DRMxBt7zOogTPKDsE9+E5bBTQLtQrpSvqOI+pY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372248; c=relaxed/simple; bh=4IRKmf51rVyNnjcS4uXxoelyQBLbnEi8fZ/MgIU4JBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XJGUZssObS/heF7hgtDtw6ihtxjTYatPyjJFjcrIYzAJrfRZGnzczERPF0nT+69L4GkILIZFJyqKE16scIP2SBo5Ch41jICQAyldJfWzB0MU64P15BXxdMp4doDrDGEM57q5GNvLN3APP5W27CGCEEV23g9PmmLYbv7Xp5S5cFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C22nJov7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C22nJov7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9414C4CEE1; Wed, 8 Jan 2025 21:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372248; bh=4IRKmf51rVyNnjcS4uXxoelyQBLbnEi8fZ/MgIU4JBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C22nJov7zuhLE0UKlIf4Fv1XiefvnqX518kmEv3ykhhiGWVpc8FL9SS/IAWRAKxOU P5OKpYdQslZcy1gkuLcsBHxURAwSUjIPewS3Gn5Jm/x7fzquZrXLPWaWCMG0aC3Xq0 LCeYf/344GF+ilOk83vuY1Sd67D1xtj3yXF2Ag1VNtvNBEoB84LBlgT+XFgqwPB76J 6uaeLhkNU54vTzEyBdooh5CqhXMfcJ9525oHORZGRNcjCAwxEW3irPQyIbi8miZWzK fOOLKkLNRbynkoED+7E4/6DzqMJrzwdH4YxsKuTo7pp9AUqjECuVAuJNXQERagbXhK Hk+47Q/bmb8hA== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 01/10] rpcctl: Fix flake8 whitespace errors Date: Wed, 8 Jan 2025 16:37:17 -0500 Message-ID: <20250108213726.260664-2-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index d2110ad6de93..92a851c2278b 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -8,7 +8,7 @@ import socket import sys with open("/proc/mounts", 'r') as f: - mount = [ line.split()[1] for line in f if "sysfs" in line ] + mount = [line.split()[1] for line in f if "sysfs" in line] if len(mount) == 0: print("ERROR: sysfs is not mounted") sys.exit(1) @@ -18,6 +18,7 @@ if not sunrpc.is_dir(): print("ERROR: sysfs does not have sunrpc directory") sys.exit(1) + def read_addr_file(path): try: with open(path, 'r') as f: @@ -25,17 +26,19 @@ def read_addr_file(path): except: return "(enoent)" + def write_addr_file(path, newaddr): with open(path, 'w') as f: f.write(newaddr) return read_addr_file(path) + def read_info_file(path): res = collections.defaultdict(int) try: with open(path) as info: - lines = [ l.split("=", 1) for l in info if "=" in l ] - res.update({ key:int(val.strip()) for (key, val) in lines }) + lines = [l.split("=", 1) for l in info if "=" in l] + res.update({key: int(val.strip()) for (key, val) in lines}) finally: return res @@ -75,7 +78,7 @@ class Xprt: if not self.path.exists(): return f"{self.name}: has been removed" return "\n".join([self._xprt(), self._src_reqs(), - self._cong_slots(), self._queues() ]) + self._cong_slots(), self._queues()]) def read_state(self): if self.path.exists(): @@ -132,7 +135,7 @@ class Xprt: def get_by_name(name): glob = f"**/{name}-*" if name else "**/xprt-*" - res = [ Xprt(x) for x in (sunrpc / "xprt-switches").glob(glob) ] + res = [Xprt(x) for x in (sunrpc / "xprt-switches").glob(glob)] if name and len(res) == 0: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), f"{sunrpc / 'xprt-switches' / glob}") @@ -158,19 +161,19 @@ class XprtSwitch: 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.xprts = sorted([Xprt(p) for p in self.path.iterdir() if p.is_dir()]) self.sep = sep def __lt__(self, rhs): return self.name < rhs.name def __str__(self): - switch = f"{self.name}{self.sep} " \ - f"xprts {self.info['num_xprts']}, " \ - f"active {self.info['num_active']}, " \ - f"queue {self.info['queue_len']}" - xprts = [ f" {x.small_str()}" for x in self.xprts ] - return "\n".join([ switch ] + xprts) + switch = f"{self.name}{self.sep} " \ + f"xprts {self.info['num_xprts']}, " \ + f"active {self.info['num_active']}, " \ + f"queue {self.info['queue_len']}" + xprts = [f" {x.small_str()}" for x in self.xprts] + return "\n".join([switch] + xprts) def add_command(subparser): parser = subparser.add_parser("switch", help="Commands for xprt switches") @@ -194,8 +197,8 @@ class XprtSwitch: def get_by_name(name): xprt_switches = sunrpc / "xprt-switches" if name: - return [ XprtSwitch(xprt_switches / name) ] - return [ XprtSwitch(f) for f in sorted(xprt_switches.iterdir()) ] + return [XprtSwitch(xprt_switches / name)] + return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())] def show(args): for switch in XprtSwitch.get_by_name(args.switch): @@ -234,8 +237,8 @@ class RpcClient: def get_by_name(name): rpc_clients = sunrpc / "rpc-clients" if name: - return [ RpcClient(rpc_clients / name) ] - return [ RpcClient(f) for f in sorted(rpc_clients.iterdir()) ] + return [RpcClient(rpc_clients / name)] + return [RpcClient(f) for f in sorted(rpc_clients.iterdir())] def show(args): for client in RpcClient.get_by_name(args.client): @@ -244,9 +247,12 @@ class RpcClient: parser = argparse.ArgumentParser() + def show_small_help(args): parser.print_usage() print("sunrpc dir:", sunrpc) + + parser.set_defaults(func=show_small_help) subparser = parser.add_subparsers(title="commands") From patchwork Wed Jan 8 21:37:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931561 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3272A202C58 for ; Wed, 8 Jan 2025 21:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372249; cv=none; b=UpSBhMz5Vk45xQCrayPVU0I/POLksvgNPNtnrpEk1koeKft9rsswy+uX9QmNA2D3IfO/HbtFuwj92qwlzcsY4j2tZaOfySK1qfXDSShXcln94rvaAj1aDja3dhr34bgbhKPewln8Xh/Pu5N8uhwuz26qKZxbOmwVH4xgIsGkvr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372249; c=relaxed/simple; bh=0V4sxlCPz+itlsPtq1bPzgTX0ZYKT5JKKOgt2zH9uus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UfmSSr0+yQ5f/gebWP+LPFQYI0W7ei3fWb51Z+7l0oPhBKFy+jMe+ZVfYDTqVzU2S3SYum1TWButP5rf7Htp4+rhmW9RmsnQg5N4diC65+x3I/Hj7Ap9tYBILJGzqHrU52uWIlQTh4AOPamwGAC86rwe0a27Zp0lioCE8Drdnls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B247t+UI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B247t+UI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E7B1C4CEE2; Wed, 8 Jan 2025 21:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372248; bh=0V4sxlCPz+itlsPtq1bPzgTX0ZYKT5JKKOgt2zH9uus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B247t+UISj5WWb/JDVTsEtBMfhX5mKHrb3jN6RJyYriK3ho/+p2UU3mP84CYVhsbv 8zNL8gfX/40lmUb/y3NVaqGYNr0tI8hUU8LoGhIskoZfa3k7aVvC3Q79/OEssMT7n7 7RnlOlAn726dsytQPjqzm/haaM589ZmsEFeEmQ+tWr9GwQh9Fv0cuHXrbDkvZ8zWJm P7hM5XaMhz7dw8ykrq1jWS4H2QEXjZuEKFFWM0w8Fcq3pA+JrBnR3w7Cts0lYQy4PK l2OFr0tzYdS4GWcAS5KEM5oSzDRDPXKEHFpYd52umFi7sWdGUvGwO/rO5nEST1307y x4EjAo7sZ2Sjg== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 02/10] rpcctl: Fix flake8 line-too-long errors Date: Wed, 8 Jan 2025 16:37:18 -0500 Message-ID: <20250108213726.260664-3-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 92a851c2278b..ec43d12afc41 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -66,13 +66,17 @@ class Xprt: f"Requests: {self.info['num_reqs']}" def _cong_slots(self): - return f" Congestion: cur {self.info['cur_cong']}, win {self.info['cong_win']}, " \ - f"Slots: min {self.info['min_num_slots']}, max {self.info['max_num_slots']}" + return f" Congestion: cur {self.info['cur_cong']}, " \ + f"win {self.info['cong_win']}, " \ + f"Slots: min {self.info['min_num_slots']}, " \ + f"max {self.info['max_num_slots']}" def _queues(self): return f" Queues: binding {self.info['binding_q_len']}, " \ - f"sending {self.info['sending_q_len']}, pending {self.info['pending_q_len']}, " \ - f"backlog {self.info['backlog_q_len']}, tasks {self.info['tasks_queuelen']}" + f"sending {self.info['sending_q_len']}, " \ + f"pending {self.info['pending_q_len']}, " \ + f"backlog {self.info['backlog_q_len']}, " \ + f"tasks {self.info['tasks_queuelen']}" def __str__(self): if not self.path.exists(): @@ -106,7 +110,8 @@ class Xprt: self.set_state("remove") def add_command(subparser): - parser = subparser.add_parser("xprt", help="Commands for individual xprts") + parser = subparser.add_parser("xprt", + help="Commands for individual xprts") parser.set_defaults(func=Xprt.show, xprt=None) subparser = parser.add_subparsers() @@ -128,7 +133,8 @@ class Xprt: online.set_defaults(func=Xprt.set_property, property="online") offline = subparser.add_parser("offline", help="Set an xprt offline") offline.set_defaults(func=Xprt.set_property, property="offline") - dstaddr = subparser.add_parser("dstaddr", help="Change an xprt's dstaddr") + dstaddr = subparser.add_parser("dstaddr", + help="Change an xprt's dstaddr") dstaddr.add_argument("newaddr", metavar="NEWADDR", nargs=1, help="The new address for the xprt") dstaddr.set_defaults(func=Xprt.set_property, property="dstaddr") @@ -161,7 +167,8 @@ class XprtSwitch: 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.xprts = sorted([Xprt(p) for p in self.path.iterdir() + if p.is_dir()]) self.sep = sep def __lt__(self, rhs): @@ -176,7 +183,8 @@ class XprtSwitch: return "\n".join([switch] + xprts) def add_command(subparser): - parser = subparser.add_parser("switch", help="Commands for xprt switches") + parser = subparser.add_parser("switch", + help="Commands for xprt switches") parser.set_defaults(func=XprtSwitch.show, switch=None) subparser = parser.add_subparsers() @@ -185,11 +193,13 @@ class XprtSwitch: help="Name of a specific switch to show") show.set_defaults(func=XprtSwitch.show) - set = subparser.add_parser("set", help="Change an xprt switch property") + set = subparser.add_parser("set", + help="Change an xprt switch property") set.add_argument("switch", metavar="SWITCH", nargs=1, help="Name of a specific xprt switch to modify") subparser = set.add_subparsers(required=True) - dstaddr = subparser.add_parser("dstaddr", help="Change an xprt switch's dstaddr") + dstaddr = subparser.add_parser("dstaddr", + help="Change an xprt switch's dstaddr") dstaddr.add_argument("newaddr", metavar="NEWADDR", nargs=1, help="The new address for the xprt switch") dstaddr.set_defaults(func=XprtSwitch.set_property, property="dstaddr") @@ -225,7 +235,8 @@ class RpcClient: return f"{self.name}: {self.switch}" def add_command(subparser): - parser = subparser.add_parser("client", help="Commands for rpc clients") + parser = subparser.add_parser("client", + help="Commands for rpc clients") parser.set_defaults(func=RpcClient.show, client=None) subparser = parser.add_subparsers() From patchwork Wed Jan 8 21:37:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931562 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBE4520468E for ; Wed, 8 Jan 2025 21:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372249; cv=none; b=qK/fs/ZQ7OIbmG3EV/kPBqE0WHsUSg/l9R24+C8aXWX5BPNX6HJyXXNQLZRgB6Rleb3RtjNuK+zmbiuuqO725cg5h/TbZVnZQazGpydrW0BRm4MFzi0irLB0yV/y23GW5ZtohjvFEnFqTSuH+xF7ZGJKmdpFlGQy3KlIzWqMzZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372249; c=relaxed/simple; bh=HXmXUXLSrd7RgDLMydjovtSkU8JwcPnmzJgtXPt5m9Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hhnWrY9nF5d/T2DXfFVouKjX8TNP4VU8Naz2wKKDyw2LKoGaWVIqkuSn19zQruDb7Z+COWl34Raf6525cJVkIGqGH0kStnGjMt6bvjRyeg3gVVfxiPIFxJNvEV/fNItkFzTeSjy0C21/ZjxPgP+34Kce32xFZD9dHItIyrP1gPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gTfaz2Vh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gTfaz2Vh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA80DC4CEDF; Wed, 8 Jan 2025 21:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372249; bh=HXmXUXLSrd7RgDLMydjovtSkU8JwcPnmzJgtXPt5m9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gTfaz2VhMJMHTkH3eHW+BotCZ/ZRbX5jRKTqw8Fi/w35eNwhcW8PGZ7sUdVLk9VhX SyfS1rBisz7lQw1vZUuPkN/rOmUcWK55//BQIb8uCg4FhD73MfM7kca8TF52MBd7z1 ZDI7eRkx0dvmWxsxyTe3UEzHu1wK2Dn5y2YWwsps1CDaDfdZhsCFWbJdTkUI+U84Cu PbcZKbCvbWIz//Fa/WRh7PRg5Uu50IAgVkl+kLTR/enu0P37e4W0VGoWVnc916/hEj QixlYoAEQcazrCL2mLtORnDOs07/s/z9bdDJagFW1AIloJt9/xSpqiJJLlzPIfRZoI Q8q+/cz0szstg== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 03/10] rpcctl: Fix flake8 bare exception error Date: Wed, 8 Jan 2025 16:37:19 -0500 Message-ID: <20250108213726.260664-4-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index ec43d12afc41..c6e73aad8bb9 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -23,7 +23,7 @@ def read_addr_file(path): try: with open(path, 'r') as f: return f.readline().strip() - except: + except FileNotFoundError: return "(enoent)" From patchwork Wed Jan 8 21:37:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931563 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D79F20468E for ; Wed, 8 Jan 2025 21:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372250; cv=none; b=vDTkCcqQ3dycoXA72VNsbb3nbpYTcs9SLbpgitNunGP3St/etg6HqdrOovMrlagRJAT57Lc33Uv2aoUbEF98+A5Ti50MW5IwFdaUBswEGFiDf7o8E+BoN7/yWYJwSAWt1RaJbSQKb+gbC2++hlagA3QNOPTOTIVjp7ZFjbp0goI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372250; c=relaxed/simple; bh=2yKbHVaOHdTZCHip3sx7Ve6r7fgYiMdZZZ4shSizyj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mvG3EUeOJeCdJUN0WplLPRH5DdCjGbDT8ZQITNgnLVS18yDQNxYVGf2ydquxBc3L1VdHBNp0iwfnC5c6j1wl0YwUR8nl0HW/aTTh8wE3iSNPK/wWOIMPkU4KDrGewjxB8j1aZtWcXwfIU/QnWZv04in7kR/JHoNqPdLBmMLiMbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H4E6FvOt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H4E6FvOt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89C09C4CEE2; Wed, 8 Jan 2025 21:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372249; bh=2yKbHVaOHdTZCHip3sx7Ve6r7fgYiMdZZZ4shSizyj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4E6FvOtE1zy4mOgEH5RLY6j024aW6uP+SZp9ke7poyNLyiULx6OXQmJKsuSIVT+9 mftDt9j4q0xHqlMCs5JE/nqnu4i/4NLMVLZ/R7qWcHPjPOZo5+ICfZlkf7cpnljMjb A3hgdvFfqguv/EX3sVwxurGZ00HAofBuGbe14tm3q4ItYrzap43PXZPqSqaAL0gQJY lGyFT8E4KFzQ6QsMhogoM7xQNZMTOzgIFNJ0/rZXb2/+N/L/4feTSRhfV1xDHZoWgp 8EGEuwzT7Q6GibWnyyiTWtxCviI+in3teBBLWp4PUrBida8X6jwP6xRRRAXTrKUcVx TM1ZwjJ8CN+fw== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 04/10] rpcctl: Fix flake8 ambiguous-variable-name error Date: Wed, 8 Jan 2025 16:37:20 -0500 Message-ID: <20250108213726.260664-5-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index c6e73aad8bb9..435f4be6623a 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -37,7 +37,7 @@ def read_info_file(path): res = collections.defaultdict(int) try: with open(path) as info: - lines = [l.split("=", 1) for l in info if "=" in l] + lines = [line.split("=", 1) for line in info if "=" in line] res.update({key: int(val.strip()) for (key, val) in lines}) finally: return res From patchwork Wed Jan 8 21:37:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931564 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E25A3204696 for ; Wed, 8 Jan 2025 21:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372251; cv=none; b=Oz/PWm3KDsuq5fZ0Dnr59ISiyLTcY7lU55oOTKz1FaN9F0NpD+7NiNuooysd/I39QWKnVZWmbr4Y4+GyD2Aea4reXG7zd7AqvKUCmiQMsME8Zi25zP8Y4y9Z8xkl1covgxTu35lJwPu/ibwWbnQAOYQCVXjFkhs6qfZYi+qg9Ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372251; c=relaxed/simple; bh=ciNJNKQUk6OHtbaa2qJUKYgCaPsZGL7zLIgxK4tRh4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AEmUDXlOW3VD9vFPjIpNiz6bQly9u5a43ilF/SSEB5R2RK4NhB8cwfX1rN3QYMgsIM4Q01PWrazWA96qfS2zZFs7UeIwCBVqfr/03sfOmNCcwLmsLeHvjJcO5H14/zlkpJ7KU2F8rDVeyfbA5+ZLRUl+FczSUH78o1nF5/kkGYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kMERH7i/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kMERH7i/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AF36C4CEDF; Wed, 8 Jan 2025 21:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372250; bh=ciNJNKQUk6OHtbaa2qJUKYgCaPsZGL7zLIgxK4tRh4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kMERH7i/Ncln1YBX7JEo7yvUy9dzRWmDi+DRDiFHPwKDIK4WdRtNXflrK9yoW0cr+ a8Z4udmQFQUFcDZ3Cda/z9PjUrXqFBigzzILAH29vhP0shtJeyG0FNp6ESntTV5qMf B8m5k+YBfA7FhAezzqnrNzmoCO89bhrjyAn/tY+C5lz027/5CqCuB0e7bJyleA3v9L QzSsDU9FhfSk93tu3UnBhtMBAmgNdbUIsKzwtp0rBy5QWOgB30mQiRaj+FxDIVyaYY Xm2eFgM2eJR2NHnNEoVOn1aUTO2PYfk1RIMixFLYe8A8+eSGkY4Xgowb4AVdl8OREc 4Ihju119lHMLQ== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 05/10] rpcctl: Add missing docstrings to the Xprt class Date: Wed, 8 Jan 2025 16:37:21 -0500 Message-ID: <20250108213726.260664-6-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 435f4be6623a..b8808787b51d 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -44,7 +44,10 @@ def read_info_file(path): class Xprt: + """Represents a single sunrpc connection.""" + def __init__(self, path): + """Read in xprt information from sysfs.""" self.path = path self.name = path.stem.rsplit("-", 1)[0] self.type = path.stem.split("-")[2] @@ -54,6 +57,7 @@ class Xprt: self.read_state() def __lt__(self, rhs): + """Compare the names of two xprt instances.""" return self.name < rhs.name def _xprt(self): @@ -79,24 +83,29 @@ class Xprt: f"tasks {self.info['tasks_queuelen']}" def __str__(self): + """Return a string representation of an xprt.""" if not self.path.exists(): return f"{self.name}: has been removed" return "\n".join([self._xprt(), self._src_reqs(), self._cong_slots(), self._queues()]) def read_state(self): + """Read in the xprt_state file.""" if self.path.exists(): with open(self.path / "xprt_state") as f: self.state = ','.join(f.readline().split()[1:]) def small_str(self): + """Return a short string summary of an xprt.""" main = " [main]" if self.info.get("main_xprt") else "" return f"{self.name}: {self.type}, {self.dstaddr}{main}" def set_dstaddr(self, newaddr): + """Change the dstaddr of an xprt.""" self.dstaddr = write_addr_file(self.path / "dstaddr", newaddr) def set_state(self, state): + """Change the state of an xprt.""" if self.info.get("main_xprt"): raise Exception(f"Main xprts cannot be set {state}") with open(self.path / "xprt_state", 'w') as f: @@ -104,12 +113,14 @@ class Xprt: self.read_state() def remove(self): + """Remove an xprt.""" if self.info.get("main_xprt"): raise Exception("Main xprts cannot be removed") self.set_state("offline") self.set_state("remove") def add_command(subparser): + """Add parser options for the `rpcctl xprt` command.""" parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.set_defaults(func=Xprt.show, xprt=None) @@ -140,6 +151,7 @@ class Xprt: dstaddr.set_defaults(func=Xprt.set_property, property="dstaddr") def get_by_name(name): + """Find a (sorted) list of Xprts matching the given name.""" glob = f"**/{name}-*" if name else "**/xprt-*" res = [Xprt(x) for x in (sunrpc / "xprt-switches").glob(glob)] if name and len(res) == 0: @@ -148,10 +160,12 @@ class Xprt: return sorted(res) def show(args): + """Handle the `rpcctl xprt show` command.""" for xprt in Xprt.get_by_name(args.xprt): print(xprt) def set_property(args): + """Handle the `rpcctl xprt set` command.""" for xprt in Xprt.get_by_name(args.xprt[0]): if args.property == "dstaddr": xprt.set_dstaddr(socket.gethostbyname(args.newaddr[0])) From patchwork Wed Jan 8 21:37:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931565 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E64CE204699 for ; Wed, 8 Jan 2025 21:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; cv=none; b=uOhdcM+gZr9ybFSryYwDcN04uP4SQdhUvBgUfzM8gHecxW89hr791kl8uajwvXTIIfc2F5NVuFCg2j839Zo6ihhBxokB+pm9YkhM89BfMXSen9rGzYKoG8hbdZ2UV1agmQHjckbhVVaAEmLWWu0iSePxC+xkO/N+6afqNrYV1XM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; c=relaxed/simple; bh=5qlZXj8hlh4KeRoXPvbvmIX++lohLRAE6j8J2PBxSB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g0LI3Z6cxoObUn548USbDA4jc50bE9d7n7OKxE6xhnIuea9mkJFCZh42ahpTF/HRHrL7znslknoG7K9HU9sMrMgSQWJ4kZ+ABuevwyP/wYoqDvvN3l13DPzFqgGJSoKFMtbyFpHLZdRld0v8evMo7ZKG44cwJEDKFBeco/MxiYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uyK630XG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uyK630XG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4ADEC4CEE2; Wed, 8 Jan 2025 21:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372251; bh=5qlZXj8hlh4KeRoXPvbvmIX++lohLRAE6j8J2PBxSB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uyK630XGrEkgjxJZw8Ek05mjGJSuPImL3iJFJGDNMEsB3xpTeXnNYQnV6/YL4Disi dmspzb2phczjRmXfvPnFd2FR5Mcr7GMX+K1khy1KMndKvDTxBfPfRp8PieDcUQ1Z1w uRPQ0TVz9kTiCtvrGTfiKYyVEiZN/JWi/cO/dj18+BqvgQd31xC1vaR9JeLBU5W7k6 Zl3n4ZAtitW84ukhdQF77HVBaXzFvCMDg5ZiXBkCKgCTVcp0GyeIqEMA/pzkUsDhjm vCUh2TnMr1xgwLBYZNmWZJ17tohemAYfA2Hqr2tP0ruBGMj4XqsQMsBbca4cWQOqpq 5xkDrycuqIT7A== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 06/10] rpcctl: Add missing docstrings to the XprtSwitch class Date: Wed, 8 Jan 2025 16:37:22 -0500 Message-ID: <20250108213726.260664-7-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index b8808787b51d..adeb26d51f0e 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -177,7 +177,10 @@ class Xprt: class XprtSwitch: + """Represents a group of xprt connections.""" + def __init__(self, path, sep=":"): + """Read in xprt switch information from sysfs.""" self.path = path self.name = path.stem self.info = read_info_file(path / "xprt_switch_info") @@ -186,9 +189,11 @@ class XprtSwitch: self.sep = sep def __lt__(self, rhs): + """Compare the name of two xprt switch instances.""" return self.name < rhs.name def __str__(self): + """Return a string representation of an xprt switch.""" switch = f"{self.name}{self.sep} " \ f"xprts {self.info['num_xprts']}, " \ f"active {self.info['num_active']}, " \ @@ -197,6 +202,7 @@ class XprtSwitch: return "\n".join([switch] + xprts) def add_command(subparser): + """Add parser options for the `rpcctl switch` command.""" parser = subparser.add_parser("switch", help="Commands for xprt switches") parser.set_defaults(func=XprtSwitch.show, switch=None) @@ -219,16 +225,19 @@ class XprtSwitch: dstaddr.set_defaults(func=XprtSwitch.set_property, property="dstaddr") def get_by_name(name): + """Find a (sorted) list of XprtSwitches matching the given name.""" xprt_switches = sunrpc / "xprt-switches" if name: return [XprtSwitch(xprt_switches / name)] return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())] def show(args): + """Handle the `rpcctl switch show` command.""" for switch in XprtSwitch.get_by_name(args.switch): print(switch) def set_property(args): + """Handle the `rpcctl switch set` command.""" for switch in XprtSwitch.get_by_name(args.switch[0]): resolved = socket.gethostbyname(args.newaddr[0]) for xprt in switch.xprts: From patchwork Wed Jan 8 21:37:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931566 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E65282046AD for ; Wed, 8 Jan 2025 21:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; cv=none; b=j5a137caz6xsdOOo9axM4LjwuWYj2r7lTiLqX6gTPp1tfaObfHtnimSIIWr/XMe6eju8WfTBu9kOycvAWQDyVlmi5YYjgqnO8yBjJJWYftu+t6fGo5+SRQ56NLwKbg/BWZTzxflJhG1zyrUhyvQyml9cTQ461Uy/EGg2O9mxAgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; c=relaxed/simple; bh=0DECj3dt2Ypdi8/vKPv5Nz3JV/SpaEltQPMDB1K/eR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V4A+ZKoFLoD8kHnrSfc7aQ5mLOIrLstE7Fc2dJUpzNKb+SDU/Yv/aqmidawPe4xT0zKEk8UXW1uRSNbqgHpepxqAWcugILB/WZB2cebnBkNIDbHPAIFGRNj6XscCwDgY9LZF0+DTGFM7vJGAStw+meZzkmNv7OBxHZJOqvXCr7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z4JcVL6r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z4JcVL6r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49F69C4CEDF; Wed, 8 Jan 2025 21:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372251; bh=0DECj3dt2Ypdi8/vKPv5Nz3JV/SpaEltQPMDB1K/eR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z4JcVL6rTIeUTbG++fTsTYirWxWlQGmxw1uNgCNE5h7iX5GWsKAhC+J4ZQ61phQOB nmyOP+5Bf8UUt2S4Zgu2Fh9n+f7LnVNTFZchnRy6Rcdxd9bIr9A4cbmyANY507gxj8 a/hbQM0zXa9a20w3pmfafyCNWxcWOEAPBktU4Q66Iocqf2llEGlPnkJ50at4dJgiJk YwCFGuz+JiBmoMSdwzGkNE4zvGxH0aESw/SfKXZadVDjb8Qhc2OU8C+78sDthrukYU 0hrG9+JbY/jvIKXZO4tb+tyaDiTm+PEyyqe1OLYTb42VY5Lorh1xQ4v3iTvB8gpQ9N cq56duYg5grRg== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 07/10] rpcctl: Add remaining missing docstrings Date: Wed, 8 Jan 2025 16:37:23 -0500 Message-ID: <20250108213726.260664-8-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index adeb26d51f0e..0221fbb68be1 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +"""Utility for working with the sunrpc sysfs files.""" import argparse import collections import errno @@ -20,6 +21,7 @@ if not sunrpc.is_dir(): def read_addr_file(path): + """Read an xprt address file.""" try: with open(path, 'r') as f: return f.readline().strip() @@ -28,12 +30,14 @@ def read_addr_file(path): def write_addr_file(path, newaddr): + """Write a new address to an xprt address file.""" with open(path, 'w') as f: f.write(newaddr) return read_addr_file(path) def read_info_file(path): + """Read an xprt or xprt switch information file.""" res = collections.defaultdict(int) try: with open(path) as info: @@ -246,18 +250,24 @@ class XprtSwitch: class RpcClient: + """Represents an rpc client instance.""" + def __init__(self, path): + """Read in rpc client information from sysfs.""" self.path = path self.name = path.stem self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") def __lt__(self, rhs): + """Compare the name of two rpc client instances.""" return self.name < rhs.name def __str__(self): + """Return a string representation of an rpc client.""" return f"{self.name}: {self.switch}" def add_command(subparser): + """Add parser options for the `rpcctl client` command.""" parser = subparser.add_parser("client", help="Commands for rpc clients") parser.set_defaults(func=RpcClient.show, client=None) @@ -269,12 +279,14 @@ class RpcClient: parser.set_defaults(func=RpcClient.show) def get_by_name(name): + """Find a (sorted) list of RpcClients matching the given name.""" rpc_clients = sunrpc / "rpc-clients" if name: return [RpcClient(rpc_clients / name)] return [RpcClient(f) for f in sorted(rpc_clients.iterdir())] def show(args): + """Handle the `rpcctl client show` command.""" for client in RpcClient.get_by_name(args.client): print(client) @@ -283,6 +295,7 @@ parser = argparse.ArgumentParser() def show_small_help(args): + """Show a one-line usage summary if no subcommand is given.""" parser.print_usage() print("sunrpc dir:", sunrpc) From patchwork Wed Jan 8 21:37:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931567 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1840204690 for ; Wed, 8 Jan 2025 21:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; cv=none; b=UrYZxSLHDmWbWkB/HtpndUzO4CHGcezjDtcUvW3YGxOuITis7L5y2HSZ43e2RlWB6Qb1aYfR/+paYrAshN6zVRx3NOiZTUB6b7Wl18jux0x38hMSsgmXrdGsbBhtkbEa78Qe6Kj2aFFZMFq9gKUfRrvoWbPnIImygDgdB/vnDxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; c=relaxed/simple; bh=FH9V4eDopKIQlmPmb10TVifkgoelCXgFhNpQXHzB1+M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UL9jVC6RR1x1S7Xi9N2yEWRgK5+4g+XNr2pWrSi2/RefaXDcbSvssm1P+2oao2LJBgZJau830JyajD5k687NWC9aqz4ipMjybdmIzj4EFvtmc1mo1RNrmsku2WIbKe/cGgjtgpGkBTmjeSvAYlZBv5Vtc8ZLV5SmGKIygLpgvH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C8lupjdP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C8lupjdP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4427C4CEE1; Wed, 8 Jan 2025 21:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372252; bh=FH9V4eDopKIQlmPmb10TVifkgoelCXgFhNpQXHzB1+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C8lupjdPohu3A9TboO5UhoqJwaeMWUi7Svew0BHvk+0F8QljlVulyuwePc1VR1ip5 0ie0M6g1HeQ4aH0qZ8eJSrSWvyUQn5+nBnv42pgwoVLlybr7XBAXhSGy3duop2uyt4 UBMVhNHaR8bN9SBbMNO7VElBkDmTtPweGXPxxzX7pqxbcb5DXDre6nvn0GKeeVNIbw GUWxVnE3qAUiNUCV9kxMfL/bYFbf3yDw5zNde7C42K+XhIVSWvffR5419vXAI0CHUV Co3TEE8Ju49Upho5+QYHle2jU7qaEz37zq9PmcoZ8jHI0yfyh9VwKIGtYDilLvozZX A369GI/JT4aiA== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 08/10] rpcctl.py: Rename {read,write}_addr_file() Date: Wed, 8 Jan 2025 16:37:24 -0500 Message-ID: <20250108213726.260664-9-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker There is nothing address specific about these functions, so name them something more generic so they can be reused. Signed-off-by: Anna Schumaker --- 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.""" From patchwork Wed Jan 8 21:37:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931568 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4AB20469C for ; Wed, 8 Jan 2025 21:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; cv=none; b=N2tsMiIsltr9l5Oj9Vbjmv/GItxoHyBPJNn7mZR7KKVDqH87VIqCnHBz3Rb03JRd/nD3g0njmTtCuRWHo+Odt0Zp3XiIagQ/FBqyFF1GS6DaGwyZnpKo9IqS9eCMa0BOVDt/9hw0tGo52s75lZcK2wcWdJvxAYflwdBsfZichmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372252; c=relaxed/simple; bh=CTnzduBHPxc7Bt/P+DI7oh5Esmvkx82/JZ0FPV8utNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dfsgp/AQWDEY5fiwLmPNWJp4djtNVywtXzDvqTfE3xczY2Z2GGmnw9wqSCuBlFFYAN9vNyQgNb06u7sjkaZ+DXWJPoUenu5Ydq3tXbf4SXsunfz2Hj+xoS3IBdWnUklFgWGbKzFKEaZSdlUA31PU2N2lAqg9gLlMTgk0ODw7Ma8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iuN+yh8q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iuN+yh8q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AAA4C4CEE6; Wed, 8 Jan 2025 21:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372252; bh=CTnzduBHPxc7Bt/P+DI7oh5Esmvkx82/JZ0FPV8utNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iuN+yh8qa7r7qE6kWHLwdfCU6zoRjvMweRVZZJ2X9gcEIiB62iWMEAYj9HkfJ8av6 vDfUKw/Ap2JzRig0oC8mUPrSg7gLVTn6oa4nPMYXWimix0eheQ6qjQlpbuG0YLD+AW bttlFp7U6W77ivHOm0++EuZVH7QFEkQvMvXc4w/IUzmx+e70aGdaB3aL7lX1jVKYy8 3F40ovyUrIFjS2cATvSYCuMc8+N+gC7YQBgcITSNvBMV9entXFOm39yKz9raoxQcLR ykLOALkVZLahjlFXk4sdlmV0wjpho8LQ3Rvz9zROD8pLaIZoFCqZu3o17upF1SU2Jj lsKJHZY/hSD7w== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 09/10] rpcctl.py: Add support for the xprtsec sysfs attribute Date: Wed, 8 Jan 2025 16:37:25 -0500 Message-ID: <20250108213726.260664-10-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker 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 --- tools/rpcctl/rpcctl.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 654b2f60a894..20f90d6ca796 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -36,6 +36,15 @@ def write_sysfs_file(path, input): return read_sysfs_file(path) +def read_xprtsec_file(path): + """Read an xprtsec file.""" + try: + with open(path, 'r') as f: + return f.readline().strip() + except FileNotFoundError: + return "(unknown)" + + def read_info_file(path): """Read an xprt or xprt switch information file.""" res = collections.defaultdict(int) @@ -58,6 +67,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_xprtsec_file(path / "xprtsec") self.read_state() def __lt__(self, rhs): @@ -67,7 +77,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']}, " \ From patchwork Wed Jan 8 21:37:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13931569 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C003220469C for ; Wed, 8 Jan 2025 21:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372253; cv=none; b=hNrLDccfcLXu0jlXQwYnSuxIVwJjHUnhKojYbn1BX4lqm83Zf4PdHho18H6h8rueKVpUiTYUnw8E9GeMnfGfe0RbTou4v5n0oTHEpUGQ+vcW4LQucwv1BbhRUwkTrR3NtFusjwgdE71iWmpYLbeXdBnsDKOSIUXWj96qio1YbWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736372253; c=relaxed/simple; bh=flcgskvrmIU/Aqh8316x+t5NHkXN4cH6AcMOVPQ7mGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q9Cj9WmHTZ7101gB11ZenSUmSlTyBYlZsah/G7AdgFrmuoIMK3lzc8o3V8QHZ/R9AysoQ/NIgASEICFqUV6T+cpJ/69tAjiZbzAkdPWKZGtWKk30ju+FyMYd8rZEz1Aea2VAL+t9LpmcijOAvRUk9Q++axay8XeT82E0u9YNFGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sd64+a8N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sd64+a8N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03260C4CEE4; Wed, 8 Jan 2025 21:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736372253; bh=flcgskvrmIU/Aqh8316x+t5NHkXN4cH6AcMOVPQ7mGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sd64+a8Nt7ycZwUDSxhf0phfmZm4c/BQDM122DdWUM0T9xT3bDwhU2bGqOmwXCsJS 7dy/hbvw3vz5uawBBsPjzS9INAvh2nhgi3QcNoFwMQGKC+kWbFqs9+VflZ/EfmPd9P +Ok0Sxfc9PwvK20TTh1Dypc6jiltAYf6XyxEI9MGoWPpRO/5z4N0+sL0mIlrmSGHHS EMWFz/th8o3TQno+UJ3hv5rVfAfcE8IsUXZwrhV4eGJCcW+mLhUVVuU6hCWep9Gk0m AHOISo15umRROq8Ik3gJoqX9AWu9r0U27KSSqv2/iDriXCofoOP1gf9odfL7FXmDzY mA5FkLkDsOwMQ== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH NFS-UTILS 10/10] rpcctl: Add support for `rpcctl switch add-xprt` Date: Wed, 8 Jan 2025 16:37:26 -0500 Message-ID: <20250108213726.260664-11-anna@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250108213726.260664-1-anna@kernel.org> References: <20250108213726.260664-1-anna@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anna Schumaker This is used to add an xprt to the switch at runtime. Signed-off-by: Anna Schumaker --- 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 20f90d6ca796..8722c259e909 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -223,6 +223,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") @@ -246,6 +252,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 / "xprt_switch_add_xprt", "1") + def show(args): """Handle the `rpcctl switch show` command.""" for switch in XprtSwitch.get_by_name(args.switch):