Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1483194pxb; Wed, 2 Feb 2022 06:05:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxquLrEgSki1r1nsraNPjtyjURb610Utc5Iqj9lz8dI7+IST6+AUgYEHdpFoazJHZJPVozF X-Received: by 2002:a05:6a00:c94:: with SMTP id a20mr18700077pfv.59.1643810721747; Wed, 02 Feb 2022 06:05:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643810721; cv=none; d=google.com; s=arc-20160816; b=tPRA7bq7FL23rVopiDL0eeDR13RpwmQxicAF9Kn9A0w7CoGrCQ2TwbgjZWNlC8QOtR U/CrfyjSagCG8I1BY+v/IW973R+M94Jn0Xf6M8fLpglWA3RKrNcq+K+mpL2dlP1sddhA GQc2NJ50ItugKYBxHVsSA0zn0fIwnipGUlMa6hZUVHhHmjkgo2kbtj+w3qwMjgR4Vt4D YzuRRnfdAxSWIt0vHEtpSUNQDAE/ylvvQ1zNIEsJZ1WV7tneXRytBqGWjz2G8asYK7/P dxEgswH2JBXo2mLZ773XOEuTvI2e4i/ShkbdVDGrsNOA5xOzYNIxwIt0+VQ/DuKkWP+J lc+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZypiyxpCcuEyM1ySNhbfCIbOxAuGxHr+z3CxNGHnfjY=; b=DfWL8Y7lwXR/96VfVVLGC8MN936k0oFpztvLcSEmXTfssXJlCMjJO9CAL7JPmMrXyG Mb8SYBHj9H2HjCx+aEY5yre+29ts4hECK5FAj0VzBpEIhHXGRlNRD/54fuVnfAxkUQO8 kjmaBqNPcXPS0SGH4ZggV/Nw2H4MEcuEcVLG6O/kGyRBQ9gluKI3SszV9rjMtMmtJjbr tUQTIhDA9oS3x/T69fA7ieFQkiuyevVQld85lUSJQBf1Bsm7fa76mHF/8J5WOPEclD3z B+w5cIYv4ukGlvHna/09VDZUczFrZQLAAxAVkbOTlYSuuk8ohX6gGj9gRjNP2kmU0iQ4 jMaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jj700g1O; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4si18471075pfr.238.2022.02.02.06.05.06; Wed, 02 Feb 2022 06:05:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jj700g1O; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240742AbiBAP6a (ORCPT + 99 others); Tue, 1 Feb 2022 10:58:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23839 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237158AbiBAP63 (ORCPT ); Tue, 1 Feb 2022 10:58:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643731109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZypiyxpCcuEyM1ySNhbfCIbOxAuGxHr+z3CxNGHnfjY=; b=Jj700g1OYIjy6mGWwZvq+vNdkmVO4Wge1hQUGg8xCF5cZOD4PyKfcXdxKJ0eyP6uKh38V+ PC+S/nPdvVDYy1x0/nC2gy8oS6IF+S3G1RQYcWvGJmcTxUhxgKU+7vR34/l+isXaPSBctK 7wp3tgteL59LVIYkrFwNFqAtlMPiu3s= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-lHUZM5_SNsKzIfdytcskqw-1; Tue, 01 Feb 2022 10:58:28 -0500 X-MC-Unique: lHUZM5_SNsKzIfdytcskqw-1 Received: by mail-ed1-f69.google.com with SMTP id k10-20020a50cb8a000000b00403c8326f2aso8929351edi.6 for ; Tue, 01 Feb 2022 07:58:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZypiyxpCcuEyM1ySNhbfCIbOxAuGxHr+z3CxNGHnfjY=; b=V/fFRIG+daCDqiZM7zyTgYZcOZzCdPogdbokMKWlREgw7gcq3FVHI96DMKNYP7RERl dFC5bncRDJ09yZwxdmntOiTbcL3dNstZ5ETi3VPpZVlxssOxg4SyttHo08aF1XoPhl/t 7+R90j3MsL0LbBSgYQI3sFZGAbD2mWQk4PRnuHCzC8EMVtujUhgKTzoFCqjsB04MJW/A p6VidP6Pn0iHKiWCXQi6JhpavBQOLraw1SXidTDQtsPw4zniRLEfhZQw14kB4GYbWShu kxQIDy4FePTYOLAuLdDtOGHi+Nn1uoKg7N/BHmvaF0+VzZ0pGe7i3YtRt30dZa/nz8+M DGKw== X-Gm-Message-State: AOAM531CMzRcJi5fdUxrgCc2OiXIsrDpxQWa82WymEzqQUJkjHgNk7l4 Wceg00xe4HA+BIh4gh4O2TRDdWMWHb/MbLegQtZdGp13aQqHO3ZCnom8VVO90p+pWiZ1N6hSq8h RLmpVOqDa9A2zOQYBpQ30wrW/H5GRr+VRYwNk X-Received: by 2002:a17:907:7412:: with SMTP id gj18mr20670572ejc.379.1643731089947; Tue, 01 Feb 2022 07:58:09 -0800 (PST) X-Received: by 2002:a17:907:7412:: with SMTP id gj18mr20670541ejc.379.1643731089374; Tue, 01 Feb 2022 07:58:09 -0800 (PST) MIME-Version: 1.0 References: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> <20220127194952.63033-2-Anna.Schumaker@Netapp.com> In-Reply-To: <20220127194952.63033-2-Anna.Schumaker@Netapp.com> From: David Wysochanski Date: Tue, 1 Feb 2022 10:57:31 -0500 Message-ID: Subject: Re: [PATCH v7 1/9] rpcctl: Add a rpcctl.py tool To: schumaker.anna@gmail.com Cc: "Dickson, Steve" , linux-nfs , Anna Schumaker Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Jan 27, 2022 at 2:50 PM wrote: > > From: Anna Schumaker > > This will be used to print and manipulate the sunrpc sysfs directory > files. Running without arguments prints both usage information and the > location of the sunrpc sysfs directory. > > Signed-off-by: Anna Schumaker > -- > v7: Check entire line for "sysfs" instead of just the start of the line > --- > tools/rpcctl/rpcctl.py | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > create mode 100755 tools/rpcctl/rpcctl.py > > diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py > new file mode 100755 > index 000000000000..9737ac4a9740 > --- /dev/null > +++ b/tools/rpcctl/rpcctl.py > @@ -0,0 +1,25 @@ > +#!/usr/bin/python3 > +import argparse > +import pathlib > +import sys > + > +with open("/proc/mounts", 'r') as f: > + 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) > + > +sunrpc = pathlib.Path(mount[0]) / "kernel" / "sunrpc" > +if not sunrpc.is_dir(): > + print("ERROR: sysfs does not have sunrpc directory") > + sys.exit(1) > + > +parser = argparse.ArgumentParser() > + > +def show_small_help(args): > + parser.print_usage() > + print("sunrpc dir:", sunrpc) > +parser.set_defaults(func=show_small_help) > + > +args = parser.parse_args() > +args.func(args) > -- > 2.35.0 > Might want to rework some of the directory related code to ensure you handle disappearing entries. Got Tracebacks (see below) while running a series of tests that would: - mount - run some IO - umount [root@dwysocha-fedora-node1 nfs-utils]# while true; do ./tools/rpcctl/rpcctl.py xprt; done | grep -B 5 -A 5 Traceback Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 112, in list_all xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 112, in xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] File "/usr/lib64/python3.10/pathlib.py", line 1032, in glob for p in selector.select_from(self): File "/usr/lib64/python3.10/pathlib.py", line 492, in _select_from for starting_point in self._iterate_directories(parent_path, is_dir, scandir): File "/usr/lib64/python3.10/pathlib.py", line 482, in _iterate_directories for p in self._iterate_directories(path, is_dir, scandir): File "/usr/lib64/python3.10/pathlib.py", line 471, in _iterate_directories with scandir(parent_path) as scandir_it: FileNotFoundError: [Errno 2] No such file or directory: '/sys/kernel/sunrpc/xprt-switches/switch-4' Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 112, in list_all xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 112, in xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] File "/usr/lib64/python3.10/pathlib.py", line 1032, in glob for p in selector.select_from(self): File "/usr/lib64/python3.10/pathlib.py", line 492, in _select_from for starting_point in self._iterate_directories(parent_path, is_dir, scandir): File "/usr/lib64/python3.10/pathlib.py", line 482, in _iterate_directories for p in self._iterate_directories(path, is_dir, scandir): File "/usr/lib64/python3.10/pathlib.py", line 471, in _iterate_directories with scandir(parent_path) as scandir_it: FileNotFoundError: [Errno 2] No such file or directory: '/sys/kernel/sunrpc/xprt-switches/switch-2' [root@dwysocha-fedora-node1 nfs-utils]# while true; do ./tools/rpcctl/rpcctl.py client; done | grep -B 10 -A 10 Traceback Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in list_all clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 195, in __init__ self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") File "/usr/lib64/python3.10/pathlib.py", line 1159, in readlink path = self._accessor.readlink(self) FileNotFoundError: [Errno 2] No such file or directory: '/sys/kernel/sunrpc/rpc-clients/clnt-3/switch' Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in list_all clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 195, in __init__ self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") File "/usr/lib64/python3.10/pathlib.py", line 1159, in readlink path = self._accessor.readlink(self) FileNotFoundError: [Errno 2] No such file or directory: '/sys/kernel/sunrpc/rpc-clients/clnt-7/switch' Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in list_all clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 195, in __init__ self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 148, in __init__ self.xprts = [ Xprt(p) for p in self.path.iterdir() if p.is_dir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 148, in self.xprts = [ Xprt(p) for p in self.path.iterdir() if p.is_dir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 49, in __init__ self.read_state() File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 81, in read_state self.state = ','.join(f.readline().split()[1:]) OSError: [Errno 19] No such device Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in list_all clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 195, in __init__ self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 148, in __init__ self.xprts = [ Xprt(p) for p in self.path.iterdir() if p.is_dir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 148, in self.xprts = [ Xprt(p) for p in self.path.iterdir() if p.is_dir() ] File "/usr/lib64/python3.10/pathlib.py", line 1015, in iterdir for name in self._accessor.listdir(self): FileNotFoundError: [Errno 2] No such file or directory: '/sys/kernel/sunrpc/rpc-clients/clnt-9/../../xprt-switches/switch-2' Traceback (most recent call last): File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 230, in args.func(args) File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in list_all clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 209, in clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] File "/mnt/build/nfs-utils/./tools/rpcctl/rpcctl.py", line 195, in __init__ self.switch = XprtSwitch(path / (path / "switch").readlink(), sep=",") File "/usr/lib64/python3.10/pathlib.py", line 1159, in readlink path = self._accessor.readlink(self) FileNotFoundError: [Errno 2] No such file or directory: '/sys/kernel/sunrpc/rpc-clients/clnt-5/switch' ^C