From patchwork Tue Jun 8 17:46:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12307803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 248AAC47082 for ; Tue, 8 Jun 2021 17:48:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10203610E5 for ; Tue, 8 Jun 2021 17:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233025AbhFHRuA (ORCPT ); Tue, 8 Jun 2021 13:50:00 -0400 Received: from mail-qk1-f177.google.com ([209.85.222.177]:46808 "EHLO mail-qk1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233821AbhFHRt7 (ORCPT ); Tue, 8 Jun 2021 13:49:59 -0400 Received: by mail-qk1-f177.google.com with SMTP id f70so5820240qke.13 for ; Tue, 08 Jun 2021 10:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4zJwskrhg2xmjIMfnlMJyQayKAwR6dqMI8RYPyrldHg=; b=G2XVAkNfsE2H48ajOG59ysiXM8URgdDTSZEGZDTHRHTY/AyGrdfDPM1uOPhePQgq52 C4dpYl+jU6cakMd12wIZXxvQ8WrUG89msGPlOyX1v12LLZ8JxfEuCnKRJCytIsG8rinG J55+zkixWbuZ9Obvy1khFvX/iC20QtMZJyHHzwfIZXTMXydRR8Z7I9XVDuCOlHuveWmG VHmPh3QIRX61o9XC+dpYojyUWHjEX9DxOP9WXA95d3ahj9s8eW4LhzgVJz8kuVH8Izg4 r+OWGCMH9p1FXFLO7gtCZbMgF1BxwFInIpcte9RGRnR/NMlVvU2c+U6R5XkbkSrQ9WkG lvQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4zJwskrhg2xmjIMfnlMJyQayKAwR6dqMI8RYPyrldHg=; b=CjuIqpNdnLSloOtJXYkCmPQwtUARFmkrDGwYqfHkWJxGEwLxVhjT+ld/s3I5BQHWpC CQtSOD3WX19jWox9PGmRbtgWjgEKyQHLi7cyvXHltYNoJ6sqXY1LzsyfiN/A6XintB1K jIHcQRVzLkmF+11wbPUDjuoEs7rMmjEbpStW6vNDSBYwoaA5LjDLt0i7aaOuVH3pGWba 2eTA1NCgVK8A5vT2Fjc6ifHUjbAozgjbHzxXwW5oqnWbPFLV5Xjk6QKrsHPfdYyuvkmr HLPzgQ6SxMlZS6kYOmUselVJ+5Q185oeOhwj69dOnbS7KMyGH/Db+vMdjk2X7dSQ4/YD Kk7w== X-Gm-Message-State: AOAM531x9hAF/cJwY/3ODmnxWopfzV0CZR99iPN01xuoT0V7XK2I6TJW PGDKld3jhsY2PHs1cHyt5dxDmn3fYpU= X-Google-Smtp-Source: ABdhPJxVEyR8A3MJNykG2W3iaDshS9ezryCtYkv1foVUu5bjLH9CBesxOA6zS2WrZRgRIWGBjtFlgg== X-Received: by 2002:a37:a548:: with SMTP id o69mr16965902qke.376.1623174419888; Tue, 08 Jun 2021 10:46:59 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id h2sm12963080qkf.106.2021.06.08.10.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 10:46:59 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [RFC PATCH 1/6] nfs-sysfs: Add an nfs-sysfs.py tool Date: Tue, 8 Jun 2021 13:46:52 -0400 Message-Id: <20210608174657.603256-2-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com> References: <20210608174657.603256-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 --- tools/nfs-sysfs/nfs-sysfs.py | 13 +++++++++++++ tools/nfs-sysfs/sysfs.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 tools/nfs-sysfs/nfs-sysfs.py create mode 100644 tools/nfs-sysfs/sysfs.py diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py new file mode 100755 index 000000000000..8ff59ea9e81b --- /dev/null +++ b/tools/nfs-sysfs/nfs-sysfs.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +import argparse +import sysfs + +parser = argparse.ArgumentParser() + +def show_small_help(args): + parser.print_usage() + print("sunrpc dir:", sysfs.SUNRPC) +parser.set_defaults(func=show_small_help) + +args = parser.parse_args() +args.func(args) diff --git a/tools/nfs-sysfs/sysfs.py b/tools/nfs-sysfs/sysfs.py new file mode 100644 index 000000000000..0b358f57bb28 --- /dev/null +++ b/tools/nfs-sysfs/sysfs.py @@ -0,0 +1,18 @@ +import pathlib +import sys + +MOUNT = None +with open("/proc/mounts", 'r') as f: + for line in f: + if "sysfs" in line: + MOUNT = line.split()[1] + break + +if MOUNT == None: + print("ERROR: sysfs is not mounted") + sys.exit(1) + +SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" +if not SUNRPC.is_dir(): + print("ERROR: sysfs does not have sunrpc directory") + sys.exit(1) From patchwork Tue Jun 8 17:46:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12307801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE5AC4743D for ; Tue, 8 Jun 2021 17:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23B1B6135D for ; Tue, 8 Jun 2021 17:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232152AbhFHRt4 (ORCPT ); Tue, 8 Jun 2021 13:49:56 -0400 Received: from mail-qk1-f172.google.com ([209.85.222.172]:43679 "EHLO mail-qk1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233905AbhFHRtz (ORCPT ); Tue, 8 Jun 2021 13:49:55 -0400 Received: by mail-qk1-f172.google.com with SMTP id j62so7251089qke.10 for ; Tue, 08 Jun 2021 10:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o9bYo5fP3VxJGTa5w7iwXg2aImIDXtHPxGkN8GuDhl0=; b=gAMjtCQKwKFWlchM0ww63AINde1n4aMJZ2HqjEpOnrN9PVrA1wHp/s+IUj+SkXLgpK a8WDZFVfLdIXjSUdOSpJVNJzIEWoicVheKrhxlyhvvFZaz025kqR8ExXB4r0tFG8AO8u glDVsJ/E7ItyXh70IxHYc5W7vkdRQ0qnHUUYaxIXASLaGyL9gB728NtQwGpAfxggk7p8 1CAf43yuKCW7ESbtqSlOEJ5CcVeGaeSKf6p5lsfno1eidak44ZkaJuIUhr9jo3L0JAnl WNmH5DIQHSZDYhMdKjlVi8gy+1uE/kF5f9yBULWv3HkEowGEDIrW3Dvf5l3QzeXvSEWd 12cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=o9bYo5fP3VxJGTa5w7iwXg2aImIDXtHPxGkN8GuDhl0=; b=WkOiBVoNEUOQhZinVXfZ/8F8F4ZyGIkQ0LizyobKaKma5EQvfXCsmkCT5NzyDcIODK Sfuhk0Ho63lm4yUEJWdsWizd1bwbsoGabBaavOywkH2vZvfwzWwj4XmtoAV1UH6mGYk9 t4yL80LgTsSSuRZZ9FmfdHLWgBo40xzrpbI9+arsYWYd1hS0S2Nj6ZUuuqjiq8n1qh05 0ePOpM/DHG8SUvZ0ZagQAwZAbqJp3VL1lSFKxuZM9QvjT1pcYwA7T4zH0wAP8N/SkcGo dZwPvknPdOow5hLRD5dB3emAMqnLnSMvIDK/as7mL0LrKm+XozJRlJoBTmj3A5eRk2hg IcPQ== X-Gm-Message-State: AOAM531hT9vF0LqBQxu805kWVAPnNU6+bF5oGDutIXUEJVEcoxgpZ2TX zCdyWpkAQOKVN+16pbxF1PORFJtWHQQ= X-Google-Smtp-Source: ABdhPJwqWkjVILKHUFgf0qV5jR/FIxbXE4fX5KgxCBWBlmTbscftYy9u3dnLDqsdbCDIxbPCQMfriA== X-Received: by 2002:a37:9d93:: with SMTP id g141mr22619366qke.350.1623174420791; Tue, 08 Jun 2021 10:47:00 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id h2sm12963080qkf.106.2021.06.08.10.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 10:47:00 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [RFC PATCH 2/6] nfs-sysfs.py: Add a command for printing xprt switch information Date: Tue, 8 Jun 2021 13:46:53 -0400 Message-Id: <20210608174657.603256-3-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com> References: <20210608174657.603256-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/nfs-sysfs/nfs-sysfs.py | 6 ++++++ tools/nfs-sysfs/switch.py | 35 +++++++++++++++++++++++++++++++++++ tools/nfs-sysfs/sysfs.py | 10 ++++++++++ tools/nfs-sysfs/xprt.py | 12 ++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tools/nfs-sysfs/switch.py create mode 100644 tools/nfs-sysfs/xprt.py diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py index 8ff59ea9e81b..90efcbed7ac8 100755 --- a/tools/nfs-sysfs/nfs-sysfs.py +++ b/tools/nfs-sysfs/nfs-sysfs.py @@ -9,5 +9,11 @@ def show_small_help(args): print("sunrpc dir:", sysfs.SUNRPC) parser.set_defaults(func=show_small_help) + +import switch +subparser = parser.add_subparsers(title="commands") +switch.add_command(subparser) + + args = parser.parse_args() args.func(args) diff --git a/tools/nfs-sysfs/switch.py b/tools/nfs-sysfs/switch.py new file mode 100644 index 000000000000..afb6963a0a1f --- /dev/null +++ b/tools/nfs-sysfs/switch.py @@ -0,0 +1,35 @@ +import sysfs +import xprt + +class XprtSwitch: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 1)[1]) + + self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] + self.xprts.sort() + + self.__dict__.update(sysfs.read_info_file(path / "xprt_switch_info")) + + def __lt__(self, rhs): + return self.path < rhs.path + + def __str__(self): + line = "switch %s: num_xprts %s, num_active %s, queue_len %s" % \ + (self.id, self.num_xprts, self.num_active, self.queue_len) + for x in self.xprts: + line += "\n %s" % x.small_str() + return line + + +def list_xprt_switches(args): + switches = [ XprtSwitch(f) for f in (sysfs.SUNRPC / "xprt-switches").iterdir() ] + switches.sort() + for xs in switches: + if args.id == None or xs.id == args.id[0]: + print(xs) + +def add_command(subparser): + parser = subparser.add_parser("xprt-switch", help="Commands for xprt switches") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") + parser.set_defaults(func=list_xprt_switches) diff --git a/tools/nfs-sysfs/sysfs.py b/tools/nfs-sysfs/sysfs.py index 0b358f57bb28..32dcf74438de 100644 --- a/tools/nfs-sysfs/sysfs.py +++ b/tools/nfs-sysfs/sysfs.py @@ -16,3 +16,13 @@ SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" if not SUNRPC.is_dir(): print("ERROR: sysfs does not have sunrpc directory") sys.exit(1) + + +def read_info_file(path): + res = dict() + with open(path) as info: + for line in info: + if "=" in line: + (key, val) = line.strip().split("=") + res[key] = int(val) + return res diff --git a/tools/nfs-sysfs/xprt.py b/tools/nfs-sysfs/xprt.py new file mode 100644 index 000000000000..d37537771c1d --- /dev/null +++ b/tools/nfs-sysfs/xprt.py @@ -0,0 +1,12 @@ +class Xprt: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 2)[1]) + self.type = str(path).rsplit("-", 2)[2] + self.dstaddr = open(path / "dstaddr", 'r').readline().strip() + + def __lt__(self, rhs): + return self.id < rhs.id + + def small_str(self): + return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr) From patchwork Tue Jun 8 17:46:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12307793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C52C47082 for ; Tue, 8 Jun 2021 17:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3691061370 for ; Tue, 8 Jun 2021 17:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233583AbhFHRs6 (ORCPT ); Tue, 8 Jun 2021 13:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbhFHRs4 (ORCPT ); Tue, 8 Jun 2021 13:48:56 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED3BAC061574 for ; Tue, 8 Jun 2021 10:47:02 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id u20so7682172qtx.1 for ; Tue, 08 Jun 2021 10:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z6FZgD22GFRX+KNepHUoNKIvyYh3M6iGZgZLu1+bisQ=; b=G7J/a9HzfPh8GmRG24DmjIadU54IYP4T1yjoC80GqhH3nbPPrgo8G1Qsl64QtfII/A nhe2diAmZujWcPEi0QyxuVrXqSpyZ9vHR5SDgpP6T2kFlkIYE9edVZIooWVRIAGSzAUd gHfxdsHcSLZD2XQxFGU/td00MkwTeOtEY89nEgP22APJbkBZjD2e2g1o8Ki7RJSwKFoM B+aURHSmb/8UBuiUa8f8PPRDSt/dJblWYe7EVDNfcseEVoIZ+l6t1JX5oyV4hAv2csV9 CO4qZyjDodpa6Tz2FGVO825ANgDXxUBAQdwUmrmSD5B5jbkUlN4xcp8Car2TqVsBmFCi aSeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=z6FZgD22GFRX+KNepHUoNKIvyYh3M6iGZgZLu1+bisQ=; b=aocFBus165vitwvjLy7Xfi4KxtJyp4wtgTX3jVjOTp5Irms8KnvWQPw3Lq4Gr09BZk 5E5E2ZNDf1/jGOtHtrrrRupwHcu/MxyDweVDA0XckMeDsWMGy35Mw6DBamxWnZYUqcR0 gTo2825y5xIlTDKw6AQUlg02+ZH59UEmvr3ukGnemS5h7tnt517qtoj2egmVE1SGu8Ew 55u7XWVQB1Pnr5y4QXCeHSNgezhE+TaOLu1HrsWNhLAlXdvM9CQ7n4FrKELbZqDjMLT4 fTjq6fWsIprKolEX81FqEpa4YQY5sNulfPGNyAGRGJH9sIqRBSU9QEZ2nv7ZWS5nQ1Ex OWEg== X-Gm-Message-State: AOAM532uKeJrEHpGZFxklk+L9H9x//CjHU0jPZwLd3up11Ry6IoSuuzx MuEm5XJvxNp5QYmD2VKm1xtPJ4G1d90= X-Google-Smtp-Source: ABdhPJwm3Ce+6Q5xZ27vkKO48t1JQcMkhua2BFg/dKCaMslNsqjtLbGLsqKtkwU8Lno/ycjWj7uWYA== X-Received: by 2002:a05:622a:100e:: with SMTP id d14mr1874630qte.254.1623174421494; Tue, 08 Jun 2021 10:47:01 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id h2sm12963080qkf.106.2021.06.08.10.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 10:47:01 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [RFC PATCH 3/6] nfs-sysfs.py: Add a command for printing individual xprts Date: Tue, 8 Jun 2021 13:46:54 -0400 Message-Id: <20210608174657.603256-4-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com> References: <20210608174657.603256-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. Signed-off-by: Anna Schumaker --- tools/nfs-sysfs/nfs-sysfs.py | 2 ++ tools/nfs-sysfs/xprt.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py index 90efcbed7ac8..dfad6ac08fa0 100755 --- a/tools/nfs-sysfs/nfs-sysfs.py +++ b/tools/nfs-sysfs/nfs-sysfs.py @@ -11,8 +11,10 @@ parser.set_defaults(func=show_small_help) import switch +import xprt subparser = parser.add_subparsers(title="commands") switch.add_command(subparser) +xprt.add_command(subparser) args = parser.parse_args() diff --git a/tools/nfs-sysfs/xprt.py b/tools/nfs-sysfs/xprt.py index d37537771c1d..b95fb2d48829 100644 --- a/tools/nfs-sysfs/xprt.py +++ b/tools/nfs-sysfs/xprt.py @@ -1,3 +1,5 @@ +import sysfs + class Xprt: def __init__(self, path): self.path = path @@ -5,8 +7,34 @@ class Xprt: self.type = str(path).rsplit("-", 2)[2] self.dstaddr = open(path / "dstaddr", 'r').readline().strip() + with open(path / "xprt_state") as f: + self.state = ','.join(f.readline().split()[1:]) + self.__dict__.update(sysfs.read_info_file(path / "xprt_info")) + def __lt__(self, rhs): return self.id < rhs.id + def __str__(self): + line = "xprt %s: %s, %s, state <%s>, num_reqs %s" % \ + (self.id, self.type, self.dstaddr, self.state, self.num_reqs) + line += "\n cur_cong %s, cong_win %s, min_num_slots %s, max_num_slots %s" % \ + (self.cur_cong, self.cong_win, self.min_num_slots, self.max_num_slots) + line += "\n binding_q_len %s, sending_q_len %s, pending_q_len %s, backlog_q_len %s" % \ + (self.binding_q_len, self.sending_q_len, self.pending_q_len, self.backlog_q_len) + return line + def small_str(self): return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr) + + +def list_xprts(args): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + xprts.sort() + for xprt in xprts: + if args.id == None or xprt.id == args.id[0]: + print(xprt) + +def add_command(subparser): + parser = subparser.add_parser("xprt", help="Commands for individual xprts") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") + parser.set_defaults(func=list_xprts) From patchwork Tue Jun 8 17:46:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12307799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAC39C4743E for ; Tue, 8 Jun 2021 17:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE94B610E5 for ; Tue, 8 Jun 2021 17:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233425AbhFHRt4 (ORCPT ); Tue, 8 Jun 2021 13:49:56 -0400 Received: from mail-qt1-f177.google.com ([209.85.160.177]:42532 "EHLO mail-qt1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233843AbhFHRt4 (ORCPT ); Tue, 8 Jun 2021 13:49:56 -0400 Received: by mail-qt1-f177.google.com with SMTP id v6so7014736qta.9 for ; Tue, 08 Jun 2021 10:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VXO6A1fFPYXH5Z8ZqtWOt/eu1D5T/QlkTGPxMiAjCkY=; b=f8q9o4AKu+5vJSZwSvTndNsy1iKfxFbxQm5KQfw4UyLgnDRtaI9OgAZtG6173wwFbp qM4R59MT9cOVmtdAB461BebnPNvOlZ1qrt5CL2OHckLIo21jbU985zBBsgi199+Guski zFoVGkg9W7ID0hzzNMrNvXm26UxXA86AP4T1+77xekaBfaL/c2M2If+ZKV2kLMljGCI5 N7qweu2Tr6mpRo0fJVbpcXezPCuAZ0EnfkS9LrZUFOXqLfkJeMdSXBXzgoMSLumBmgfC yiNNzDqx2V3Ff+sOCCJjPbwofPAuBUO/CbJ+XsEkKZrrBOeqXGWDP9AMH7nfE4i+FRBI nItw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VXO6A1fFPYXH5Z8ZqtWOt/eu1D5T/QlkTGPxMiAjCkY=; b=YToU2Z97i7+vohVVe395AH3NrzlpKLRmrcWdl8SfkoqVO21RlZ4RIbDcs/vWyB+piB juf7zPTHEAvUCuZxMRNG6Nx6CP+hY7rTB/rmPYdJ+FgC+42xdxp4KN8xwher3+JsOHMe 9bO/CSEI49EaRYYDYFKLgonfVAbLl2PHl2b/67PUD05OVwZV6kQbXvIcX6n4uBwylq+T vHZFh707nD76csYQRVLLW0Qd0ZmvlGW9cMKIdpCtQh2Uq9JrKyiCI5m4CO1vqpwuHAtL IzP4a2e/b7B8ApBgpq1h+Ab9orCl5gm84xqoit1lvymsRIF4JcYKxQur7gdm+GLrRm95 KzBw== X-Gm-Message-State: AOAM532/qQ6n7tamxnnvwe+ZQzSgdCs713sjYc/afkTdF3SxNas49lxb jua3lPMuDDV+dJVTz/LzlFa0kfRLfCc= X-Google-Smtp-Source: ABdhPJwhVLo6vdmwiveE3wJkGWBUAZQtmqVtOfPYmxA4+1QHAAOL7o3/EsUB1Bxsnr9poLaTJ48LeA== X-Received: by 2002:ac8:6f37:: with SMTP id i23mr23006262qtv.376.1623174422281; Tue, 08 Jun 2021 10:47:02 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id h2sm12963080qkf.106.2021.06.08.10.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 10:47:01 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [RFC PATCH 4/6] nfs-sysfs.py: Add a command for printing rpc-client information Date: Tue, 8 Jun 2021 13:46:55 -0400 Message-Id: <20210608174657.603256-5-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com> References: <20210608174657.603256-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/nfs-sysfs/client.py | 27 +++++++++++++++++++++++++++ tools/nfs-sysfs/nfs-sysfs.py | 2 ++ tools/nfs-sysfs/switch.py | 7 ++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tools/nfs-sysfs/client.py diff --git a/tools/nfs-sysfs/client.py b/tools/nfs-sysfs/client.py new file mode 100644 index 000000000000..5192cc226aed --- /dev/null +++ b/tools/nfs-sysfs/client.py @@ -0,0 +1,27 @@ +import sysfs +import switch + +class RpcClient: + def __init__(self, path): + self.path = path + self.id = int(str(path).rsplit("-", 1)[1]) + self.switch = switch.XprtSwitch(path / (path / "switch").readlink(), sep=",") + + def __lt__(self, rhs): + return self.id < rhs.id + + def __str__(self): + return "client %s: %s" % (self.id, self.switch) + + +def list_rpc_clients(args): + clients = [ RpcClient(f) for f in (sysfs.SUNRPC / "rpc-clients").iterdir() ] + clients.sort() + for client in clients: + if args.id == None or client.id == args.id[0]: + print(client) + +def add_command(subparser): + parser = subparser.add_parser("rpc-client", help="Commands for rpc clients") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific client to show") + parser.set_defaults(func=list_rpc_clients) diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py index dfad6ac08fa0..e2172cdfa4c1 100755 --- a/tools/nfs-sysfs/nfs-sysfs.py +++ b/tools/nfs-sysfs/nfs-sysfs.py @@ -10,9 +10,11 @@ def show_small_help(args): parser.set_defaults(func=show_small_help) +import client import switch import xprt subparser = parser.add_subparsers(title="commands") +client.add_command(subparser) switch.add_command(subparser) xprt.add_command(subparser) diff --git a/tools/nfs-sysfs/switch.py b/tools/nfs-sysfs/switch.py index afb6963a0a1f..5384f970235c 100644 --- a/tools/nfs-sysfs/switch.py +++ b/tools/nfs-sysfs/switch.py @@ -2,9 +2,10 @@ import sysfs import xprt class XprtSwitch: - def __init__(self, path): + def __init__(self, path, sep=":"): self.path = path self.id = int(str(path).rsplit("-", 1)[1]) + self.sep = sep self.xprts = [ xprt.Xprt(p) for p in self.path.iterdir() if p.is_dir() ] self.xprts.sort() @@ -15,8 +16,8 @@ class XprtSwitch: return self.path < rhs.path def __str__(self): - line = "switch %s: num_xprts %s, num_active %s, queue_len %s" % \ - (self.id, self.num_xprts, self.num_active, self.queue_len) + line = "switch %s%s num_xprts %s, num_active %s, queue_len %s" % \ + (self.id, self.sep, self.num_xprts, self.num_active, self.queue_len) for x in self.xprts: line += "\n %s" % x.small_str() return line From patchwork Tue Jun 8 17:46:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12307805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 674A4C47082 for ; Tue, 8 Jun 2021 17:48:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54E21610E5 for ; Tue, 8 Jun 2021 17:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbhFHRuL (ORCPT ); Tue, 8 Jun 2021 13:50:11 -0400 Received: from mail-qt1-f178.google.com ([209.85.160.178]:43545 "EHLO mail-qt1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233156AbhFHRuL (ORCPT ); Tue, 8 Jun 2021 13:50:11 -0400 Received: by mail-qt1-f178.google.com with SMTP id 93so8577846qtc.10 for ; Tue, 08 Jun 2021 10:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A8+RkubmhiUGlgMZbxD8YgREz+LPON5cuR6XCKvqkKU=; b=UV9LDJyyYQiH4bFg6ZAbkNJ/HBa7XAn7CfH5eQXO7AGVQAXttO0QcVKyKWOHehu5Fq 0Ju82HCWsZGlbJKjQ1mw4wKv7KYxtYpC9IGg1KfsIBx9WGZIgEOEquSOLS+YTslu3A41 ylymGAubhxyWP5RmhqyZQ6z9WVjE3BFYIb9hUFeRl+OOrNUUJUuwySPQ8727Oc3kBM9G hmmBTWQrI3wnHfXdySTDtuxb0OzSX+oggwnwjQeGhdvRQJ5lnRmCDq/SFkeUD/WGMwT6 eFTDOsEapImga+mC+j01UFk6AlzMNJRva6OUNeCwH8IJN/Vo0+Whi3coKCT3l0TizA8k b4gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=A8+RkubmhiUGlgMZbxD8YgREz+LPON5cuR6XCKvqkKU=; b=V0Z2tggaun0Qo+71bvPwNX28Fa7KjHl5auy/ttEuBjanoUBYnr4jjaSfC0PadyiZ1b E2iyrjYk0kOJ+2XCzFa6bk/giH3r33LM7LTmdGyJCEptF1OJKHt5gFrBRgDktMpEd/yg BUxhDqOkJ79u3BnjW9CmCkxWsNpUE072fi2IjNWmnrc4F/1Xl90loXVsyLyHz6Lo1ZE7 vCWnFfPsWmS22YVGfMnr/e9Ixdmq048Gck6XVwdZrT6SnWyxXfKq6v3gVABfJ0Vn4uya h5kIZBTNdOjidfIlWfDL+1yyt2/Wc0ikb3Tu+cXjPkbjkQaE1IV7NRreWHTCyBYJFNTy +4lg== X-Gm-Message-State: AOAM5333bh0MnhdSTdhMck34R21J5RKDeYBj2GxDbBjb+0OD0z6cVwA/ caNpBnDgU+ZZT5RFAPqE4DBJDY+bNRs= X-Google-Smtp-Source: ABdhPJz6RCLbNA97dFXuGMZoCdhNjD1tmWB98ZF51N/CHZE7W6rIAmSaF/eHbik+hBzkYku06oxr+A== X-Received: by 2002:ac8:5894:: with SMTP id t20mr9687073qta.281.1623174422980; Tue, 08 Jun 2021 10:47:02 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id h2sm12963080qkf.106.2021.06.08.10.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 10:47:02 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [RFC PATCH 5/6] nfs-sysfs.py: Add a command for changing xprt dstaddr Date: Tue, 8 Jun 2021 13:46:56 -0400 Message-Id: <20210608174657.603256-6-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com> References: <20210608174657.603256-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/nfs-sysfs/xprt.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/nfs-sysfs/xprt.py b/tools/nfs-sysfs/xprt.py index b95fb2d48829..167e5fa69df7 100644 --- a/tools/nfs-sysfs/xprt.py +++ b/tools/nfs-sysfs/xprt.py @@ -1,3 +1,4 @@ +import socket import sysfs class Xprt: @@ -26,6 +27,12 @@ class Xprt: def small_str(self): return "xprt %s: %s, %s" % (self.id, self.type, self.dstaddr) + def set_dstaddr(self, newaddr): + resolved = socket.gethostbyname(newaddr) + with open(self.path / "dstaddr", 'w') as f: + f.write(resolved) + self.dstaddr = open(self.path / "dstaddr", 'r').readline().strip() + def list_xprts(args): xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] @@ -34,7 +41,28 @@ def list_xprts(args): if args.id == None or xprt.id == args.id[0]: print(xprt) +def get_xprt(id): + xprts = [ Xprt(f) for f in (sysfs.SUNRPC / "xprt-switches").glob("**/xprt-*") ] + for xprt in xprts: + if xprt.id == id: + return xprt + +def set_xprt_property(args): + xprt = get_xprt(args.id[0]) + try: + if args.dstaddr != None: + xprt.set_dstaddr(args.dstaddr[0]) + print(xprt) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt to show") parser.set_defaults(func=list_xprts) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of a specific xprt to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_property) From patchwork Tue Jun 8 17:46:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 12307795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E008C47082 for ; Tue, 8 Jun 2021 17:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 180C361370 for ; Tue, 8 Jun 2021 17:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232246AbhFHRtO (ORCPT ); Tue, 8 Jun 2021 13:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232152AbhFHRtO (ORCPT ); Tue, 8 Jun 2021 13:49:14 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDCEDC061789 for ; Tue, 8 Jun 2021 10:47:04 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id c124so21025423qkd.8 for ; Tue, 08 Jun 2021 10:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l3qsx1hJN4Ap0lnfTXiXGiNo7EkyOjgXvMFg3+Yut7o=; b=F0ruDejcrs5RFshNAjQFktssQ80D+Sac0aTt88+eXaTQ08EL6jQirlNbcs4IXqkMSd mP+KUidnpAqu/lXhnSX+ue74w4bK2ypF+v3WZEkXyUg3BekgHuOvitEthOd0shbUYaLi +PgC289lZsB8UMZISo9oRR8lhoQqcNDk/+kpeXvSzQLm5KWqoEig+X5tmTAvsehEaBIh LlABj/7w9+bTYhP4RzJCuHGwP9fqqMVNvN36kC7hyHJjf0ZsJPQCeUB7rehooHLESEz1 Li/QtGMmKbQRdEbdW+J7etE0Uan7/20jbtK/lSB0XilesPuE64MbrrGfCw8zTHjhCnd1 BMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=l3qsx1hJN4Ap0lnfTXiXGiNo7EkyOjgXvMFg3+Yut7o=; b=OjVrPutDO4hu6Hc+v1cllPnHRsm4c3MYl+CvdOlEyqrypFdar08pGSo0kITH9HAQri N4AordmV0h3hTypzdUs66PMOcLLAjRe5+WHUQiv9qJSiqrPSEWmw5k+/duL1ESB3cHwf 5YzCS9iPWr3E1m5IBobC3NWbXZBVu8eTUVrwznqHOLvXlgUQYoFN0lwC+q0gH4GZP0SE cpf1vJft7Ssdf1OwRC5MLhGAUAaQLVRtPa0FvhvQWd2osAiBHDqmsRTo/M0Yr79IeOCK rdQiQXy3CQNJ0KbeUW3agNj0xgNfrMWnFwCOg2YpUrsAzEp6XJCknD2nLEGryN9O+uQ/ sB+g== X-Gm-Message-State: AOAM531vqFIL1I2MRoiVRIU6O+uaE/F3s/NWuk5VDWOxZjL9mj98sMm8 YH6HbxDVdNLG7+dGuXTmlYCsftLRt40= X-Google-Smtp-Source: ABdhPJwCqUDdpg+7gUnL/ZS/eXl/FXcuYLnuibXEJAuVJPEjM/vEOFV6TIkrsGWk54tv1pbHA1Qg/Q== X-Received: by 2002:a05:620a:20d7:: with SMTP id f23mr22138037qka.484.1623174423786; Tue, 08 Jun 2021 10:47:03 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id h2sm12963080qkf.106.2021.06.08.10.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 10:47:03 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [RFC PATCH 6/6] nfs-sysfs.py: Add a command for changing xprt-switch dstaddrs Date: Tue, 8 Jun 2021 13:46:57 -0400 Message-Id: <20210608174657.603256-7-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com> References: <20210608174657.603256-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/nfs-sysfs/switch.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/nfs-sysfs/switch.py b/tools/nfs-sysfs/switch.py index 5384f970235c..859b82e07895 100644 --- a/tools/nfs-sysfs/switch.py +++ b/tools/nfs-sysfs/switch.py @@ -30,7 +30,22 @@ def list_xprt_switches(args): if args.id == None or xs.id == args.id[0]: print(xs) +def set_xprt_switch_property(args): + switch = XprtSwitch(sysfs.SUNRPC / "xprt-switches" / f"switch-{args.id[0]}") + try: + for xprt in switch.xprts: + xprt.set_dstaddr(args.dstaddr[0]) + print(switch) + except Exception as e: + print(e) + def add_command(subparser): parser = subparser.add_parser("xprt-switch", help="Commands for xprt switches") parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show") parser.set_defaults(func=list_xprt_switches) + + subparser = parser.add_subparsers() + parser = subparser.add_parser("set", help="Set an xprt switch property") + parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of an xprt-switch to modify") + parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set") + parser.set_defaults(func=set_xprt_switch_property)