From patchwork Tue Jan 25 19:09:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12724159 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 973C4C433F5 for ; Tue, 25 Jan 2022 19:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbiAYTJw (ORCPT ); Tue, 25 Jan 2022 14:09:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiAYTJu (ORCPT ); Tue, 25 Jan 2022 14:09:50 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65AE7C06173D for ; Tue, 25 Jan 2022 11:09:49 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id a7so26214786qvl.1 for ; Tue, 25 Jan 2022 11:09:49 -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=kw5JfT3YUES2j7F/cVOsfLAQzmbaJFRQxrMCwxFTydA=; b=BeAY+Kibs1iqu695MqZej4L+vyS2TywF6tc9ZxaV50g/Q8xJqe3BRAVXnJZuWD97Mo K91lTUrqHQvZMOj1RTA0TLqFlx/z8468zUvl7s6zy6P274AZq9kGxttdTOdzQ1H/g1fD DvMdZKMFPnht5utoKm7IKcL5+Kjnu03nUchfmsoJs8xDnV+8/cawjUwClRFcbqxSAGVl ZkdSLXLXWH7n5+p7VqXwsjjk4fDRyW4KeLm9mXNqE+EukRdWBjH0vCbXReUqT3kiLp6q B7TP6WcQP6AwHktmnYxHR+j+cjnSXCzvlYJ+TzUEd0D5nG6Ovs8e/4DZJbrvmfapODAK EfQg== 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=kw5JfT3YUES2j7F/cVOsfLAQzmbaJFRQxrMCwxFTydA=; b=n1JhE7FRwzZEKpqDXi+ixmjHH6suhtZ00yZ6rNFIRh3Msc2hH+WEiWTBAn2gA3MrlB HcoyFMe3zo3a5mpQ0TP5fhOYGpP9VY1oN+XpOcbuqKvLQKfcJM5EkKZ6veV2E4b7nazF lZDrtBszgrf0eEvNhMV6G3kr2qPBX/FBgQgy5Rve3xyfqAH/BoJkcUNg9N1lSFbvsRDR ufZBHTg8e1khMkcJzYavn3m+VSWlP9XFSR217W21XwFYi2QLdnvdWWu4xBJxj68pdDO/ cErq1p2rOS1isU3xTh+R70GnNioifZTCTuzrIdzysFj32S2EExsEjQcBLXKM7XFyh04K h6KA== X-Gm-Message-State: AOAM533NaSATCwRgFMbZN9WssdJHflrNTA5F92K+qPx/MoAkUf5e62V7 iK35psupjaJDyCNVKoYi9sMzP/ePpyw= X-Google-Smtp-Source: ABdhPJyG6E8ctjbVDuU8iEyUul0KMzZxF73cnAciwAz1XNLea1Nm8nONoAFs9sz1nGpSHmjhNKugHg== X-Received: by 2002:a05:6214:d02:: with SMTP id 2mr19602215qvh.125.1643137788545; Tue, 25 Jan 2022 11:09:48 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:47 -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 v6 1/9] rpcctl: Add a rpcctl.py tool Date: Tue, 25 Jan 2022 14:09:38 -0500 Message-Id: <20220125190946.23586-2-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Combine files into a single Python script --- 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..9851d2f5f9a6 --- /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 line.startswith("sys ") ] + 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 Tue Jan 25 19:09:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12724161 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 8383FC433FE for ; Tue, 25 Jan 2022 19:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbiAYTJx (ORCPT ); Tue, 25 Jan 2022 14:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiAYTJu (ORCPT ); Tue, 25 Jan 2022 14:09:50 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BE95C06173E for ; Tue, 25 Jan 2022 11:09:50 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id h4so4118099qtm.2 for ; Tue, 25 Jan 2022 11:09:50 -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=PniGwIjGbetmqx1+oOSRn+cgMMvvnoBMUb+ILYmoyy8=; b=CTPXSDOG/NP+lSVs5m0J5tM62ljKJLYbxc2SipmvQn9LF4+pxd1Ee9QfRElM5qK7v9 +0ZT2aTjAXAWl1tjTs9Txy+Jv5d5vWaMwOzxQ+4WXPNaX9svUWjyjGGn+jbDF4UwHRWE XHZxaGKD5TbQhzHB0gCkXsoaPUL1pM2TNcu/CrXOBaxff2oskXONlXczzhDdwK0iz/7Z D2sBHY/XZ+ZEOdWYjdJP+ZyNi51nGEXp4L3IEKCmicJ0XwIfvcQgbsX5kyDHmrHPo6Br 7wQnBmS9GTiiSk79y2EUvoR7HH5TUARdMSJm5OPmqco0Rr4IhAv4zChOHCbYr5T5p1du 5z6g== 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=PniGwIjGbetmqx1+oOSRn+cgMMvvnoBMUb+ILYmoyy8=; b=vBX2fZspT4AXDTYi2Ji7yPYOf2uWY6bCskTs1+fk4wdrtkyAQsg5KC/4s4VTtiAIjn dAGP6xcqnAPuwNLCOhTMdpoQh5A5b8kfdWvDVkHaASG5wpkrw2Muqf1/BVz+SJqC38P9 pyRfupyLrjR/TkCBY8+Xh/1ZYDQ69p80iakpqDiQa/o4b0v2mMwx76Nf4auaRT2whXwb Eed766iH3CTwZdIsSSrPE2KSNNvuyLuVN33ZlL7QU94RA1+xHydbZ2K9qtXY6GQbtnl7 x8KOrUzmL9wioapD3u7aL7NROFNgyLVnBqJfLC7HQT5BbulJWEA7rxKWYc8nXuWwDZMn jt8g== X-Gm-Message-State: AOAM531tG01P8KUjfqZlc2IfBOig95cCZoE4n16e9S2XE8xuOFw/dfXn 8dclsfgVPGLLJg0+l7jfaxIT1QGAy8s= X-Google-Smtp-Source: ABdhPJyqITMB6x+k+efecIifAlEuncUVVNY2MHWIBBadXNt9QpeTfMMYyV1FzD0ke/7qIFd+GXoxRg== X-Received: by 2002:a05:622a:204:: with SMTP id b4mr17842617qtx.680.1643137789342; Tue, 25 Jan 2022 11:09:49 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:48 -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 v6 2/9] rpcctl: Add a command for printing xprt switch information Date: Tue, 25 Jan 2022 14:09:39 -0500 Message-Id: <20220125190946.23586-3-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Continue squashing into a single file Change XprtSwitch comparison to use id instead of path --- tools/rpcctl/rpcctl.py | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 9851d2f5f9a6..a6bd418f8d4a 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 Tue Jan 25 19:09:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12724160 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 7C5C7C4332F for ; Tue, 25 Jan 2022 19:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbiAYTJx (ORCPT ); Tue, 25 Jan 2022 14:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbiAYTJv (ORCPT ); Tue, 25 Jan 2022 14:09:51 -0500 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A89DC06173B for ; Tue, 25 Jan 2022 11:09:51 -0800 (PST) Received: by mail-qv1-xf30.google.com with SMTP id d8so5626231qvv.2 for ; Tue, 25 Jan 2022 11:09:51 -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=2+G+khJ+4q/8j018SJn5jdvwb/eI6plL2kwVmOnCRX4=; b=VvWC9GDzU2JsvkS21z3hME9LXeEzMRfMCim0VImkg4p6nu+QtO3wccguGqkJusihCi O4BNLki6o7ycjuKt3MmBP66GwwzGzv7XT7UEePjFkpGKZjakHbHx4Sy9nnPYL2VxpqBO ikWGLbpiL7dxbeOrzglKH25aNlgxGY70uNRXuOi3hQK5uktOJxE36rTMwHN8uEQ7pihr btHIf3PrCndG8U0hkL9RUcCNP68cNQJV4NrSt2yw4YY3oWxzSy86tdAh/ZRxLv+F7jaG v2EUsjReCUWRrreKPveylEASLV7VCWKd3qGj/Cd+tFDSHbLGDv1o1FaDclbml+XnIzX6 LpNw== 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=2+G+khJ+4q/8j018SJn5jdvwb/eI6plL2kwVmOnCRX4=; b=2OrgSJs92BwNG/0EcnD/IBEDO0YAYY0DMKpiGpIo8kkzbeHStisOqMbbtyQOLrft2n dBdPmFu2vCIrJv7t28kr/nTGZRgTXPCI+VxI0CfjZqWbfeKiLGkQeOC6nnis+fix9gbu oJ2f2V6VWBj4qqnbqqf7BrRBw5kKzxcFwKLs2rGOziZl+i+cM2RY+HBRFDokTAbqoXRf wI6fdDZHpn3WjPEk+6sJfPnbB6HcfR/Ze91GJ46m+J65rFDIA0i98eNoWFQLn51EPISw CpKiIcWcZnf1UXdpvqDdQyuOtndqIj00Kn5wm0+oxoHPmDosxmf5FvPyaqOFqqqrcOlx t6Uw== X-Gm-Message-State: AOAM532PChBUoTPNGwfyLmafb0fthyuZwn9AqqNZ7yXFWGDH5p0ilAk4 XjeZwHMH7cAvkIoywyML7uM= X-Google-Smtp-Source: ABdhPJyTGp9Q3RV6koftuYFh+6FnLwM+MNmS4MxidqxNi0E2xBDJh+S4rR/hesXohjlIf7KIfTiRtw== X-Received: by 2002:a05:6214:19ed:: with SMTP id q13mr21022291qvc.38.1643137790666; Tue, 25 Jan 2022 11:09:50 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:49 -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 v6 3/9] rpcctl: Add a command for printing individual xprts Date: Tue, 25 Jan 2022 14:09:40 -0500 Message-Id: <20220125190946.23586-4-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Squash into a single file --- 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 a6bd418f8d4a..ae338e06f802 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 Tue Jan 25 19:09:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12724163 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 45D22C433F5 for ; Tue, 25 Jan 2022 19:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229589AbiAYTJy (ORCPT ); Tue, 25 Jan 2022 14:09:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiAYTJw (ORCPT ); Tue, 25 Jan 2022 14:09:52 -0500 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 88032C06173D for ; Tue, 25 Jan 2022 11:09:52 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id o3so5201212qtm.12 for ; Tue, 25 Jan 2022 11:09:52 -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=u1lofvTDU5M40tHfHLPNv46v0X/TQnWs7E87egegVa0=; b=JN9iVfTTT+qtiVMp8B9NEYCB+nNQRWTImFSdBF6w4Dowo1rcdDZ6+m/jFUB/sjRJwZ 6PaIRBeTDuzpR4ND6r2tkDwpfzutN/MxTpZq51wQ0uxVLMDDnm471qeDepUNPSodYSgd ZiXVjG1CKuIwwn/EpFTt+s6U0rd6I4Ong6EbGnCGY4u4puBa2z2y9Fpo2QQ0XoPC5Xvd H9kZ4YFPO/zRpO2pKgMoKjEd/0l2rUW4ml5mQ5V3+s5LhN24UZ5L9v4+P4EfHnWWD9h7 4fAgH6ZiPB3ErVPM50stUUSJBSjXzdLvxDoXqotLK0BquyUlPclQbIHp5XmSdenmOYY9 iyFg== 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=u1lofvTDU5M40tHfHLPNv46v0X/TQnWs7E87egegVa0=; b=wg2mqs0VFjfp+zCXgcFDznht6c2W/tIGCWbdbvNWK1of0/odj7kr4cLz+4WIEnkU/3 fjBPVOb5WUq9UhLljldNQXstvmkygiH0GY4kF+cM0EakPwxxS/absTMgSJ6hRclcSS+E YjmP6aoxhHJ/OBqv7Ee0A/nQs8tfpEI/de8KyktxlYzwhnMhCx35QsYX6Y/70EdZ1EKB dT7f62iKjEJGZmbTnloPYtdLJf57+naW1fJ6hb2CAJdu5zkPJVRwbJQVODc4LZ47Gs7o w46FNh9jMSGPpnZ8Npr9JG0rvHOYv0+08WFhqQE+vEkGpIqxlmu9mOZnMswb+XEfjCKJ Maww== X-Gm-Message-State: AOAM532kdib6GYs8f7Tl2cHn895/xpAfkvrhm4WuEWMLptJCRV9tlIWE +cQ3BJe2i8D/EflPUYEw3P4= X-Google-Smtp-Source: ABdhPJxUKj4/uSqah3IScJ1cP5jwDSWudBdQh9FSiD0PEE8btycaQUSR9ZZ/Y920S5G2KIMoyD8MSQ== X-Received: by 2002:a05:622a:182:: with SMTP id s2mr12779133qtw.381.1643137791590; Tue, 25 Jan 2022 11:09:51 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:51 -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 v6 4/9] rpcctl: Add a command for printing rpc client information Date: Tue, 25 Jan 2022 14:09:41 -0500 Message-Id: <20220125190946.23586-5-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Squash into a single file --- 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 ae338e06f802..169a2a3c0ef9 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 Tue Jan 25 19:09:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12724165 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 54D57C43219 for ; Tue, 25 Jan 2022 19:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbiAYTJz (ORCPT ); Tue, 25 Jan 2022 14:09:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiAYTJx (ORCPT ); Tue, 25 Jan 2022 14:09:53 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FB6CC06173B for ; Tue, 25 Jan 2022 11:09:53 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id g11so20235043qvu.3 for ; Tue, 25 Jan 2022 11:09:53 -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=PIWBNnsksAL2n2J/iW8XJV9eJgoiGZJ8Gy0i0a++uEU=; b=fstn4Xgba3zBbYwlgtF3pkscIsJ/6u9hAXLM0w7xZr1NKmL3AmYznTvmkJFxAa14xh Ko9tYuysgqb2Shw50OE1TR5UTa42XzDZ9d1XEiVWC1Y7j3ffiez+KCDvh5WcM8m4ZkUD F5McHxNKzo6J3ck53zRLNkVZDVtLhX0dGo1bNf2u8qPoIfDt0HuoQAH7Zmx4ukrQdcK4 EkABnDWhwgbCRFZZR1Qsz4vTMUDkOQBwsBu+LCVNeYi4U7fZVBNY962V1rHnrPBrzOdo FqzMYu2hiiNBFekKK/CRRDY1mKExt4X47CVzaasmjr/QF68zUJy3zqiKmXE6PHSIQze3 a25w== 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=PIWBNnsksAL2n2J/iW8XJV9eJgoiGZJ8Gy0i0a++uEU=; b=HLgtkOle621ATe8ZepcebHMICJ84FwDYaBZrrRWw8/Aq6O+mXBuznixHiZ9ZNBuJ4g 28lcCoUv9a/EQYqFYd5mMAz1+siLdPburFToAxor/yD9UQa9Pg0gd9GAGrfYtogMPtu4 ZgwBEYWrIceWFkOWiGKW++gIpXBYSbvANcs452CgyfOOp9HvJIyxpRD32vp1BXRb6C3A jcgdix/YJod79M+x3LnjYj7NtL8A0E7vz0mqU2X17BDfQMqcKXn245ThUZFa+lecyAOR snvZH7HqX3XSC+AxKLix3ldA4t2uNC2QMEMDjfhDHCDKiGL+/BYkWiFP5DbG0qdqnDqb DU7g== X-Gm-Message-State: AOAM530xU8BDD2K5dD75KLn3YxA2ZFARNhmv9p+IQ7MNs4YZJyL4bJ5m BVSf45V8C0KQrrMroIjo618= X-Google-Smtp-Source: ABdhPJyvy9e1diJhoyIDeoRr4WOAJxwLufObRALXMlY/aca+zjvGphwQ1frb+u8c+vA1iI58DQlSxA== X-Received: by 2002:ad4:5be6:: with SMTP id k6mr20426222qvc.69.1643137792426; Tue, 25 Jan 2022 11:09:52 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:52 -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 v6 5/9] rpcctl: Add a command for changing xprt dstaddr Date: Tue, 25 Jan 2022 14:09:42 -0500 Message-Id: <20220125190946.23586-6-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Continued work to squash into a single file --- tools/rpcctl/rpcctl.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 169a2a3c0ef9..a5f83c46298f 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 Tue Jan 25 19:09:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12724164 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 000BAC43217 for ; Tue, 25 Jan 2022 19:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbiAYTJz (ORCPT ); Tue, 25 Jan 2022 14:09:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiAYTJy (ORCPT ); Tue, 25 Jan 2022 14:09:54 -0500 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 1C896C06173B for ; Tue, 25 Jan 2022 11:09:54 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id o12so5677146qke.5 for ; Tue, 25 Jan 2022 11:09:54 -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=glCIF45lcj+8BiuUMyKiYl5GPRpcLA2pBDqOPqIHpDA=; b=QAMtL3spYRWNHMWk9A/sWJKGmSrNrhdkNPRAn0b7V87439Rnw0BGc6aOGfRXmz1wkG 2sixb0VR7efp29n9NC785EWRniBbnMZAgw795Q26w97kOuZrwdUmeIfsQAdjRAmtWvXm fR3sbXxKklUDS+GIkTueZL6vja5Qv8rBQ797EMnM1arhd5+Ka7EO46T5FzdkSXJt9FJ1 U+hi8okPjbHxDya1iq640GlCNTp76TTfVBxOb6eVVxipAk5tyLBSi8RnjnTaxafl/vJw JthgotNe+UIiO40T1C1txfa/Ppty9zRZ+O9DFXmi2O2aTZWEIz786+MSQczzwF5zocVl tVLQ== 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=glCIF45lcj+8BiuUMyKiYl5GPRpcLA2pBDqOPqIHpDA=; b=HHHnU0Hh0KrInul9ALthf+xnzdLQBZTo5bEh1QKblqnxD86RC++aMjuJC0AMdHKNAg 0IMy7M/B48/IAMAbzveNBOpolSrDaj92NwQHMTWI/baFOyf7DQAOoWRoXGCUAYgqAGeD cVU4LXwJIARQfnu/IupCap6HikDbPsd7bTYuV+tw6r0IoxU5lLoHRW2ix8rm5yBqQj7y +DwVw89iZ16qthVlJwgxsvf8Zq8UiesdeRv9Ain001/Gdy6763wVxQYVI54jjN17b/+g 3TpyWrLE6omj/8oY5YGG4JLDDMpGTACVEjGvYIvh7FolbzXeBJGlMjAUrgo4bbtOkcqS i1fQ== X-Gm-Message-State: AOAM5337zsN+RXRiENuMA89+POaX4oRht2lj2y036FW7wQFNTLmT6rLM C4uIxgMe9GUCmL072dOaG7A= X-Google-Smtp-Source: ABdhPJycLcnYW9sZcIZ1ph0BwAm/nHNg402RlkUnnYLP7vvQx1S3HhX3eof1xZvRGSTuS16qb8/beg== X-Received: by 2002:a37:2c02:: with SMTP id s2mr14110031qkh.42.1643137793189; Tue, 25 Jan 2022 11:09:53 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:52 -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 v6 6/9] rpcctl: Add a command for changing xprt switch dstaddrs Date: Tue, 25 Jan 2022 14:09:43 -0500 Message-Id: <20220125190946.23586-7-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Continue single file squash --- tools/rpcctl/rpcctl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index a5f83c46298f..0c6c9d0f006c 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 Tue Jan 25 19:09: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: 12724166 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 50E77C4321E for ; Tue, 25 Jan 2022 19:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbiAYTJ4 (ORCPT ); Tue, 25 Jan 2022 14:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiAYTJz (ORCPT ); Tue, 25 Jan 2022 14:09:55 -0500 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 05373C06173D for ; Tue, 25 Jan 2022 11:09:55 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id d8so5626421qvv.2 for ; Tue, 25 Jan 2022 11:09:54 -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=o7ChbtkeVq8IE39aPHar6/G9s65bWpPz1oGjr0dqfEc=; b=nREy9/gF19a1n9sD2jtii6UbovMs7ShWGJNNyEy49us2EENbYSytRWagD5jKr8T8o5 DBppP8H+HhFroMqt4GVfz7CO7KqBvuAEa48Jr4f5OieYOntlTAvu05UlKOaptjWff5Kk ZK2y9DO3r7ao1JoaLKOcPwl7bCTyefrDOPVJMxChHIyp7jBK9XWbzPZXUHSsDSC68OFY AEHkJ6fn+KNbNGdy2wqt3dLOEH9zs+vLxDtuVlqJ5cc+BiA4Aw+3k21kjfm7kkYZ8wkb 9CKfRP9u3o+j/403m9fvAegd/9dSHdbISjyhl42FGyb++FrUh948HYSbLhXXdv9BqKH/ SjBg== 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=o7ChbtkeVq8IE39aPHar6/G9s65bWpPz1oGjr0dqfEc=; b=tR/A2PYDcYfHEunBlrW7U+9gkTsfpgpYkQhShT1EHyo+L3g5HiPO6jILEKDhq32nXt LTKYFA33WSM5SawFPNpJE4/8cx/rWGFAdieNYk39h++IYOomKvxxVDjD6l+R4wpllQeJ it3MmPcvSVwnThf9hz5eAidHmPibNC1pm20gqPiaD3hANnnmxFOhlQzkpI3cOei24CWn U5qVItc5zaKRsyQXXBiongjxpF6SpzPVaiME5GKZ7eQDSugJbhiz0XGbfvdX1pEtfu8p JxWlOEukbkPEUKdWC9r7t++mWS76ZCJh906oBoMdJd+bbr/kOKS9ja6ckb4bw56l0kso 0+Zw== X-Gm-Message-State: AOAM5315AvYBU8vX3Uf++mCdH6Iu3FL8CfmY/N1y7b8+/K/j4Pn8+Xd0 ef0vXWmyw2PrseFL+b12ubxr3/8RQ9c= X-Google-Smtp-Source: ABdhPJz9TwBlbs1HNi5wySySkAgOM1nNAHDw2tHcQuPbo17BeLgp5YA8R3Hqg7RN2FlM0aSxt66I9Q== X-Received: by 2002:a05:6214:2466:: with SMTP id im6mr8022417qvb.8.1643137794056; Tue, 25 Jan 2022 11:09:54 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09:53 -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 v6 7/9] rpcctl: Add a command for changing xprt state Date: Tue, 25 Jan 2022 14:09:44 -0500 Message-Id: <20220125190946.23586-8-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 0c6c9d0f006c..48e5dd502f3d 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 Tue Jan 25 19:09: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: 12724167 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 B5026C4167B for ; Tue, 25 Jan 2022 19:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbiAYTJ5 (ORCPT ); Tue, 25 Jan 2022 14:09:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiAYTJ4 (ORCPT ); Tue, 25 Jan 2022 14:09:56 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB824C06173B for ; Tue, 25 Jan 2022 11:09:55 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id g145so10311413qke.3 for ; Tue, 25 Jan 2022 11:09: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=cE4Nr/LA8O+LrDW/9Np3xTZgPYwdOkjrZK8wbRpHm68=; b=Wgy6Jd2bKj5pXUI+jF3aoPETdx65ZePhYS5ulN3RbOUnIJrgcXkYiG8qB3WjxLzhl1 MP67GUyWtANG8RJKoc6y84PLkkY6ZFW9FanPXQZiTSYl2koeh/ohnjSnJpSLAo0dsKXF iiX6JZ2/V274rRNF9w29EF/zPxMvfvKH5cN7Re0FsY2xcizejSShEFAXkX9G6CJWR357 4Nup8CrzaTt5xccuRs/TxgpgfK2vX0MYdRgKm1BYuXicCH4N5eIw9ysTRjOR+bIJ/SPl eJf8Mxg8npXNfytikxADbALIBlyqQxQ0NMbe6yQo0/KzFQVu7HSCzeeBMaE3gW9m9d4c JqSA== 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=cE4Nr/LA8O+LrDW/9Np3xTZgPYwdOkjrZK8wbRpHm68=; b=bf9O7L1l3uVFCLrpoQIC7iKwd6ZGr0erSR/ILp6pz60DJbfDH780+pVl7Q1lBic+fL UrLcgmUHCOtxgkkaJSCtuMO2lXAMeTnO+n/ZJuhUPk97HNgryZIytF2kH63A7Ro5UKNM oxxg3pYYaZKPOPMEc6KEcwsqgCrPhzvpD8XhYEzbaC9tz/x2SniIpG89ArFl0Zb26m/v FdGbbDSSYasN27mIHn+oXszHJLABlvYLjZCwHb4PfJHkLIvZ0D2J154WEoGSCNB66I3w VGjE0HCUbtnzNN2Q3OI4W7GIfoAfQ8ScRkDF4UvF9HvNRUYoQAsM5TssrXqwOSW0lPMW 6KBw== X-Gm-Message-State: AOAM530qkNNKR97Ai7XnrK+Z5PsJp8CGkqN8YCqGnYZtQn+WHJgXL58S pvg7fAZE1FALWXerI1OYEqE= X-Google-Smtp-Source: ABdhPJy3D3NsVrTV2IfaQ9uAahUxVMhqjfiOQjKHsieAKv9sHt7G7GzesKbwi5EWdCCS+1HjPfEppw== X-Received: by 2002:a05:620a:25ca:: with SMTP id y10mr15426356qko.526.1643137794844; Tue, 25 Jan 2022 11:09:54 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09: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 v6 8/9] rpcctl: Add a man page Date: Tue, 25 Jan 2022 14:09:45 -0500 Message-Id: <20220125190946.23586-9-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 Tue Jan 25 19:09: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: 12724168 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 6DE09C433FE for ; Tue, 25 Jan 2022 19:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbiAYTJ5 (ORCPT ); Tue, 25 Jan 2022 14:09:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbiAYTJ4 (ORCPT ); Tue, 25 Jan 2022 14:09:56 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ADE2C06173B for ; Tue, 25 Jan 2022 11:09:56 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id s6so19083342qvv.11 for ; Tue, 25 Jan 2022 11:09: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=pZQBiAFLbs2VhJ1f3T2tO0THO1pm036aexkSZmTc8zE=; b=mRixsWEtbcn13onoKBaGFPQZdl0WWFEO/Y3MZcXbaxhGswKqriN9CpjiJvUlVxt8BW HfYRncRf7vWOv2M9MsIGdPP3Ey7RnOwimmLgYXwR93YRXXMLmG/acinRoGm8TAT4pH4r fU4Tt052N/KsnkephGdgJ44dhtOrWbLTec1GNiUWn0mDbDuaQMUrows/RlzFm6ZgNscr 54ZBCBkUT69TaFQjnP3YP37k4zjRwuHd4kI7W9pXJLItX1QJBnsy5r3nTJVPWERfaD2o Loa/7yu/c7b+hNeHPBBFnr653hfRc4sgTONTgW5iksqOA6Y05nlyl6zAxPz0/QLLtRPV /igg== 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=pZQBiAFLbs2VhJ1f3T2tO0THO1pm036aexkSZmTc8zE=; b=K8rfitw65s6hbxvAuEFPQoqRU6L6ryMjteVe5gKZg6tY+qLwwBWKdGeSSFSOaJYFB0 cQYydjLH98ddve8KCGIAaHosdbzhCt5XWH3TUapXZrXdWfOkhnE3M7mLnSBRlJpx4DU+ BgpsT2hz9uyyRKoYttSUthLGFwyGGICkOnS2GMi/S8bXS9GYV5QCKQDsyA9Rwh0hQXyH nM5I/u54iHtihumtNC9aotDiNUb86VQqaNdinbQQSlq9dRh6uE6irSZKwnIaiWV6SfPb uEgpHbUhbzwmas1fW77MdUR0N1p8NHx3WQFeDMJSWIC1y0lGQbh0C+gbtifLAhdv0u2k NH1A== X-Gm-Message-State: AOAM530ZNLsAgodKhHggl/Uxxie4KXttjCrEhSx0+Dv5F2nYTisYTJuu wotxlk4xvCrwdhM3R8Mn/KY= X-Google-Smtp-Source: ABdhPJwZA2EuxS7R8WtwE51iDm3buSmRIif63R3OefMrbmvHXJSLsuu7HDDdmI8Vr+3QU+S2amhvuA== X-Received: by 2002:a05:6214:1c8a:: with SMTP id ib10mr21050967qvb.12.1643137795625; Tue, 25 Jan 2022 11:09:55 -0800 (PST) Received: from gouda.nowheycreamery.com ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id n6sm34802qtx.23.2022.01.25.11.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:09: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 v6 9/9] rpcctl: Add installation to the Makefile Date: Tue, 25 Jan 2022 14:09:46 -0500 Message-Id: <20220125190946.23586-10-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125190946.23586-1-Anna.Schumaker@Netapp.com> References: <20220125190946.23586-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 --- v6: Fix up the Makefile to account for this being a single file tool now --- 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