From patchwork Thu Oct 28 18:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 012A6C433FE for ; Thu, 28 Oct 2021 18:35:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D51CF60D43 for ; Thu, 28 Oct 2021 18:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229645AbhJ1Shv (ORCPT ); Thu, 28 Oct 2021 14:37:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbhJ1Shu (ORCPT ); Thu, 28 Oct 2021 14:37:50 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6874DC061570 for ; Thu, 28 Oct 2021 11:35:23 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id t40so6665194qtc.6 for ; Thu, 28 Oct 2021 11:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZVRoHY9JRFv/k1KUIzj+9BKZjG6smOlHa2LwVuVuuP4=; b=gQwQH/AWEZDGimIdAkVKMDnLdJMEQzzhkKVsX33YiJI6sFbImtyyb9mkpzNd9DgLI0 /PkxusnllDjyhIV0BraDWjb94KLot6iY3C3MTT+jHB7Zy+QaT2k304jYdoaR8yBlK9qk 1biq7YGPxMSyFRkD3ZJXYYKqZcRrAzuLBBDOiMKQxyROuMQNyJXBbbNz5kOjEoAks8f+ g6j0OI1o+E1NKX/lNMPvXC9g43PrpFDaxGX9OA8mzlzx9YMRXr/OQK+tH5CUw9zMPNSx 603f/LdXAsvHHNZzDnujyM56vI6QZZxpRIbN6KfbbJyeU1rhTVY4k0BR5lP6SJtky7Au uY8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZVRoHY9JRFv/k1KUIzj+9BKZjG6smOlHa2LwVuVuuP4=; b=G8JXrv/ZU4u1D94FFI+h/Y7GPnGmAGyUuMHRmTrR19UQvh2UyuRLE0T2FQVLWDm6oO xp5LEnqMNNY6+knRmFN/+k/e1SlbXYqbEGNLQKmVVi0/ncZLt4YloChKmsTLzNEP0/ut hKFtOna2EOO27GHRi+De28YCAYCL5CoZB3fdcbYmZM08TZUH+G9T4HK2EFTLHaDXMp7g pEirazkNAOZs7Em5O73X4BBSn/eKnkoW7y/TXJN8TsL4Nj7gtMsJXZmCt0dkKdIop1/i 8bj3MQJ3MqtzZrYTrGaulZkdWafN4uLalU9tdtRmTPNcXrrr9LNVYQ3MDThbjY1ocgZf ajFg== X-Gm-Message-State: AOAM530Fobaicoyyg5NstR4w3QBzUY4PhgHAim2GuIJwUC9z5iCkX6Br b+yfx29NDIGvoNBYgfPuQ3R3/dJgk1M= X-Google-Smtp-Source: ABdhPJw7YSuw2xSvY8lKs5ygRIsAEQgCtt8nVI/yIkODKrkHPZ0zhFLlH5A6iYLN+aw7ffZwwrbjRg== X-Received: by 2002:ac8:1e06:: with SMTP id n6mr6523660qtl.365.1635446122323; Thu, 28 Oct 2021 11:35:22 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:22 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 1/9] rpcctl: Add a rpcctl.py tool Date: Thu, 28 Oct 2021 14:35:11 -0400 Message-Id: <20211028183519.160772-2-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- .gitignore | 2 ++ tools/rpcctl/rpcctl.py | 13 +++++++++++++ tools/rpcctl/sysfs.py | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 tools/rpcctl/rpcctl.py create mode 100644 tools/rpcctl/sysfs.py diff --git a/.gitignore b/.gitignore index c89d1cd2583d..a476bd20bc3b 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,5 @@ systemd/rpc-gssd.service cscope.* # generic editor backup et al *~ +# python bytecode +__pycache__ diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py new file mode 100755 index 000000000000..8ff59ea9e81b --- /dev/null +++ b/tools/rpcctl/rpcctl.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +import argparse +import sysfs + +parser = argparse.ArgumentParser() + +def show_small_help(args): + parser.print_usage() + print("sunrpc dir:", sysfs.SUNRPC) +parser.set_defaults(func=show_small_help) + +args = parser.parse_args() +args.func(args) diff --git a/tools/rpcctl/sysfs.py b/tools/rpcctl/sysfs.py new file mode 100644 index 000000000000..c9d477063585 --- /dev/null +++ b/tools/rpcctl/sysfs.py @@ -0,0 +1,19 @@ +import pathlib +import re +import sys + +MOUNT = None +with open("/proc/mounts", 'r') as f: + for line in f: + if re.search("^sys ", line): + MOUNT = line.split()[1] + break + +if MOUNT == None: + print("ERROR: sysfs is not mounted") + sys.exit(1) + +SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" +if not SUNRPC.is_dir(): + print("ERROR: sysfs does not have sunrpc directory") + sys.exit(1) From patchwork Thu Oct 28 18:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE716C433FE for ; Thu, 28 Oct 2021 18:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7C9D61040 for ; Thu, 28 Oct 2021 18:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230466AbhJ1Shw (ORCPT ); Thu, 28 Oct 2021 14:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhJ1Shv (ORCPT ); Thu, 28 Oct 2021 14:37:51 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B4F8C061570 for ; Thu, 28 Oct 2021 11:35:24 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id d6so4695500qvb.3 for ; Thu, 28 Oct 2021 11:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1fl2PgIKZ7d+0Ni8x29K1OlM/fBaw+yfeZ9qVart6y0=; b=XGUDpUJA7FsyAmKiUuqDjL1hdQA0ndiaDQ4FpWcPuHde6iyaWFGRltcIEZwu1IOm/U LxGP4v2X1WolBi61tNDrltvMfC9jcuxzXBNdEJWNed3WVIkL2YpTLPeehjOU2uTujhok YR8lPjx2o0gHlCLqHNkkBYBe8XOvFLLoAj1OgEm1WBs1z13iA1rHMHVlGOEUKxNh1HjM rAY41C+khpLW8g6hw4ol0PWW8OJPX7k3aRoiZewgoG9Yy47Ovxe4+xDqAw0+I412WSTm h/vAuGIVZGS150XST5YMgzbXCBlY9xVTroNeRdazvEAFf4u8YU/HhVHEBl7hSytXbIrs rqdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1fl2PgIKZ7d+0Ni8x29K1OlM/fBaw+yfeZ9qVart6y0=; b=7JvfsqmMlLG6/+f7mKxBkT7dajPCumCMZv1uopo2oI2EbcO86U13EWFxHqqgZjjTa7 d+1I4HHvyelEMGszCxdMQPeiDzRCP3Ey4Ynye1stUxfyWbtTuqFNTYFT7tGxHh8oIOkt uDYnrWfpBJUFzx0UHWaPXGPAslT5veBgGb9WWFtVPzzqG4dL2ncuN3KNHzKAAnE42aoa N9KQw4NNnyItT67KMf6JbY9KKMgnombRgQhaPi05us2t88F1xdzivJXSdWbSE19+PonF YSIdJFyn1v9+GA/dyMVD58ntpThvbeLCpNu5+0vwozo0pbH0Ovz63J2EZCVpfS718Pzf 1wgQ== X-Gm-Message-State: AOAM531joYa0LW158/ugT73gC8eSAOHPMa03YBm8fHmEksOCrUiGu58E /AzLH26xfs5UfB7c8L602x4= X-Google-Smtp-Source: ABdhPJye8XDDOLQi//xlp+2/xgCWp5HuiH7VJ84M8CjXL6PQqSaf1S+0Lxq3KJX7aa1p4U+8jYyZLw== X-Received: by 2002:a05:6214:226e:: with SMTP id gs14mr5860713qvb.8.1635446123108; Thu, 28 Oct 2021 11:35:23 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:22 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 2/9] rpcctl: Add a command for printing xprt switch information Date: Thu, 28 Oct 2021 14:35:12 -0400 Message-Id: <20211028183519.160772-3-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker This combines the information found in xprt_switch_info with a subset of the information found in each xprt subdirectory Signed-off-by: Anna Schumaker --- v5: Clean up how the XprtSwitch __str__() function works Rename the subcommand to simply "switch" --- tools/rpcctl/rpcctl.py | 6 ++++++ tools/rpcctl/switch.py | 35 +++++++++++++++++++++++++++++++++++ tools/rpcctl/sysfs.py | 18 ++++++++++++++++++ tools/rpcctl/xprt.py | 14 ++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 tools/rpcctl/switch.py create mode 100644 tools/rpcctl/xprt.py diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 8ff59ea9e81b..90efcbed7ac8 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -9,5 +9,11 @@ def show_small_help(args): print("sunrpc dir:", sysfs.SUNRPC) parser.set_defaults(func=show_small_help) + +import switch +subparser = parser.add_subparsers(title="commands") +switch.add_command(subparser) + + args = parser.parse_args() args.func(args) diff --git a/tools/rpcctl/switch.py b/tools/rpcctl/switch.py new file mode 100644 index 000000000000..c96e70b7710f --- /dev/null +++ b/tools/rpcctl/switch.py @@ -0,0 +1,35 @@ +import sysfs +import xprt + +class XprtSwitch: + def __init__(self, path): + self.path = path + self.id = int(path.stem.split("-")[1]) + self.info = sysfs.read_info_file(path / "xprt_switch_info") + + self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] + self.xprts.sort() + + def __lt__(self, rhs): + return self.path < rhs.path + + def __str__(self): + switch = f"switch {self.id}: " \ + 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 list_xprt_switches(args): + switches = [ XprtSwitch(f) for f in (sysfs.SUNRPC / "xprt-switches").iterdir() ] + switches.sort() + for xs in switches: + if args.id == None or xs.id == args.id[0]: + print(xs) + +def add_command(subparser): + parser = subparser.add_parser("switch", help="Commands for xprt switches") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") + parser.set_defaults(func=list_xprt_switches) diff --git a/tools/rpcctl/sysfs.py b/tools/rpcctl/sysfs.py index c9d477063585..c05d2d591175 100644 --- a/tools/rpcctl/sysfs.py +++ b/tools/rpcctl/sysfs.py @@ -1,3 +1,4 @@ +import collections import pathlib import re import sys @@ -17,3 +18,20 @@ SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" 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: + return f.readline().strip() + except: + return "(enoent)" + +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 }) + finally: + return res diff --git a/tools/rpcctl/xprt.py b/tools/rpcctl/xprt.py new file mode 100644 index 000000000000..62859a23ea4d --- /dev/null +++ b/tools/rpcctl/xprt.py @@ -0,0 +1,14 @@ +import sysfs + +class Xprt: + def __init__(self, path): + self.path = path + self.id = int(path.stem.split("-")[1]) + self.type = path.stem.split("-")[2] + self.dstaddr = sysfs.read_addr_file(path / "dstaddr") + + def __lt__(self, rhs): + return self.id < rhs.id + + def small_str(self): + return f"xprt {self.id}: {self.type}, {self.dstaddr}" From patchwork Thu Oct 28 18:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DF23C433F5 for ; Thu, 28 Oct 2021 18:35:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3BB360D43 for ; Thu, 28 Oct 2021 18:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231151AbhJ1Shz (ORCPT ); Thu, 28 Oct 2021 14:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbhJ1Shx (ORCPT ); Thu, 28 Oct 2021 14:37:53 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD2CC061570 for ; Thu, 28 Oct 2021 11:35:25 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id s1so5291249qta.13 for ; Thu, 28 Oct 2021 11:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fx8Eu7TST74xkhEXu4GKTc1eYjHji/4D1Q6XRZtrAp8=; b=GhbIkWYKXzrtLqoeqz9YET/bUgCw2ZxhSDj8/ExuHGF8fe1hleOTM5kfJOhON6eapl V+Q5WMs3VWdMom1zY/cKwVTnbtlfqou0h8d4vN1gtuxpPv9Xp2TUSYTLANphtKMyWglx rMMFCn+sU7RdHyETGtyLw6qAn7TR5sxrlfWgGKtKbxmPAk45XHSL220rlEdGHRtpST5z ChZOdRU90pX4bI7mx+rWT3NnJ5tguS3bH4E3PYLPyjnFsxtJ82q1BaxMSSdvTmrYR/fc 9MBKrHNSXwwQi5DnrXNQIb6ycsZ4JgbtGTidboHcRul8EpnXW8EvTqA81VhmrwXvgSyc 1UYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Fx8Eu7TST74xkhEXu4GKTc1eYjHji/4D1Q6XRZtrAp8=; b=bY8aHCzKwKWRkCX45sbjvm5Pl/GD8ICwgmz39zOscdzwEaOt8bkSqx9bGPErhlXjgR C1GmLNbPBqkftQukSIskJWo+I01OTQ+92laBqiPFT4g9Nl6UU5ies0r5vhs4jB0Dyxee nBm4eg0h09kxxvuf7pBwRk6m/aZTYvlxMNu4lxTEoUDxnV1sgbeu/mg3b7lHoAkxzsf4 llS2QN6EAPdG9p9XRLjkifZ/FX7pNTvJTFE/Qn/toweyydrVWpwi9faEXk7TCzVS2Fjv 44ZYM/G5E8gUw9ZoGKRXPg0azKJV2voilddoVtk+GzPsFzM5r7MZXM8tByqv5umG6h8z ooYA== X-Gm-Message-State: AOAM530W8x2GMIG12LTHN/CdZ7L61dK0nq13u/yyj35n8vW9wJWZzQuD sBrFKU5ftaNeCYqMADjC1dCM8w/zy+s= X-Google-Smtp-Source: ABdhPJx7P1JlIXdaf8OZrElTZcucoz8H9s6Ixk0jeqRb3Vof9JdWQQD09XIDtfjfmbH4EnfJ4pFmRA== X-Received: by 2002:a05:622a:186:: with SMTP id s6mr6436056qtw.323.1635446124155; Thu, 28 Oct 2021 11:35:24 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:23 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 3/9] rpcctl: Add a command for printing individual xprts Date: Thu, 28 Oct 2021 14:35:13 -0400 Message-Id: <20211028183519.160772-4-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker This shows more detailed information than what is presented with xprt switches. I take the chance to add a main-export indicator to the small_str() used when printing out xprt-switches. Signed-off-by: Anna Schumaker --- v5: Clean up how the Xprt __str__() function works --- tools/rpcctl/rpcctl.py | 2 ++ tools/rpcctl/xprt.py | 43 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 90efcbed7ac8..dfad6ac08fa0 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -11,8 +11,10 @@ parser.set_defaults(func=show_small_help) import switch +import xprt subparser = parser.add_subparsers(title="commands") switch.add_command(subparser) +xprt.add_command(subparser) args = parser.parse_args() diff --git a/tools/rpcctl/xprt.py b/tools/rpcctl/xprt.py index 62859a23ea4d..f8c8110eeed6 100644 --- a/tools/rpcctl/xprt.py +++ b/tools/rpcctl/xprt.py @@ -5,10 +5,51 @@ class Xprt: self.path = path self.id = int(path.stem.split("-")[1]) self.type = path.stem.split("-")[2] + self.info = sysfs.read_info_file(path / "xprt_info") self.dstaddr = sysfs.read_addr_file(path / "dstaddr") + self.srcaddr = sysfs.read_addr_file(path / "srcaddr") + + with open(path / "xprt_state") as f: + self.state = ','.join(f.readline().split()[1:]) def __lt__(self, rhs): return self.id < rhs.id + def _xprt(self): + main = ", main" if self.info.get("main_xprt") else "" + return f"xprt {self.id}: {self.type}, {self.dstaddr}, " \ + f"port {self.info['dst_port']}, state <{self.state}>{main}" + + def _src_reqs(self): + return f" Source: {self.srcaddr}, port {self.info['src_port']}, " \ + 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']}" + + 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']}" + + def __str__(self): + return "\n".join([self._xprt(), self._src_reqs(), + self._cong_slots(), self._queues() ]) + def small_str(self): - return f"xprt {self.id}: {self.type}, {self.dstaddr}" + main = " [main]" if self.info.get("main_xprt") else "" + return f"xprt {self.id}: {self.type}, {self.dstaddr}{main}" + + +def list_xprts(args): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + xprts.sort() + for xprt in xprts: + if args.id == None or xprt.id == args.id[0]: + print(xprt) + +def add_command(subparser): + parser = subparser.add_parser("xprt", help="Commands for individual xprts") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") + parser.set_defaults(func=list_xprts) From patchwork Thu Oct 28 18:35:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BA5EC433EF for ; Thu, 28 Oct 2021 18:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13C2160D43 for ; Thu, 28 Oct 2021 18:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbhJ1Sh4 (ORCPT ); Thu, 28 Oct 2021 14:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhJ1Shx (ORCPT ); Thu, 28 Oct 2021 14:37:53 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F40C061745 for ; Thu, 28 Oct 2021 11:35:26 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id h14so5880933qtb.3 for ; Thu, 28 Oct 2021 11:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sh2Ri79lVNQOJYQb4TPc6Y1GVYSVmFvfd7BVg9tSaF8=; b=hGyeDI2hNNBvb6iRedc/Y8s0oLFqL2I7xJ9/cqf17iIdfyqs3/kRIWOTUiKy/PcZVy 6TcHKO8lx8gu02p+3mhLO5+ufnXjrf27HyKWOkR+Ozeqt2Btt5i3vE1FvEtWgyaABpX4 iMYeK1vXAvIDadcz3W8daf0Tz2PHZQdPDUHqRZa3JEIw6jpMRjPurirZ1W1fqkl2IdG2 BnKYV9UedjQ+BnJMJ1OmB9uJ12qFLFRJqPj/ocaGyCbuPSLjSZbzujyBwTIICKl1iqlu SEf/mTkmOvvz/SdKdtrz+9Ke8UQiQnwqKcdWyfHMf7J925r793jiEtchpx1y/P8rzHGG e/Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Sh2Ri79lVNQOJYQb4TPc6Y1GVYSVmFvfd7BVg9tSaF8=; b=lXRxFYe/mm42b4WjaAHcF+OhIdFh4yKCHu+KKjixGQQxfk1P/PzFQ6OeEwiJDdsyIB K1q249LmuUrFRbWoMu+oYtzPbzSp83VUaN0biqGlEa4mveXOM82H7eeL3uHhjfCwfN4W rqLxRl/lmDW+jfab2p01IemfTweka17Uqn23wJT2pLiwodIYYxFbnLmNfTkCf3zzqyXv o/l9fFym43DL0R0TIINomaxFCpxvcaBBAoe4mSMVqoiyHU4oNmki3z3vgEgR4gsfi8Wn n7V6M2qvL1KP5xsPLxPH3A7Wsbk4D4iZn1qDquFA8m1yE9EoEmPx4k5E2pu4QmNciigP PfPA== X-Gm-Message-State: AOAM5331Ro/CVLCm/bebzYa4bZgP1U5mR/nZyZ2oYq7oSB6xGz9h1EE/ YglHfZf0PmhOgplRU+wEwUNXdOIRikk= X-Google-Smtp-Source: ABdhPJziKYdA0/IL0LASn96ht1I0az/IXtea9XGpBuWgjF0gzse10coueiO3YzYlQECfDdB3LmDUUA== X-Received: by 2002:ac8:1ca:: with SMTP id b10mr6403008qtg.327.1635446125076; Thu, 28 Oct 2021 11:35:25 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:24 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 4/9] rpcctl: Add a command for printing rpc client information Date: Thu, 28 Oct 2021 14:35:14 -0400 Message-Id: <20211028183519.160772-5-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker It's mostly the same information as with xprt-switches, except with rpc-client id prepended to the first line. Signed-off-by: Anna Schumaker --- v5: Clean up how the RpcClient __str__() function works Rename the subcommand to simply "client" --- tools/rpcctl/client.py | 27 +++++++++++++++++++++++++++ tools/rpcctl/rpcctl.py | 2 ++ tools/rpcctl/switch.py | 5 +++-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tools/rpcctl/client.py diff --git a/tools/rpcctl/client.py b/tools/rpcctl/client.py new file mode 100644 index 000000000000..42c9bee0d2d8 --- /dev/null +++ b/tools/rpcctl/client.py @@ -0,0 +1,27 @@ +import sysfs +import switch + +class RpcClient: + def __init__(self, path): + self.path = path + self.id = int(path.stem.split("-")[1]) + self.switch = switch.XprtSwitch(path / (path / "switch").readlink(), sep=",") + + def __lt__(self, rhs): + return self.id < rhs.id + + def __str__(self): + return f"client {self.id}: {self.switch}" + + +def list_rpc_clients(args): + clients = [ RpcClient(f) for f in (sysfs.SUNRPC / "rpc-clients").iterdir() ] + clients.sort() + for client in clients: + if args.id == None or client.id == args.id[0]: + print(client) + +def add_command(subparser): + parser = subparser.add_parser("client", help="Commands for rpc clients") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific client to show") + parser.set_defaults(func=list_rpc_clients) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index dfad6ac08fa0..e2172cdfa4c1 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -10,9 +10,11 @@ def show_small_help(args): parser.set_defaults(func=show_small_help) +import client import switch import xprt subparser = parser.add_subparsers(title="commands") +client.add_command(subparser) switch.add_command(subparser) xprt.add_command(subparser) diff --git a/tools/rpcctl/switch.py b/tools/rpcctl/switch.py index c96e70b7710f..497ee8b1923c 100644 --- a/tools/rpcctl/switch.py +++ b/tools/rpcctl/switch.py @@ -2,10 +2,11 @@ import sysfs import xprt class XprtSwitch: - def __init__(self, path): + def __init__(self, path, sep=":"): self.path = path self.id = int(path.stem.split("-")[1]) self.info = sysfs.read_info_file(path / "xprt_switch_info") + self.sep = sep self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] self.xprts.sort() @@ -14,7 +15,7 @@ class XprtSwitch: return self.path < rhs.path def __str__(self): - switch = f"switch {self.id}: " \ + switch = f"switch {self.id}{self.sep} " \ f"xprts {self.info['num_xprts']}, " \ f"active {self.info['num_active']}, " \ f"queue {self.info['queue_len']}" From patchwork Thu Oct 28 18:35:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FBB9C433FE for ; Thu, 28 Oct 2021 18:35:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81F1261040 for ; Thu, 28 Oct 2021 18:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231140AbhJ1Shz (ORCPT ); Thu, 28 Oct 2021 14:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbhJ1Shy (ORCPT ); Thu, 28 Oct 2021 14:37:54 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A6F3C061767 for ; Thu, 28 Oct 2021 11:35:27 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id i9so6282964qki.3 for ; Thu, 28 Oct 2021 11:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P96dwD493nRuMBr4TlxvNv4S0sXk48KeDkmUiAdO3Kg=; b=Xb8IgEz3Shr4Wqa1rcWGedbEXIdRCKt+LWieHT44pMDohsSRAvuAw55ccbU8dtW22G V/NFgOVRvARbYozM7YvhHfV1JtBmMYYTNfDt0hD9PJWi41l9JJR9fult+Oya/KKI6VY8 TvyXYQaPvjYIB7H4YhbWtsVfUFA7SE69t8+2Y6qJyEYHKDyoNsfzH3huZxv5SxAcOzaO Uz6zVVF7RV2/34ylhIuRPezVNi5Ydx6XWZItKFTP6PBh2/9CKRHqPhrVmzmp6Lje1n7N vwIzMeaOZ1YPsaFNysCom4wWOOYqRBO9LuqEVUapK1qhDW+pW4/z9BL/7B5tQfe5EXhK fwkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=P96dwD493nRuMBr4TlxvNv4S0sXk48KeDkmUiAdO3Kg=; b=O5szaZY++veVY1prcyxqWQ0qvqFNM7wbWzSeWJvmJAXsekRjN6ayUvnNG4Q7B7yQNW yh69+wLeUF/+z/7g+j95i1SB2vF3pH+zgDj+urPDiri4WYS7UWhPHummNBomsy3gIodi e4WitdwAHGp4cK3X7PXijgLl/gO+Cgv1HMv0wS1jFOJ1WcCe49GObAzCYa1BVdII305S 3mG4hAV3xp8UDVkuq6ymq66NdfbrKNb4a8KaGWylWfDdR13HcW9txiF9hqgcyYgYwfI3 JVPVf5m3y54newqgRSgukbEvXl+QdDVgnIDhMj+2LiQQFk1gjRnK158ePSETlRMPL1gY sIXw== X-Gm-Message-State: AOAM533mNvd+HtmtMmw+FnS40Tap9J3EUwKWZANf5X6gsEdErOU9d5qf UnxzUs0lHHzChn6zyO1CPPY= X-Google-Smtp-Source: ABdhPJwwOBWE2II6D5Wx5Y08cmT81WJWFXL/KMvk33C6Lv3YKJbFqaoacajoDKGb9FzevsoR/bgciA== X-Received: by 2002:ae9:ef0d:: with SMTP id d13mr5043757qkg.290.1635446126220; Thu, 28 Oct 2021 11:35:26 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:25 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 5/9] rpcctl: Add a command for changing xprt dstaddr Date: Thu, 28 Oct 2021 14:35:15 -0400 Message-Id: <20211028183519.160772-6-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Using the socket module for dns resolution Signed-off-by: Anna Schumaker --- tools/rpcctl/sysfs.py | 5 +++++ tools/rpcctl/xprt.py | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/rpcctl/sysfs.py b/tools/rpcctl/sysfs.py index c05d2d591175..27726c56bb80 100644 --- a/tools/rpcctl/sysfs.py +++ b/tools/rpcctl/sysfs.py @@ -27,6 +27,11 @@ 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: diff --git a/tools/rpcctl/xprt.py b/tools/rpcctl/xprt.py index f8c8110eeed6..1201140ce5af 100644 --- a/tools/rpcctl/xprt.py +++ b/tools/rpcctl/xprt.py @@ -1,3 +1,4 @@ +import socket import sysfs class Xprt: @@ -41,6 +42,10 @@ class Xprt: main = " [main]" if self.info.get("main_xprt") else "" return f"xprt {self.id}: {self.type}, {self.dstaddr}{main}" + def set_dstaddr(self, newaddr): + resolved = socket.gethostbyname(newaddr) + self.dstaddr = sysfs.write_addr_file(self.path / "dstaddr", resolved) + def list_xprts(args): xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] @@ -49,7 +54,28 @@ def list_xprts(args): if args.id == None or xprt.id == args.id[0]: print(xprt) +def get_xprt(id): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + for xprt in xprts: + if xprt.id == id: + return xprt + +def set_xprt_property(args): + xprt = get_xprt(args.id[0]) + try: + if args.dstaddr != None: + xprt.set_dstaddr(args.dstaddr[0]) + print(xprt) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") parser.set_defaults(func=list_xprts) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of a specific xprt to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_property) From patchwork Thu Oct 28 18:35:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC39C4332F for ; Thu, 28 Oct 2021 18:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98A2E610C8 for ; Thu, 28 Oct 2021 18:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231163AbhJ1Sh4 (ORCPT ); Thu, 28 Oct 2021 14:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231160AbhJ1Shz (ORCPT ); Thu, 28 Oct 2021 14:37:55 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439B9C061570 for ; Thu, 28 Oct 2021 11:35:28 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id s1so5291406qta.13 for ; Thu, 28 Oct 2021 11:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BoJQS8T5pA3TgBjObqAge0sFAZ3k/4sBTrxF1sXiu+o=; b=Q7UiyARzm6hIZ2Q1nhY26CAc/oE4RklMNzU39Epvl8+WSyK8gS97TdnDO3GX7qrwez 9VMrPSxys2pQHReARYr9jWPxnjCUaG4qZ+RUsPHgcF9HkPZPlwRA3dYoro9aFV/BpPHR mP1pgUl8gjctOMcT3lw7BRb0wvPmHZQdv5PQc/G7tegf8LPwozv9hBBdwabXBA9+RsKm xiZ49p1MYFaaCeRUvDwo5JM4Yl/vjy5FZEDikF/JuZvTHr5TNf1u3qwJtZf4CXYge1/y hjL9fOgovmKSaxq/mkE8MtRPPmg/Fj8kCirjokkL6Oo+5GH0sUGwFmhKOrKDoLKaYAzi QBFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BoJQS8T5pA3TgBjObqAge0sFAZ3k/4sBTrxF1sXiu+o=; b=xHzb3Ec+lkz7u3MYhRtWUQW1F1RxLzwv1c8q0Jnsu8Jh1sFDhuOGh3Vdyja7R7/tZ9 HcW4KwRKNckmPxbwsRg7gvTow/SaP9NhvADOUdVR5nrIeyMh1zDdZYTfhMeR6a5MRum4 L9AgaHBeSFTb+jQRKWvv8RB79M0QKqlR8oKSTRmpEFCjQmaL4nrhGmvgG/1GTTj1jgyB LkMbj3xxcQkyBkZX1PCPaJR4plM/q+axuu/u3SZk7mOmrDl950jpVkfcQxFHr+6CCFfo bv8zWclRjXul979bEL0p9OvjGsYPOp7zTZrh46BDkBCTSB4laX+5qJNKwGj4PeXEcSBD ubUQ== X-Gm-Message-State: AOAM532tmFd0BX/rbCZ+NSDKAPj22q6PH0qjliWU84P/HWqDehjD2YgB 9EQ8ZFxbY3dJacd1LpKhitE5UooSkuc= X-Google-Smtp-Source: ABdhPJxFXjLf74G3XY5cS5EYeQvIV6+6UXMq3VTIGRLWgjuBKRhUKrkvZhFUZMhoAPfrTAegIjY+dA== X-Received: by 2002:ac8:7f8c:: with SMTP id z12mr6581937qtj.292.1635446127264; Thu, 28 Oct 2021 11:35:27 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:26 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 6/9] rpcctl: Add a command for changing xprt switch dstaddrs Date: Thu, 28 Oct 2021 14:35:16 -0400 Message-Id: <20211028183519.160772-7-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker This is basically the same as for xprts, but it iterates through all xprts attached to the switch to apply the new address. Signed-off-by: Anna Schumaker --- tools/rpcctl/switch.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/rpcctl/switch.py b/tools/rpcctl/switch.py index 497ee8b1923c..b1b287bb6578 100644 --- a/tools/rpcctl/switch.py +++ b/tools/rpcctl/switch.py @@ -30,7 +30,22 @@ def list_xprt_switches(args): if args.id == None or xs.id == args.id[0]: print(xs) +def set_xprt_switch_property(args): + switch = XprtSwitch(sysfs.SUNRPC / "xprt-switches" / f"switch-{args.id[0]}") + try: + for xprt in switch.xprts: + xprt.set_dstaddr(args.dstaddr[0]) + print(switch) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("switch", help="Commands for xprt switches") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") parser.set_defaults(func=list_xprt_switches) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt switch property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of an xprt-switch to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_switch_property) From patchwork Thu Oct 28 18:35:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F6EFC433F5 for ; Thu, 28 Oct 2021 18:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB5C961040 for ; Thu, 28 Oct 2021 18:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231169AbhJ1Sh5 (ORCPT ); Thu, 28 Oct 2021 14:37:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhJ1Sh4 (ORCPT ); Thu, 28 Oct 2021 14:37:56 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23E31C061570 for ; Thu, 28 Oct 2021 11:35:29 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id h20so6757508qko.13 for ; Thu, 28 Oct 2021 11:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pW5tXAaUICrJYuOC0zQmWxczkFbo232hvbVpGkDJMBo=; b=Ix4Xcdu8u4q9RNOhQXq7WcB7YjAHdxg+riugvpEjI7OVrlyBeNrTrT7jh3F0cZxEC5 wuW0WtB/b1CJw8ba5BIFjnxq3J3Up8/2DnYUl4VghF12MP2vaslsmxKJxgj55LKR9j2F XfL+HjTRHMUL5FHk0toewTtpVLFNLTAwU1ls8lMFhKiKtKd4MVLk0WSaqY9o4Ojn9Xss HNEbwYvz1KMmCmAlQDbAl0eXZsmRtaC7rxCrmHJDd/PD/9eqgA2W9PU0Jtvv1l3fMzck mI+G2HuxCJYCy7P2OFQuo6HRsm/v8P7V9+RMwChCRpqqIGFqyGiNmUm603ZIO72SLHeD 48mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pW5tXAaUICrJYuOC0zQmWxczkFbo232hvbVpGkDJMBo=; b=Gl/YJt+0JJWXC9qe7aL9MRve/vUM/aNNzJk5GpRnrqtVLDbklIjwuMkfbrHZxFdxIB B94BizFqaqZ6ORpkKUhxXGpFkeq2/ypa5fpQbWXGDCGxINwOb+/mmA+tJUQkYNujkaqs m2jxOn1GYhikk0PfavmK0GD2XvGxADBuPCcTS1ecsMwIx0mXFhtLe8XxaWrUTXo8UdVN RhZxrvWCuCjVX9kBIQRXecRtwk1xctqnzlD/skIm9ij1lb8pf0YUo/+2VsGB9zurE92w Pa4NsyWqFBpQlKant/3beYvSQ5IAqVMUB0UjBNiXl9WFvX6fx7scik/IGX+hDyUxi2fo s4kw== X-Gm-Message-State: AOAM5334+/l3tWzaGhR2MDU64yEHVCdOek2sSu1NWn+3krusawJRx04Y I0eHDX4yFUtEtmBZk+uXm5Q= X-Google-Smtp-Source: ABdhPJyfMwavi2EAKfj8gMDm0/TypPmrkWv7WUbPditw94VeG3WNScc2kTDUs3SFn7EAuCD15Jwbqg== X-Received: by 2002:a05:620a:578:: with SMTP id p24mr5142990qkp.237.1635446128096; Thu, 28 Oct 2021 11:35:28 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:27 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 7/9] rpcctl: Add a command for changing xprt state Date: Thu, 28 Oct 2021 14:35:17 -0400 Message-Id: <20211028183519.160772-8-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker We can set it offline or online, or we can remove an xprt. The kernel only supports removing offlined transports, so we make sure to set the state to "offline" before sending the remove command. Signed-off-by: Anna Schumaker --- tools/rpcctl/xprt.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/rpcctl/xprt.py b/tools/rpcctl/xprt.py index 1201140ce5af..92db756c8374 100644 --- a/tools/rpcctl/xprt.py +++ b/tools/rpcctl/xprt.py @@ -9,9 +9,7 @@ class Xprt: self.info = sysfs.read_info_file(path / "xprt_info") self.dstaddr = sysfs.read_addr_file(path / "dstaddr") self.srcaddr = sysfs.read_addr_file(path / "srcaddr") - - with open(path / "xprt_state") as f: - self.state = ','.join(f.readline().split()[1:]) + self.read_state() def __lt__(self, rhs): return self.id < rhs.id @@ -35,9 +33,16 @@ class Xprt: f"backlog {self.info['backlog_q_len']}, tasks {self.info['tasks_queuelen']}" def __str__(self): + if not self.path.exists(): + return f"xprt {self.id}: has been removed" % self.id return "\n".join([self._xprt(), self._src_reqs(), self._cong_slots(), self._queues() ]) + def read_state(self): + if self.path.exists(): + with open(self.path / "xprt_state") as f: + self.state = ','.join(f.readline().split()[1:]) + def small_str(self): main = " [main]" if self.info.get("main_xprt") else "" return f"xprt {self.id}: {self.type}, {self.dstaddr}{main}" @@ -46,6 +51,11 @@ class Xprt: resolved = socket.gethostbyname(newaddr) self.dstaddr = sysfs.write_addr_file(self.path / "dstaddr", resolved) + def set_state(self, state): + with open(self.path / "xprt_state", 'w') as f: + f.write(state) + self.read_state() + def list_xprts(args): xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] @@ -65,6 +75,13 @@ def set_xprt_property(args): try: if args.dstaddr != None: xprt.set_dstaddr(args.dstaddr[0]) + if args.offline: + xprt.set_state("offline") + elif args.online: + xprt.set_state("online") + elif args.remove: + xprt.set_state("offline") + xprt.set_state("remove") print(xprt) except Exception as e: print(e) @@ -78,4 +95,7 @@ def add_command(subparser): parser = subparser.add_parser("set", help="Set an xprt property") parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of a specific xprt to modify") parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.add_argument("--offline", action="store_true", help="Set an xprt offline") + parser.add_argument("--online", action="store_true", help="Set an offline xprt back online") + parser.add_argument("--remove", action="store_true", help="Remove an xprt") parser.set_defaults(func=set_xprt_property) From patchwork Thu Oct 28 18:35:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55AABC433EF for ; Thu, 28 Oct 2021 18:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30C3361040 for ; Thu, 28 Oct 2021 18:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbhJ1Sh6 (ORCPT ); Thu, 28 Oct 2021 14:37:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhJ1Sh5 (ORCPT ); Thu, 28 Oct 2021 14:37:57 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200CDC061570 for ; Thu, 28 Oct 2021 11:35:30 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id x123so6783073qke.7 for ; Thu, 28 Oct 2021 11:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BNF21b7o9pVNnDZqS+hsA6oGp6Q443tS/9+eQ33iVAg=; b=H7Ynb4vyBnPCPnciZXnf5C5iEd9GCVhF6LvGwUHGM00if6IMoz/KPOQinC4W24FwDA TCBwE8K5URDkxBtn53WQLHRNJbISgZ+1iBF2Lg2VYN3f0WP95dpfEZ7Td/LxSpfWXhLc 6TDtCBNek4NxDGRRyw4UYpv2125SypiLbx21g/OHTR2Qe9qfBPXaWmYr4xUJjaR4DQXR IK47afifxFtX9Fk4vy2us7LnCIKac4TSr6Islc4xxaP0CtTMK+Pt4Bcxj5rZsGUtzfce l7I1Si/V8nTPnS0JySCPQNFGuOy1DfJ24mprqXaP5Lnsegdp2oGX0Ge0bp8wOzXbv5p1 2hCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BNF21b7o9pVNnDZqS+hsA6oGp6Q443tS/9+eQ33iVAg=; b=MXI8qH6hi5HNCRzJlSvFXFd8WkaUM3due24lsqVDmv0LdP7fAyoaAhgUL52r/4SUsy eTiYSUbiyJAGGp/+29fysm93h+id+k71TnvpDJ+CtuK9e8iKI6kbDHDF92Caz/O3lPlp SI7qRef4eGh1LfpU2y8IZH3wRlyXCnYkH3DXi4P4uGmz2NOCOsaTCHEYVbuTkqAABG2r P+HjMP8Hsna/2En4u8bv9jWNAZ4o7RBx5DI2JPvN2VVZZ4QI7SunXyRMw7FztTfcevDo nhx/H6vvV451WV1D9z/NIq/34TMk4xGVbpSCpTAvp9QR4j+WILKkbMSchz6fawy6mOBG lxKQ== X-Gm-Message-State: AOAM533pw7Ta+2I1sul6I+o1Sy9H3yp0zjAhpWWhN/QRrjCM07Q/C3k2 7E7DVGLs891ZweU+lKuAQGAFDlcTc0Y= X-Google-Smtp-Source: ABdhPJyb6g/7pnmvhzhC+kyZJ2bJjNfGLNSsto73AOg73bbQsNS0vNKd6DU+Vw1zFDE5RVRcm5jk8A== X-Received: by 2002:a37:9a88:: with SMTP id c130mr5205606qke.494.1635446129050; Thu, 28 Oct 2021 11:35:29 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:28 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 8/9] rpcctl: Add a man page Date: Thu, 28 Oct 2021 14:35:18 -0400 Message-Id: <20211028183519.160772-9-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Signed-off-by: Anna Schumaker --- tools/rpcctl/rpcctl.man | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tools/rpcctl/rpcctl.man diff --git a/tools/rpcctl/rpcctl.man b/tools/rpcctl/rpcctl.man new file mode 100644 index 000000000000..5da608aa1907 --- /dev/null +++ b/tools/rpcctl/rpcctl.man @@ -0,0 +1,88 @@ +.\" +.\" rpcctl(8) +.\" +.TH rpcctl 8 "22 Oct 2021" +.SH NAME +rpcctl \- Displays SunRPC connection information +.SH SYNOPSIS +.B rpcctl +.RB [ \-h | \-\-help ] +.P +.B rpcctl client +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.P +.B rpcctl switch +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.P +.B rpcctl switch set +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.RB [ \--dstaddr +.IR dstaddr] +.P +.B rpcctl xprt +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.P +.B rpcctl xprt set +.RB [ \-h | \-\-help ] +.RB [ \--id +.IR ID ] +.RB [ \--dstaddr +.IR dstaddr] +.RB [ --offline ] +.RB [ --online ] +.RB [ --remove ] +.P +.SH DESCRIPTION +.RB "The " rpcctl " command displays information collected in the SunRPC sysfs files about the system's SunRPC objects. +.P +.SS Objects +Valid +.BR rpcctl (8) +objects are: +.IP "\fBclient\fP" +Display information about this system's RPC clients. +.IP "\fBswitch\fP" +Display information about groups of transports. +.IP "\fBxprt\fP" +Display detailed information about each transport that exists on the system. +.SH OPTIONS +.SS Options valid for all objects +.TP +.B \-h, \-\-help +Show the help message and exit +.TP +.B \-\-id \fIID +Set or display properties for the object with the given +.IR ID. +This option is mandatory for setting properties. +.SS Options specific to the `switch set` sub-command +.TP +.B \-\-dstaddr \fIdstaddr +Change the destination address of all transports in the switch to +.IR dstaddr +.SS Options specific to the `xprt set` sub-command +.TP +.B \-\-dstaddr \fIdstaddr +Change the destination address of this specific transport to +.TP +.B \-\-offline +Change the transport state from online to offline +.TP +.B \-\-online +Change the transport state from offline to online +.TP +.B \-\-remove +Removes the transport from the switch. Note that "main" transports cannot be removed. +.SH DIRECTORY +.TP +.B /sys/kernel/sunrpc/ +.SH AUTHOR +Anna Schumaker From patchwork Thu Oct 28 18:35:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12590853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18173C4321E for ; Thu, 28 Oct 2021 18:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 034A6610D2 for ; Thu, 28 Oct 2021 18:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231201AbhJ1SiA (ORCPT ); Thu, 28 Oct 2021 14:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbhJ1Sh6 (ORCPT ); Thu, 28 Oct 2021 14:37:58 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35059C061570 for ; Thu, 28 Oct 2021 11:35:31 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id bj31so6809797qkb.2 for ; Thu, 28 Oct 2021 11:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0p3tzqQxt2fr7aUhoLp6NI6pwaVwRH7jkeCkX9uX9DA=; b=WQsJM2ka8QEdRyKJYgz+p3ymmycPTo+oAFCOqpYeXP7oNskIYh3/8TptkMM8EGd4B7 HbbF9GwjHZ3GYNlVwCmnxSbKkwRpWQi+BFIKpq5xtJtfxnFz4c+EBJO946GLJHgRZouV XfYQMIFLb3G4wTtwW9vlLfRPTM7AGre4xvxpExxoqDSV4N1Z+cx60qEFEp2I1jIfxzgC Y67slyJ/Xh33gYYMPBRNo0P9WlOxRZeqOWiiC4QquaDt3hpxhoZmVUkYjNWmQlSu0L0G KbLNcBgE0I9ay/N1mdpqWJspB/e6UgvL/y6QY8Iwan7UV39MwDSKGXY8unomAT4u7q0W wWIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0p3tzqQxt2fr7aUhoLp6NI6pwaVwRH7jkeCkX9uX9DA=; b=xwbVNPSsBodLPpLfDGUJ2zvh0bqhXOo9elZ9iiL0eY/kSgyZDJZvB8xgx9uFLOHfQv 9Zc6ZUrkSiTdpwUTt9ogWbvkX4qiJHB7Zr1dy23CK4jle7GMZzwSe/5x1c/T48dVSTS9 B6YWwaq+iW921ll0mpX1pbN84Hr0wlamrmdWJewEPItx5e6FcLwplwJheB6/W9pH+kFt AiUdTgkw5dESgeo4cL0PTxDxPOOKjNm9wxbAcZNLaOvH3ZbrZKlPj2yqwCY1F9inl0V3 eZYPHTmG9RQZ0YGB2et3EuenrfDa5n1t99OXdoEg6aJdJSPp59W7jgV3B0KViHcd4w8v UQpQ== X-Gm-Message-State: AOAM533koLGf/JyHRyiDQxK3nWYwAdoQB+uX8eHq2T/4x6ksSNeCQHYy 1HGOLA7VM++nw7sES1tjgTZ7UCMI9BA= X-Google-Smtp-Source: ABdhPJzmX0+b0m8uRSk5og2LSBqROp3IhBGfxN4YYeIs0yjrWjbvvqPM23eqFZPZ7+29LC1qWU95DQ== X-Received: by 2002:a05:620a:bc1:: with SMTP id s1mr5187073qki.49.1635446129852; Thu, 28 Oct 2021 11:35:29 -0700 (PDT) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id q13sm2556476qkl.7.2021.10.28.11.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:29 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v5 9/9] rpcctl: Add installation to the Makefile Date: Thu, 28 Oct 2021 14:35:19 -0400 Message-Id: <20211028183519.160772-10-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> References: <20211028183519.160772-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker And create a shell script that launches the python program from the $(libdir) Signed-off-by: Anna Schumaker --- configure.ac | 1 + tools/Makefile.am | 2 +- tools/rpcctl/Makefile.am | 20 ++++++++++++++++++++ tools/rpcctl/rpcctl | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tools/rpcctl/Makefile.am create mode 100644 tools/rpcctl/rpcctl diff --git a/configure.ac b/configure.ac index 93626d62be40..dcd3be0c8a8b 100644 --- a/configure.ac +++ b/configure.ac @@ -737,6 +737,7 @@ AC_CONFIG_FILES([ tools/rpcgen/Makefile tools/mountstats/Makefile tools/nfs-iostat/Makefile + tools/rpcctl/Makefile tools/nfsdclnts/Makefile tools/nfsconf/Makefile tools/nfsdclddb/Makefile diff --git a/tools/Makefile.am b/tools/Makefile.am index 9b4b0803db39..c3feabbec681 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -12,6 +12,6 @@ if CONFIG_NFSDCLD OPTDIRS += nfsdclddb endif -SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat nfsdclnts $(OPTDIRS) +SUBDIRS = locktest rpcdebug nlmtest mountstats nfs-iostat rpcctl nfsdclnts $(OPTDIRS) MAINTAINERCLEANFILES = Makefile.in diff --git a/tools/rpcctl/Makefile.am b/tools/rpcctl/Makefile.am new file mode 100644 index 000000000000..f4237dbc89e5 --- /dev/null +++ b/tools/rpcctl/Makefile.am @@ -0,0 +1,20 @@ +## Process this file with automake to produce Makefile.in +PYTHON_FILES = rpcctl.py client.py switch.py sysfs.py xprt.py +tooldir = $(DESTDIR)$(libdir)/rpcctl + +man8_MANS = rpcctl.man + +all-local: $(PYTHON_FILES) + +install-data-hook: + mkdir -p $(tooldir) + for f in $(PYTHON_FILES) ; do \ + $(INSTALL) -m 644 $$f $(tooldir)/$$f ; \ + done + chmod +x $(tooldir)/rpcctl.py + $(INSTALL) -m 755 rpcctl $(DESTDIR)$(sbindir)/rpcctl + sed -i "s|LIBDIR=.|LIBDIR=$(tooldir)|" $(DESTDIR)$(sbindir)/rpcctl + + + +MAINTAINERCLEANFILES=Makefile.in diff --git a/tools/rpcctl/rpcctl b/tools/rpcctl/rpcctl new file mode 100644 index 000000000000..4cc35e1ea3f9 --- /dev/null +++ b/tools/rpcctl/rpcctl @@ -0,0 +1,5 @@ +#!/bin/bash +LIBDIR=. +PYTHON3=/usr/bin/python + +exec $PYTHON3 $LIBDIR/rpcctl.py $*