From patchwork Wed Jan 15 20:29:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940896 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 454628F77 for ; Wed, 15 Jan 2025 20:29:58 +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=1736972999; cv=none; b=XO4jpxx0/Rp1drGd/MAbB61GLZl2RKv5J90BVdxBQ5ow8CPuNRReJShHlSIGNq5ZVpsyYNwiDnAxvHI4yEJjWPg92ibwCf8z/PD7/WknyqOrYmMIL3ZpwO5j8eD+/ixi1L0rgcX4hk6soYtTfRboj1HF+REhg+k6Em/5y3kj9ZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736972999; c=relaxed/simple; bh=lPEmA6ck3pSMyWC7cY1+5R4MNAM+1KDdJol1heDUFFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XN7/APpa0HHs3RZcAnixlHx65iU8mITJuI2V3k7QBUJDrQHn6uMU2gCIacmE0Hdk5L+NhQEdITuNbcDl5gr3BGjtlflbZrshUifihg3YyxojXoW3qssa/ECDBoSg6J4Ve6K9rkVZZ55fOPF6wB2H9hjzg4qWlIRnlReIKzNXdk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZQzslfyp; 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="ZQzslfyp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 727BCC4CEE3; Wed, 15 Jan 2025 20:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736972998; bh=lPEmA6ck3pSMyWC7cY1+5R4MNAM+1KDdJol1heDUFFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQzslfypj0tejuVt/5R6PdCJ3cXTi2yA000S44vr+2lQGz3Yx1gDREPJJO9Tt1rd5 Gg9K22egZBq0hmVD/gf3zii3bTbHCAos1tjiuBnVa9tR32ifl0Aak1gJm472vOjkY3 cyJQY1GGBD5xrYyolk5u+6xx1NA3A8owsOcOIq9j7SVN8sVm0AX98dknc3H+6pg5/V aQiO2utm5WFBvKvhgYbg4iF811MwJFg9wXJsMSjcKoxC8sPLw1PPF40qN6wwLjCKFI hlxbrwPtClqIIgGynrPQtovkhXbf6eVrDa9Axzrzd4hKuXEBDiV/JLfdx2ePuu2DkJ XG5c8MSCNVYGw== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 1/7] rpcctl: Fix flake8 whitespace errors Date: Wed, 15 Jan 2025 15:29:50 -0500 Message-ID: <20250115202957.113352-2-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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 15 20:29:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940897 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 795B71D9320 for ; Wed, 15 Jan 2025 20:29:59 +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=1736972999; cv=none; b=DsEjMvLFbvYc6ITIzIvXkXNSUIxchYcLdASoH6923sZiSXdlwdpjNi9J1VYLhZhrtW3YgV/zzevFM0HOAqkV+YaAP02FCZwdwsTgAQ3O5BxU1GT/yzyRptu4aLjzLeU6hzN1d0hiCgkf7oLo9anc7ElS3/8bq1JytNF+HTqlPZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736972999; c=relaxed/simple; bh=xW70Aucnop/TXo6NJMtzRw2LYQdaei3qhN+R3YKWe9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O3+4h3CM/WDEsnN5CNAvLYHFnjbmUgWkQoLQK+U8DbbJJaPMQDj9VVi08grGHNWCUcbmt3Er3h7pkilN6M30BwHaIiZvYO7N9VwDbed5fprlQNVjMUIKWp6ixA6o2o7WlwSWcybS+KOd4WdAdh0VfOrUoOTZPBTA5jilvR2OPE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l6XF8Lxj; 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="l6XF8Lxj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 084F5C4CED1; Wed, 15 Jan 2025 20:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736972999; bh=xW70Aucnop/TXo6NJMtzRw2LYQdaei3qhN+R3YKWe9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l6XF8LxjbBn/QFgpKoQzQqzkWwivW3MCicTti3oGMd/9cyGqq1wmc1KMwO+r2G55v ETb5A1LjIALrplPP4HLIzMquluJppB7DmycyMUehWnZgz3+qXOmUhD0Z3LAMZRvCa/ wmd7Dqecgl2w6bAA1UtZWGbdv2sZOp3kcogAFYkbgsijmcch9YjNYYlZUAaGf7LCf3 k50BAmmlirwl66VfOROEvw5ID7zcA6msw5BmwDjsKDJ8VkAbpqPkKkY84DPhGVMkeJ Y092+75qn0EDYE6KGHKQEhUyPDltkD37YRWFFnBlIXSO4V4fGRxGzbqr+KzChL0GCT UJmozFLyZEg4Q== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 2/7] rpcctl: Fix flake8 line-too-long errors Date: Wed, 15 Jan 2025 15:29:51 -0500 Message-ID: <20250115202957.113352-3-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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 15 20:29:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940898 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 227F01D9320 for ; Wed, 15 Jan 2025 20:30:00 +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=1736973000; cv=none; b=fS2hDur1wn3edbAwaBzb9VUE4gqhombx2HgLzTZbA9D+Cj01P4tLgrUq2mwT2cMFex65E/Rf5+mG60R48KmSEwEvmojbDhSQjWtHUR9H9EOJ0hZWTaIxxJn67s24/dPv9u6mXxDXZDcvDqe6GFcQ2qWC4WBZ57LgSsLtCq1Ntwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736973000; c=relaxed/simple; bh=1SY9npNDZCPDJOJxh0hepcXTRZ+x2s7mjFFm8rpmhwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AmZD8dJ7NURDVRd9uLyF/DoT3lFrgZa9Xcd/93VaXPhFzuiioAOBRArjCCjXoWqBBEYP7MTIQTOxD2M08miGprjfT4N+CPDsm8j7VxCTGV9tz2JFtnwHzeVa9kvrYCM3+dav9wpK4n8Onqk0HR1AXNTPP9Ttl4vSf+g65JlwMKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dyTmc7Mt; 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="dyTmc7Mt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91998C4AF09; Wed, 15 Jan 2025 20:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736973000; bh=1SY9npNDZCPDJOJxh0hepcXTRZ+x2s7mjFFm8rpmhwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dyTmc7Mtq4C3sFp01v18O/5H/g9K/RPrTUsM86fWgnkslrgoc9x8+ZirfptKrbyPH 5/zJYX02C3S5IUJDL/RgAx1EE4n/dlVeLy9zit+Kqp+yWPMc9TqBiu312rvL0IPSsA Hw7/WiFUWsMlFMb4lZV03Vz7IGnGchtkczxFx2EP/2ok4y32ph15SptwAX5XtEDIIC WcVSg3wgCuu7KBS47Naf86vk997uM2RY9bLx4JeySiihxnhV1CmglCbXrSTW6imOlH UGi57K3bfjb5smL+0DDVpOABabFMOmXnySdMG6q1raFUpe5+5NHzC2Pt4Zh/SKx/19 fMmvtHDCtujTw== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 3/7] rpcctl: Fix flake8 bare exception error Date: Wed, 15 Jan 2025 15:29:52 -0500 Message-ID: <20250115202957.113352-4-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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 15 20:29:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940899 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 AAA9D1D95A2 for ; Wed, 15 Jan 2025 20:30:00 +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=1736973000; cv=none; b=ulOqDR/xOEyfQA/AKqhtIj83u4HhTTxIoySojvI9vcev1Ui1ZEXvNp+VRsSozpQPMx9z6hhcqyHsY526910G4xBms1MOOACYKOgEGhhgzVO9CJFCGeZLiEssW3SHi8h6mqwMC4bCrRizrmHLs5LfsWpL7kIUEo9RAoDDAGs9rwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736973000; c=relaxed/simple; bh=aKlE/uab/3R8C3BPeGxr8V73nq7hA/zceATf6X2HUSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eGRfnbKqZDieqN4v/KYyRi9uVD5KtXkU5fUpCq72O0f5lv7YDMYGlPLWHhWUYGKhpkUwbczbwnVyM26QriRSqPzKzUsexpg5lUrJEwub0QgG5upT4ezsHSis/lz9JvUumGNIYPgN8sUvbZhIbI7abummRfCMP+93VGMuzOcghT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R+yLQ50K; 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="R+yLQ50K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31BE3C4CEE1; Wed, 15 Jan 2025 20:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736973000; bh=aKlE/uab/3R8C3BPeGxr8V73nq7hA/zceATf6X2HUSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+yLQ50KtptfSyZe/FRSwPAPlZtroW0b4lj2ePy9VosMJHl/wq7zNFKoQLYOIhSIB hImvwJW4Zhnf7zpvQIUAcA7Zngp1uKHAjqClMUhLvwObhnoikXstFparPUPxB9Bxst Atqdg30RqRa4g511C6W4H8IMftIvd8zU8gGL6axIFj7EQr0UL0mVLYPCtUISIdrkyq KpWPQwqOmw952agysy/Qc9qSPFN4t721DAj/xmR0b0I4C9iEFBBlr40wUNG0lMNNw1 tqoEuFd4PGejjOse03CasGWZfZ159fPSPq1rGQtAU3bbkOmskeKjAPZvLT4Uy02wa4 7sj2gibukdMUA== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 4/7] rpcctl: Fix flake8 ambiguous-variable-name error Date: Wed, 15 Jan 2025 15:29:53 -0500 Message-ID: <20250115202957.113352-5-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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 15 20:29:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940900 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 42B1D1D968E for ; Wed, 15 Jan 2025 20:30:01 +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=1736973001; cv=none; b=nnGhMAV+xmh2JkuicT8D/2ecw2xiQbdLhfvwhw0t1GWwNME49YIY6r0DqsqnP5T5DbOd5C52GbRDF2yGCxxv0m7KnMXhYEzOlTJ+5LefaE0448le5s6zWeZFi4ymsyByl6Ljh3F2EcdWDSkCBKFB1vv6sZdllAW7SnwFD8r0XHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736973001; c=relaxed/simple; bh=yjkDiLX5hhYPH6CbLSaMhXE49j7uLj8uXTgK9uVGAMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=acFWc7J8ca3f/W3O3a59lXbRI0X5WlDJXewjYAPZQHHRc7zX8roRgMgsGwbfqcV0VR1aYra1LWY5C1yRnlt/GfsvM3IhDpSy8DnwW0HfBX1FFgPrHDYFJuZKvS8ccvhraJ39KzTPoLm+sGDWbukpwUVHI9zIhUhk1qxgC8VYqF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KYC7lBsR; 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="KYC7lBsR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4AD5C4CED1; Wed, 15 Jan 2025 20:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736973001; bh=yjkDiLX5hhYPH6CbLSaMhXE49j7uLj8uXTgK9uVGAMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYC7lBsRtFeLFuoxPlCfdlvsNb0UMAeqFmCEILAt4YlgYTMPGsSJeyIFlkJFYPUiW Z74c53NsybcaVabMcZLaRufUUtnnbeXvjkDDMuDJG33F2OsSmzy3KbmSUof7CDBThe vX+E+qtO7RZZQdfLyP14V2709OijurcnCZGdGmbcU8imUVbC/TyxOfBQFxBmgjKrhO wOxTNqu8SSanoxnuiiqofFdrs3IVTNAcXdv/qNQJm0VPAJz3nK/9JlRuzfiGqXJT6P J6aAucaRHfO4yc8MezYi7WhU+aD7fz/LrCBAQeYE0MC5Evuof7RA3veIlEGObTt1Aj AnaNqCN9t7m6w== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 5/7] rpcctl: Add missing docstrings to the Xprt class Date: Wed, 15 Jan 2025 15:29:54 -0500 Message-ID: <20250115202957.113352-6-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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 15 20:29:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940901 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 DA4C11D968E for ; Wed, 15 Jan 2025 20:30:01 +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=1736973001; cv=none; b=uy9OduNwrXonOUTVb37Q4jFkx0zZz786RFUJrwWPm2kdVY6MSG4mxNPfdPRH1qVcTmcF3pLYiu0DFnA7tS9q0hBqYv1S+GTDFDPGerwH+zU9C9bZRzwKm5P1FjNsL0W7ICet3PruP+t4AKkvmIcKkDEJrib/zWDrxn7EuVWp4Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736973001; c=relaxed/simple; bh=W6qK0Ba520y4HCa8GGP6e6N7kAmdoqUl7Q5Czvi8mmk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SoK+seoIYsy9HLFhCvZHbquZlvK1HpMqQ1zD0RVQamUW16vqKuCSeH7KU++O/MpNlS46IV7Aacl7wPB7JG3Aa9AqIJp27GvMLLFmZji2uOrc9wF7/DhDceqF0H+qVS+If85E18MFQy0ZRFBQfGQh3nK8mWztbH9Fg7TS7T2huL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eeNyk9/P; 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="eeNyk9/P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B5E7C4CEE2; Wed, 15 Jan 2025 20:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736973001; bh=W6qK0Ba520y4HCa8GGP6e6N7kAmdoqUl7Q5Czvi8mmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeNyk9/PMMiG4eOv9KMplonF9YR2e/tPHVl41Krunxo/DXq1FkNIRItQakSNpHbjI vZSCrQtKuSwx8cm/X/rbAmsgpV6T74XC9uGJJC/oOfHMG0YGSgTSr8G4/1yKl675De gOrv0zacmxuDmKRWOe4U+sU6Ro2kVI0E8GLMZ5eiTc2Ulq8tkWP6oBHYpm/tRXRRjD 3Y+wtrHC0aOOF6kPW9V+dj44oa5cGc4LNNpozRmcx+gUwfuS4CvAlHcbcW0C0rLl1w 1h+ColbEEmHVQKsioEakegQQZP3v0kLCARCxNQWubFNvNsxX1U1byzedCV/uqVvQk1 I2osS+Gm/PoFA== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 6/7] rpcctl: Add missing docstrings to the XprtSwitch class Date: Wed, 15 Jan 2025 15:29:55 -0500 Message-ID: <20250115202957.113352-7-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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 15 20:29:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13940902 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 6F7831D9A7D for ; Wed, 15 Jan 2025 20:30:02 +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=1736973002; cv=none; b=G06Y6u4CoY51Uq5+W6LCcQ0eFAaAkjRZWkCcEvBxJThCPLmxQK0YO7+WtqnU8YaKNdH92JfdMkDOh063wjmm753e/9LOVQMvYQvh2NQ69KESN+jXxFzvqLHLKDhKVsJjVIMRIJTZbk1wxBFuNL/WRb9Avzbe+x2ZC5zkFuGoqXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736973002; c=relaxed/simple; bh=5OsjFvU0tnvh9ALhRSGUnAbO4RpCWKUTxxN5Y9WxHjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I6b1IL8O/maz9U/0oj2k78jGuqUfTE7c2AqihCRihJ/WCeozYYJAHAx0Uxc6TLzuTWoJenY+pmbF9PZNpaJxBgFShjcdvO0dGPXpalv1t84m9LUn+DHfR5LJZm4EfADK1tFlV+IUfKomj/mNstJlitU4/0F21w9ElgwoKLzDHNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=We4iX5bu; 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="We4iX5bu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBC10C4CEE4; Wed, 15 Jan 2025 20:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736973002; bh=5OsjFvU0tnvh9ALhRSGUnAbO4RpCWKUTxxN5Y9WxHjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=We4iX5buVTtGLRwx0u+c2EmMJ6yYIETHfNInWBnaDMUCPjXKaA5VxcSu6GL5aFKpF HQ/MI1pH/LhCZb7F8AHTlY78MTC+9l+TeZdMqhCFAjJ7KiRldQZ+jKF6gCyQSBljMt u+scQE/S3hD6Et3lcK9lh2C3nrlK+uQtwGebhbxVE7Sv0Eo8uv7bXePMAV6htRRTm5 4lBmYo9hbPKrhSNLZ3BZgmLvRE5qlnsHyOHEJVNN095IJEBv2Y9VUu4pNEg/LPB67e gx8NaD9HSbFltjs5MGzrUWkD9a6m6oHcStUsT3CbAKKFt4Gn1GMOdk2ffrUflxw2of 1y9Hmrdwi/cLQ== From: Anna Schumaker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: anna@kernel.org Subject: [PATCH nfs-utils v3 7/7] rpcctl: Add remaining missing docstrings Date: Wed, 15 Jan 2025 15:29:56 -0500 Message-ID: <20250115202957.113352-8-anna@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250115202957.113352-1-anna@kernel.org> References: <20250115202957.113352-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)