From patchwork Thu Jan 27 19:49:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727218 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75C4AC433FE for ; Thu, 27 Jan 2022 19:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235210AbiA0Tt4 (ORCPT ); Thu, 27 Jan 2022 14:49:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245702AbiA0Tt4 (ORCPT ); Thu, 27 Jan 2022 14:49:56 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22A3C06173B for ; Thu, 27 Jan 2022 11:49:55 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id z1so2288314qto.3 for ; Thu, 27 Jan 2022 11:49:55 -0800 (PST) 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=27Cy+fjQrrhdBt/+KeF+2iggxTxikJ4LQwj6XTmGTFQ=; b=SankUvwZe3dHu+0eZQaZPIPwv1v+r6VBoKzJ/gxw3J7NtdrWwU3TrZQ37i6XkKWMpN 6sidNgBgWNdjLfokSUSacR96Uug3oDRAzV6+Rru5hP3B8qU5XGxAjBeVBt1+5ZpDa+fE aaxS1dC08HNR3TzhPfHKL64DsQNURqY4R3olSLPe8nF0aSXX1sIGutwZvMx/BEKUMqlr eBcRH2QMbCjf7QcMWoLn2fO82VJa/vN977S5NRvSlKsy79MozKU6R72RGkvJUc23BEPT /hq/VvFmLwAW2U34HVxSJNSvLfzT+kOzqp6oS5GEzPvWxSuIcmH9zMZhAwNFCmjSv3JJ wExg== 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=27Cy+fjQrrhdBt/+KeF+2iggxTxikJ4LQwj6XTmGTFQ=; b=HJGyD3B/5LrKQMO1JPx949a353Vof53mZhSKV6DYzIN4TZT//fEgF4iDT6sSiHZeoQ jVPsYqFh7LbvinOVKXGXIBZTrrhA4mn/LgOD1vu0IQ4wmlmDr2qXED5yrkeAbIdr69rz VjzRs+H32kARLEqYxQNngwR3R9p3J070X/Fgc/9LLrTBC8CFg0RidfdietrZusMvcPDZ aqYreGSuEmsJ5pu6HRInBsyv/4aWpkC/KYxYPfoJpkJQJV0tJikr1kT9vHENGUU5zV50 oEmbMlhz2XqC5goQqRYAuye7H3ozCYbNOxBkwkVxRzl3SSRG5qoHEbuGhqlXaED/Icg7 F+/A== X-Gm-Message-State: AOAM533k7VT+AcgRPP5hoQnrh7uwYiW780uLk80Euny/eEQOUAsqCoi6 bBvyv8310HPVPVBaaTSawR8iRX3QVTM= X-Google-Smtp-Source: ABdhPJwjBc75VZlBwgBPMIoo44u2HpCdnhV2ptIaN5TFcPlS3wLjRlGMYBCUTCdriVrAWy9VHmshHw== X-Received: by 2002:a05:622a:1908:: with SMTP id w8mr4005465qtc.252.1643312994763; Thu, 27 Jan 2022 11:49:54 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:54 -0800 (PST) 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 v7 1/9] rpcctl: Add a rpcctl.py tool Date: Thu, 27 Jan 2022 14:49:44 -0500 Message-Id: <20220127194952.63033-2-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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 --- 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) From patchwork Thu Jan 27 19:49:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727222 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8B4CC433EF for ; Thu, 27 Jan 2022 19:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245702AbiA0Tt5 (ORCPT ); Thu, 27 Jan 2022 14:49:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245708AbiA0Tt4 (ORCPT ); Thu, 27 Jan 2022 14:49:56 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57444C061747 for ; Thu, 27 Jan 2022 11:49:56 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id h25so2518872qtm.1 for ; Thu, 27 Jan 2022 11:49:56 -0800 (PST) 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=pzZX1cVE9H60Q9bqhWS3/JXUmBjeHDoCXI05lUqW7Os=; b=gtEpdKZkiE9aOh38bgHLGCWZTjl2pnqq168NLdP6gypnoh2kqCd8aT8cXnh4XQrruT Jx+jckcheEduUr2cn910dhaW9MrhQ+Bfv/vpjX07unv/JrXIXauVnvlJyy+NbVtweN3q IBu42A1Anga3ANqoiZ8un3ePMhMDErEYbZnB2DmIAY7ndiC+SDAZHuL+ZtJ5PMb9A7Z7 PMYohxo1Ekki+sMcmSrMO4yBKBtksJI6GaKGXYmeyLZWrY9nQYLwJWdwUxitkA7Ye+IW r9DvH+y7fjvkgs6BeYj5dzkeJsavLGd6ibO4cNWa6y6eX+eY4Ha5DtlJs9GZbwqKxeaQ 0sqQ== 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=pzZX1cVE9H60Q9bqhWS3/JXUmBjeHDoCXI05lUqW7Os=; b=D2vDU82yoOoSwNyk3joGouEWukYAeuCD3zuy+MmNGSYDVcHU/3mJKIQTdDLM2vuIMZ h5B+x9K/eQm/BfOnTtJIFNPN4WnokxyCit7Y05DhfiORISOFP32KSS8Xt4fkyFiIK98q 49EIxwBwpI0dSj50wyebY6DRMKZpHVfVq0sDnbFKOPSf73VLr1bv+qbDXDs8W96PRm8O tFsxwxUPSxo9AHqVvUTqrzSRf+qvFRgE3QLeFBl+zH6vVbwAQMBGbgBW+Z7TMsYHhVUG n26bcyApSjOKqSjboZh7qjT4ufYWj1WOVhmYCtUgzJt/Rujxy30HU4Muit0OGyBNF+BC WBxw== X-Gm-Message-State: AOAM530131ATTEzdRSN5juBiEwVXNjTE8Ic1TJbOd1xrgKDl57Fo0Ix/ F6HELiz0R1PRhUtZvWmt5QbPhLxtM1Q= X-Google-Smtp-Source: ABdhPJytVeVu9kvKVZJXYmmmo5+GYj4FxCNxSfNmEnC0IffTeRcUPg0ASAWgG3MYZ7eS/AG68Js9sA== X-Received: by 2002:ac8:5f0e:: with SMTP id x14mr4019902qta.234.1643312995438; Thu, 27 Jan 2022 11:49:55 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:55 -0800 (PST) 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 v7 2/9] rpcctl: Add a command for printing xprt switch information Date: Thu, 27 Jan 2022 14:49:45 -0500 Message-Id: <20220127194952.63033-3-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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 --- tools/rpcctl/rpcctl.py | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 9737ac4a9740..0d922f1acf21 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 import argparse +import collections import pathlib import sys @@ -14,6 +15,70 @@ 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 + + +class Xprt: + def __init__(self, path): + self.path = path + self.id = int(path.stem.split("-")[1]) + self.type = path.stem.split("-")[2] + self.dstaddr = 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}" + + +class XprtSwitch: + def __init__(self, path): + self.path = path + self.id = int(path.stem.split("-")[1]) + self.info = read_info_file(path / "xprt_switch_info") + + self.xprts = [ Xprt(p) for p in self.path.iterdir() if p.is_dir() ] + self.xprts.sort() + + def __lt__(self, rhs): + return self.id < rhs.id + + 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 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=XprtSwitch.list_all) + + def list_all(args): + switches = [ XprtSwitch(f) for f in (sunrpc / "xprt-switches").iterdir() ] + switches.sort() + for xs in switches: + if args.id == None or xs.id == args.id[0]: + print(xs) + + parser = argparse.ArgumentParser() def show_small_help(args): @@ -21,5 +86,8 @@ def show_small_help(args): print("sunrpc dir:", sunrpc) parser.set_defaults(func=show_small_help) +subparser = parser.add_subparsers(title="commands") +XprtSwitch.add_command(subparser) + args = parser.parse_args() args.func(args) From patchwork Thu Jan 27 19:49:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727220 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28744C4332F for ; Thu, 27 Jan 2022 19:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245708AbiA0Tt5 (ORCPT ); Thu, 27 Jan 2022 14:49:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiA0Tt5 (ORCPT ); Thu, 27 Jan 2022 14:49:57 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B7CC061714 for ; Thu, 27 Jan 2022 11:49:57 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id k4so3815877qvt.6 for ; Thu, 27 Jan 2022 11:49:56 -0800 (PST) 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=MmwFXixjfwMV9cyT3TGZyFhvQH58zAcM3mqXYroDdY0=; b=cWgT7th305LYBOatf0Q/3Om0pvPwhtMQD95QNyIDq2A6TXDeyMtis/Zg3ZOGdMbhLR bFgOtyKBWRxiB2JHEszLQWJQFmuv3o151yPwRwgK550XvToZ0+lqrtJUBIBpLLWfckew b10xyR4s+01H03FG1RBPHw0/yzNIgxoFClTS7hjmPsE9Q3F7Da1AEJoa0N2Z4UX2QL/T yhVQoHoBWrM3KU3U+7FcHEdjMKxbAjdQgwWAM95yH7paqmCagqLx4/DIwOH6RhX/43S5 iAEN+EqluUW0wsoD9Xl5KVZmMrnpcBmBDr09ZHaxMSSjg2gLgsPMHV8T7C4pNONSBOzM sLsw== 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=MmwFXixjfwMV9cyT3TGZyFhvQH58zAcM3mqXYroDdY0=; b=FZFqQ/bCnHaHFHtI5E9B6Xwoi3ARZKomuPJmu5Xr4OVeq07sfyi3ARwkcrDvck4W0/ XBvwKLbVEjE2wkgfYeMgZu7nKSehRP0cEaaZkbhZ3fdIEHz7zYi0WxxvIRBVd5B4gZFN 2XDI2eOCDfSZXiT26ZmnPYb+wIwU3ZHnEL7X6XzJd8kovmBZ11tUjl4lf+Ul/QEh0Jta WgsOUSqRqJzDosOb/cmo9DiBoETGDp0TpR1AuUR6no8tl5+e9GzUc6WoV1Ser29g71sW xBn+4RDnWqxPyNhjAWU4XygDVjQEdmurTuixGNjp1eCxasu8gGaO5aZZNIIh4eCQk6Ns BNcQ== X-Gm-Message-State: AOAM531TGCLTLOJdmkm+77F0nZuDPGDUb4nPr7T07zyhEUolxCK8op+F X2CN6fNxj8/JO3kXv5N0wTUG65tGnoI= X-Google-Smtp-Source: ABdhPJztV74RGQBfIaxrLBch18OG0UdiHkXdFiYjmmQ7/TaGDqTnM0PAXHZ6/ERjSM2XS0n/iz9Qvw== X-Received: by 2002:ad4:5c83:: with SMTP id o3mr5017891qvh.15.1643312996094; Thu, 27 Jan 2022 11:49:56 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:55 -0800 (PST) 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 v7 3/9] rpcctl: Add a command for printing individual xprts Date: Thu, 27 Jan 2022 14:49:46 -0500 Message-Id: <20220127194952.63033-4-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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 --- tools/rpcctl/rpcctl.py | 43 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 0d922f1acf21..b5092e39d336 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -37,13 +37,53 @@ class Xprt: self.path = path self.id = int(path.stem.split("-")[1]) self.type = path.stem.split("-")[2] + self.info = read_info_file(path / "xprt_info") self.dstaddr = read_addr_file(path / "dstaddr") + self.srcaddr = read_addr_file(path / "srcaddr") + + 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 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=Xprt.list_all) + + def list_all(args): + xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] + xprts.sort() + for xprt in xprts: + if args.id == None or xprt.id == args.id[0]: + print(xprt) class XprtSwitch: @@ -88,6 +128,7 @@ parser.set_defaults(func=show_small_help) subparser = parser.add_subparsers(title="commands") XprtSwitch.add_command(subparser) +Xprt.add_command(subparser) args = parser.parse_args() args.func(args) From patchwork Thu Jan 27 19:49:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727221 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1349AC43219 for ; Thu, 27 Jan 2022 19:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245740AbiA0Tt6 (ORCPT ); Thu, 27 Jan 2022 14:49:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiA0Tt6 (ORCPT ); Thu, 27 Jan 2022 14:49:58 -0500 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 D1FF4C061714 for ; Thu, 27 Jan 2022 11:49:57 -0800 (PST) Received: by mail-qt1-x830.google.com with SMTP id b5so3401821qtq.11 for ; Thu, 27 Jan 2022 11:49:57 -0800 (PST) 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=9KmOazJo3AC+FbfLD+18zxeLwtQZ9YpPY0h/r3NqizE=; b=PIqn/DHL99ofB6HCYG2MyFcU/3oOs1yurAfBO9urFxb4B37T5I5IOdqjc7FwrGTRap wKwzV/2wKnAvpBkAR3BeijU8igic+Qc4vWTPlr3lO0w9ug7jfEtdZUkFL2w55VIFUJc9 KGYU/0SLXiIlOlTNS9WWAbDXaqi79gTuwQFEQDhUpwObgw1eB/CbR/MG8ttv3p8Yf2E3 asxAVrI1bj1dL+tD0Q47mZ/CJ5RP3yW08OHGa7UBFcnBIF0+H/FJb8LENTTkfQZ8xUNt voAyc3do0pwWI6XN1pkwMHw0vi+UeMs5sGwuB5d3WDO6TpKlPVixs+q55qtIdnnjC19O 8zpQ== 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=9KmOazJo3AC+FbfLD+18zxeLwtQZ9YpPY0h/r3NqizE=; b=VUlevK+wX8+S4sfFcquzkMmWMk2ZKWQUsrh/xr5F5qXNFqvyHtgRVxtpds6QBofPdm Ygptpq0YtiyfElHcu6qO8aKjEl7Q23GiPr/Ul22pYqjwCRT7GqpDzClvzkuRwk3MSeFn p8PQzI5+MPhLxPe7T6JI+BOKvvVKt6ZtxhIfKeHC1i4LK2nRIeOuKtcKEXenoY+iVDr3 BARRG/pOHfvrCJ2PjKNBrWleEzYoePKwOMN+jFN9T72Z3VAuj4sUX5ZyD+pEeHxgdIwz 5j3ZLFsPuxq6atBJfvlUpUxQ+zQ98FNty+h3grokh/T8fOg32W+MgPaQJochHje/TRYv C1Bg== X-Gm-Message-State: AOAM533CRIWf8rg9hXM+JfTrqWzRK5jnf4XFfioXm+p7Ol4QPBLPM8l3 I+XKts/meIAEnWDAcTNP4UU= X-Google-Smtp-Source: ABdhPJz+Z2Nbplb3qYjjnRX2bV9Jd//2ZZfAi96cq69HKNziiNsU/AcrqXb4zO2cQ1uhqa301/0W2w== X-Received: by 2002:a05:622a:3cf:: with SMTP id k15mr3860951qtx.339.1643312996891; Thu, 27 Jan 2022 11:49:56 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:56 -0800 (PST) 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 v7 4/9] rpcctl: Add a command for printing rpc client information Date: Thu, 27 Jan 2022 14:49:47 -0500 Message-Id: <20220127194952.63033-5-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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 --- tools/rpcctl/rpcctl.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index b5092e39d336..bdb56d1f5476 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -87,10 +87,11 @@ class Xprt: class XprtSwitch: - def __init__(self, path): + def __init__(self, path, sep=":"): self.path = path self.id = int(path.stem.split("-")[1]) self.info = read_info_file(path / "xprt_switch_info") + self.sep = sep self.xprts = [ Xprt(p) for p in self.path.iterdir() if p.is_dir() ] self.xprts.sort() @@ -99,7 +100,7 @@ class XprtSwitch: return self.id < rhs.id 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']}" @@ -119,6 +120,32 @@ class XprtSwitch: print(xs) +class RpcClient: + def __init__(self, path): + self.path = path + self.id = int(path.stem.split("-")[1]) + self.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 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=RpcClient.list_all) + + def list_all(args): + clients = [ RpcClient(f) for f in (sunrpc / "rpc-clients").iterdir() ] + clients.sort() + for client in clients: + if args.id == None or client.id == args.id[0]: + print(client) + + + parser = argparse.ArgumentParser() def show_small_help(args): @@ -127,6 +154,7 @@ def show_small_help(args): parser.set_defaults(func=show_small_help) subparser = parser.add_subparsers(title="commands") +RpcClient.add_command(subparser) XprtSwitch.add_command(subparser) Xprt.add_command(subparser) From patchwork Thu Jan 27 19:49:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727223 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FF97C4321E for ; Thu, 27 Jan 2022 19:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245743AbiA0Tt7 (ORCPT ); Thu, 27 Jan 2022 14:49:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiA0Tt6 (ORCPT ); Thu, 27 Jan 2022 14:49:58 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E02C061714 for ; Thu, 27 Jan 2022 11:49:58 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id b5so3401845qtq.11 for ; Thu, 27 Jan 2022 11:49:58 -0800 (PST) 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=wIr4dYeXuycAWYUtMcxedVBml9BP+YdoGTwnU9TNSYc=; b=GcBguoaUdGo11/OFLksJ6gQC5pkJa8BMMBxZ4TQD8LmnJIuOUR9UWeLlRMrpgTZWQO zOS9e7+hKv4vbOcUyJZZgNVx5bR01KNG5pdQcCpJ3JD197nbn0yAOmdfJSViJBWuLU3/ lDmWJJYautMfRcnOiYUSVSQ5DeEf63i1Pl1mg/ws8iZw3hxDOnpWGucT5OUW2+JoGj7d wXR740LfC1K0KHwRkOa0+tv6+JvRqJ+e7Gm2vd107BAqOEyZuqC65RD677Do+TQ06d5K koCit17bslWxOFYIud6eVz60lt8GXwOx08vT7NnCmwNYqjdPcGj2U8j6/tEE0+7kQScj v+jA== 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=wIr4dYeXuycAWYUtMcxedVBml9BP+YdoGTwnU9TNSYc=; b=leGcn3Y6WSjsInAthM3lJlqHNqNEwjDSPwDqhDdELx8g55PSFJMdmJliM/Qcn39U32 JQjN0v7LOvGcSwzgohSG5VwixD4nnWWS32zoq283yXW3pkbkbzg32/NfW/dkdZfsSqR3 odgzQTXUKy9Qkooo44UImyA46xgRWRrDlfGr3+zgtTlGwxR8TrTG//qE7NFBIb8O/mfF nUoBV09HsScvgFq5fvscEtNops1gxYM1w/tGAdosS2ywi8GdnY9pzZ4RssJoSbtZvsiG LO7SVjB45WHVsFSK3msZucAi7gAY7JZVSg8Byerkg9haaNTWEb1O4SCU8F07XdO6UU6U SzaA== X-Gm-Message-State: AOAM530PCKj/8g8ZMk7rDbK7dEut7B2WQZ9z6X6H6g629BZJcpzeKC2/ T0WDZREDzclfRJRz+zKAz9k= X-Google-Smtp-Source: ABdhPJyrBhyxzFpvKYAHflRNBcorpx5Z/Q7LoXaoT/OJHRrfFqj51Ecdlcx7BPKFgBFeAeo1uDcSiQ== X-Received: by 2002:a05:622a:593:: with SMTP id c19mr1280673qtb.556.1643312997580; Thu, 27 Jan 2022 11:49:57 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:57 -0800 (PST) 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 v7 5/9] rpcctl: Add a command for changing xprt dstaddr Date: Thu, 27 Jan 2022 14:49:48 -0500 Message-Id: <20220127194952.63033-6-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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/rpcctl.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index bdb56d1f5476..c481f96333f9 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -2,6 +2,7 @@ import argparse import collections import pathlib +import socket import sys with open("/proc/mounts", 'r') as f: @@ -22,6 +23,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: @@ -73,11 +79,21 @@ 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 = write_addr_file(self.path / "dstaddr", resolved) + 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=Xprt.list_all) + 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=Xprt.set_property) + def list_all(args): xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] xprts.sort() @@ -85,6 +101,21 @@ class Xprt: if args.id == None or xprt.id == args.id[0]: print(xprt) + def get_by_id(id): + xprts = [ Xprt(f) for f in (sunrpc / "xprt-switches").glob("**/xprt-*") ] + for xprt in xprts: + if xprt.id == id: + return xprt + + def set_property(args): + xprt = Xprt.get_by_id(args.id[0]) + try: + if args.dstaddr != None: + xprt.set_dstaddr(args.dstaddr[0]) + print(xprt) + except Exception as e: + print(e) + class XprtSwitch: def __init__(self, path, sep=":"): From patchwork Thu Jan 27 19:49:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727224 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9648BC433F5 for ; Thu, 27 Jan 2022 19:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245744AbiA0Tt7 (ORCPT ); Thu, 27 Jan 2022 14:49:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiA0Tt7 (ORCPT ); Thu, 27 Jan 2022 14:49:59 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B72C061714 for ; Thu, 27 Jan 2022 11:49:59 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id d8so3840979qvv.2 for ; Thu, 27 Jan 2022 11:49:59 -0800 (PST) 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=l160xsQI888sYJ8Bl6uSXpCWja2VhcgNs1mAzMKSkGE=; b=UmNjKF896iRoEj61qhuGlK6ZfLYXMcsuN+ANLSA/eWn7Ajhm5GDG4WA1/oqYWjF5XA cQY0vjW56wrlF3nNaspCuatCQtZA2WWST5/wTWRe+o7/zl6rK6/aEjnO0sBikwVy9gp9 yEAlgXuCg1TG8ZzXuAmrP96JTK1mCj8SjgAf/zTZQHwbLFhyLKWzRNtMgs487QyVeyp+ D7YPYOMFoT909qXPsTMhHeW7t5qRsn7f3MtTfsEnr3aY74RZpfRYUg9RbkZnhQGZ+npd OtXsxPxdMU6tJ7doB+0nRwmf1C10D5jQyH8rHz4IX/GWTmKhXx1yocbXTBw1nwaYSDZN zSBw== 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=l160xsQI888sYJ8Bl6uSXpCWja2VhcgNs1mAzMKSkGE=; b=0WUG1J9/TILYHYXnwfZ0pvYTNenUOMPtN3esOcJPOBSJba09+AiQDP8vla7i4HDyrL caauZGHY3oGnfwHJkdAKZz1zFRMZGfmha+6tU8cQkpXVmskICjsVbdmwuiB/lh7DNAJO YY0DlezFRJilTeJrVFvOSpJBatY3bAcctktZ5fO5QL3v5t5WrGlyA/cIKht/Co1qoK86 t+XciSgFxSu3B0MGBkWBG9By5pbFO06x9YMMgZN90c41+KTFc1XGzJcKWYylkPgWIEKw vNRmRcfn25vJLVt6xrZoWx9l6KT9rv+2qLY157TAVQ4xYmgxFWA/EqvDXQ2y1HGt3mP5 xHgA== X-Gm-Message-State: AOAM532B2ZXYSsItDqwYne8wrnExJsFzuA8aH6h8qFPSv0QeCIxs9jmd YNGKej/laZbgNAHE/tIgVag= X-Google-Smtp-Source: ABdhPJx/HnSm5wdH1Gk3YarcgIfb+vjzvjzvj9HMdSzDyqCEU7dFr/Dn0cntOC9q/j4t2emPU62aEA== X-Received: by 2002:a05:6214:20e7:: with SMTP id 7mr4383694qvk.43.1643312998273; Thu, 27 Jan 2022 11:49:58 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:57 -0800 (PST) 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 v7 6/9] rpcctl: Add a command for changing xprt switch dstaddrs Date: Thu, 27 Jan 2022 14:49:49 -0500 Message-Id: <20220127194952.63033-7-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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/rpcctl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index c481f96333f9..9404b975e33d 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -143,6 +143,12 @@ class XprtSwitch: parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") parser.set_defaults(func=XprtSwitch.list_all) + 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=XprtSwitch.set_property) + def list_all(args): switches = [ XprtSwitch(f) for f in (sunrpc / "xprt-switches").iterdir() ] switches.sort() @@ -150,6 +156,16 @@ class XprtSwitch: if args.id == None or xs.id == args.id[0]: print(xs) + def set_property(args): + switch = XprtSwitch(sunrpc / "xprt-switches" / f"switch-{args.id[0]}") + try: + for xprt in switch.xprts: + if args.dstaddr != None: + xprt.set_dstaddr(args.dstaddr[0]) + print(switch) + except Exception as e: + print(e) + class RpcClient: def __init__(self, path): From patchwork Thu Jan 27 19:49:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727225 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 367FAC433FE for ; Thu, 27 Jan 2022 19:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245746AbiA0TuA (ORCPT ); Thu, 27 Jan 2022 14:50:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiA0TuA (ORCPT ); Thu, 27 Jan 2022 14:50:00 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8793C061714 for ; Thu, 27 Jan 2022 11:49:59 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id w6so3434937qtk.4 for ; Thu, 27 Jan 2022 11:49:59 -0800 (PST) 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=4eEDJovFmlLJ20QpwaSMs9dThSXRbe6m7jUaKUNoouM=; b=bLu5Fxy8NUZLTcIjzE7WDXEN7OTuSS4vNpGvo6/2kNElT6OHDr2Sl3bXc8vqvEdKso CfzWZaIG1pklcqcP8pk9Jh75iNNpD4pLcClTKY9hLlWtwVQXMozUtJV6Az2Zbr43huBo U409T3VRSCffbbXa2cARGUO05D2RcK6QTXhktMscdidb6Re/f4552dqQwzAuakfO/kXF qXI6rZY54rmUohETmJkErNVrKv0qh1bsfniWU9j9vQcnimMJ8emNkJlpXVbnpQ/eW5dK 6RYrytfOX4mizgzhw4y0yiChlAspSLfKibqShUp9uM+LQUmElv5Kk9jx6BxNW4rFh72k ZR6A== 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=4eEDJovFmlLJ20QpwaSMs9dThSXRbe6m7jUaKUNoouM=; b=Pz7mKI3bkasfGGrdmNYwle/+tUpKPPvzBbSYC9FvS20kHG2JibeXrhBjal1kx2Av42 63258TuLpNTokbHVCvWR25VEBHDXGJJWnSZnCcjsBMYZKyZNZfrRyr50jkXDSGEECC2K Ncb96QzlYqSNEu8Kz5BYfsuIIaUEB5rcm/Ct8FG0iZjMLpvzaPtkfAKM/nzmm191IGv+ zYuoxkbEhNmJrFivGqtevLJUv0QZOA50NRR5RH9MwAdjpaamPNmNhxiR9+JFh30UohHn IQ9eF5+UOgsJrgcMv5DUoPM91FCoMn6KhNLKY/kf5HAsLX/YWzCG0WVXYEKv2OcfG/Fg Xpwg== X-Gm-Message-State: AOAM530WN1Cg8Kzjx6RYFFBKVksOnbFWbIMI+SL+wHWnMSrUk1SBnISC VyyXUnrQJEotUwC6fMw8Ji01UNmYd0I= X-Google-Smtp-Source: ABdhPJxOFvh1Xx5CQpbtYTWprWp2VhA4RSNZfuhMwx2CE/vaU2IZuA7i9qzjeNnHArhLieG1c5RO8Q== X-Received: by 2002:a05:622a:38a:: with SMTP id j10mr4028514qtx.315.1643312998850; Thu, 27 Jan 2022 11:49:58 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:58 -0800 (PST) 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 v7 7/9] rpcctl: Add a command for changing xprt state Date: Thu, 27 Jan 2022 14:49:50 -0500 Message-Id: <20220127194952.63033-8-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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/rpcctl.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 9404b975e33d..0771c4e0d0b1 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -46,9 +46,7 @@ class Xprt: self.info = read_info_file(path / "xprt_info") self.dstaddr = read_addr_file(path / "dstaddr") self.srcaddr = 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 @@ -72,9 +70,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" 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}" @@ -83,6 +88,11 @@ class Xprt: resolved = socket.gethostbyname(newaddr) self.dstaddr = 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 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") @@ -92,6 +102,10 @@ class Xprt: 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=Xprt.set_property) def list_all(args): @@ -112,6 +126,13 @@ class Xprt: 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) From patchwork Thu Jan 27 19:49:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727226 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9531C433EF for ; Thu, 27 Jan 2022 19:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245753AbiA0TuB (ORCPT ); Thu, 27 Jan 2022 14:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245709AbiA0TuB (ORCPT ); Thu, 27 Jan 2022 14:50:01 -0500 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73927C061714 for ; Thu, 27 Jan 2022 11:50:00 -0800 (PST) Received: by mail-qt1-x835.google.com with SMTP id k14so3404317qtq.10 for ; Thu, 27 Jan 2022 11:50:00 -0800 (PST) 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=AhOG6e9nTOmpjTzbQRMgirrPw1Wc7JqJ+RcYK7lemrE=; b=eTA0EbtYSGu959RixikKvVdYhBJ7puEioirnBrK7lO0NTIpsDU3D+UM8KU9rHEUWSc Jhm2+FMYzwdBop0eSBxOo/FWTsYH0wvEU93ag8xPDM8hbDOPwoVpwCPB1CFLNplWLKzL mbGo+lB/tZGB45LOKtCE+0/m83JzXKPvHfdgzv1JFrmB9R7q2hzl60jKIOWBDSOqjc66 Fyb0F3Ph+U+USr1lOs4spvGaPmjKUuj+PF0ke5EeTRgyCfR9V6ClB4wPPGCbjUpKwb5x 7jkOOR0WPTKkFuxTcDgBKXyWCAswoAEUOSvfHKY+NF7GZYtvSUgwT8yEn8CgpMawAo6+ B22g== 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=AhOG6e9nTOmpjTzbQRMgirrPw1Wc7JqJ+RcYK7lemrE=; b=TWh74aKvlfkF9hzUO9zpG7QYOYrnDSVKSakHMbNXyBn2bmzxEvheimXrJXgtltIWHf Kyfs+remMMNrLHzv5hGhTsvIwE81Wkofv0EeLmQudGZNXOtv4Us/7+B4ezk0A2DXlphx af2PZPXqs7rAGDPVoL7Lh8fbHdEEep2TjnbEta/SshgjR4eKkjCkvKI3PZWA5X17DGOR /rOn7mgK5XH4wpgcqcyyWXbHGURgIQWWkUZlSB7Yg0yYJEb1U6nWXNJNyiBU/DZVNz1y CN5crqm9XMj8IPijbkWR54naoQVaavGuGjehfXaTCWIaGPUUNsL7TqbT188Ue9XPV7C5 mg7A== X-Gm-Message-State: AOAM533M+r8l00+s2dwAncqKWliWSh4u1Pm0IZ/P2szUuuIm0Kxm6Kj/ QiFCjmHUz8Hv/AeZddtQLCQ= X-Google-Smtp-Source: ABdhPJxGecJ3xhru6GOqHGC2Kx7eeox/IWvCGmG5AllcIqE5AnITMHU/4VtnI2THQKXIB3mvqS8n7A== X-Received: by 2002:ac8:5f89:: with SMTP id j9mr4037334qta.326.1643312999617; Thu, 27 Jan 2022 11:49:59 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:59 -0800 (PST) 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 v7 8/9] rpcctl: Add a man page Date: Thu, 27 Jan 2022 14:49:51 -0500 Message-Id: <20220127194952.63033-9-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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..e4dd53ac8531 --- /dev/null +++ b/tools/rpcctl/rpcctl.man @@ -0,0 +1,88 @@ +.\" +.\" rpcctl(8) +.\" +.TH rpcctl 8 "25 Jan 2022" +.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 Jan 27 19:49:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12727227 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BA23C4332F for ; Thu, 27 Jan 2022 19:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245709AbiA0TuB (ORCPT ); Thu, 27 Jan 2022 14:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245751AbiA0TuB (ORCPT ); Thu, 27 Jan 2022 14:50:01 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D384C06173B for ; Thu, 27 Jan 2022 11:50:01 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id g12so3394912qto.13 for ; Thu, 27 Jan 2022 11:50:01 -0800 (PST) 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=T6WLT/XpN/uII4dNmxdDBi+IqyZ9s4x0Pp0CrgatD9A=; b=l1SGTFJxwYaZSdmrjdsiy4Vtmf72xgyo7EznJt0H8dV/tUR2nuD04M9wce60hGu4oM 9ZbYBQdgn8OiDgcN1nQSupJ+OnLFrHhLoYYUthtaITHvZV6uY1q+YrzhYI9KOHHkaUhX ikv1dfHUNBQZiUPYqMW5EZmXRJuinaXM/db/HmtfXnLv9h0S0wEjzzxhaB6e9Tjo0xRK v98wmBCAEiRlb62Ykpxh+is8u4PTQLQ9SeXKAkGtMsE9/P34fA/hWcMUHWcza/VpEV1T oWV6kk/XGylICXP3vQMfV+hkTFFYPe82rdjrcG0OV5ub0c75kL/5IL4eB2vBVUXNxA6S YpFA== 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=T6WLT/XpN/uII4dNmxdDBi+IqyZ9s4x0Pp0CrgatD9A=; b=7mfQ0PWFh2n62dENDD8eLibQ+7NsX4GmAvPEi8xdymOdb4nJnDVnbSRVxup/STedfo XXrcDWBB8LEiHzDZDDG1ivTgDmD6AwtLxzhzEcUM252N6vuqBqSRPP5GP8Zp59Q3yaqF gWXw/j9coJKMLLxVpXWtYm17OmHBXrxB5N1S1/O2aBLgBuSJgm4lYsdOUpmWYoL23lTc 3Kj3oYIi2tUttQrZW0AGKSeBs70pNo8qOatNmG7x/EuFJVgRvyQr7jdb0e40Fz8TnQX9 yXzGAUWSapEtSLXjUu1mBlxyEE9fAf1RmHQnKee6JPPRp5+E36iOPF3uUUTE1N0Gv2U0 nA8w== X-Gm-Message-State: AOAM532uM3UQbTrSgiL23HfjeT497LqDJ3dU08s/rKAa+g/caA1STNHE adZpGCBUib/q9PeTE+MrQyU= X-Google-Smtp-Source: ABdhPJz7Bv1zOZq93sj1dHb6bpdpdifu1cJa8e2cqNO+xSxTGuT7vaqNnkkKNilEScA2/ia1zxb01g== X-Received: by 2002:a05:622a:1a90:: with SMTP id s16mr4009729qtc.586.1643313000295; Thu, 27 Jan 2022 11:50:00 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g7sm1836483qkc.104.2022.01.27.11.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 11:49:59 -0800 (PST) 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 v7 9/9] rpcctl: Add installation to the Makefile Date: Thu, 27 Jan 2022 14:49:52 -0500 Message-Id: <20220127194952.63033-10-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com> References: <20220127194952.63033-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 | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tools/rpcctl/Makefile.am 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..33fb431fe7d4 --- /dev/null +++ b/tools/rpcctl/Makefile.am @@ -0,0 +1,13 @@ +## Process this file with automake to produce Makefile.in +PYTHON_FILES = rpcctl.py + +man8_MANS = rpcctl.man + +EXTRA_DIST = $(man8_MANS) $(PYTHON_FILES) + +all-local: $(PYTHON_FILES) + +install-data-hook: + $(INSTALL) -m 755 rpcctl.py $(DESTDIR)$(sbindir)/rpcctl + +MAINTAINERCLEANFILES=Makefile.in