From patchwork Thu Apr 15 02:27:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204103 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.7 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 ACAEAC43460 for ; Thu, 15 Apr 2021 02:28:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EDDA611CC for ; Thu, 15 Apr 2021 02:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbhDOC23 (ORCPT ); Wed, 14 Apr 2021 22:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhDOC23 (ORCPT ); Wed, 14 Apr 2021 22:28:29 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A52C061574 for ; Wed, 14 Apr 2021 19:28:07 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id p8so1331083iol.11 for ; Wed, 14 Apr 2021 19:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u9ug9QkihPteu4k4ujdR3vfO9jchp59V55TcHSq8jHs=; b=PlDtObg52KAjmy8k0ddoefVBpw1ytrIo0h3hCATqCm9Qco05fuQO4BU/Ag4M8PrnIX ovsA6a1WrqXYGK/hxjxGaLUVIiH8scN33oSOIdzlZaEJO2Tj80QQPW7jgBBcqSkfN+hh ZUwpplXOGWlwdaVA/eR0EQVhIqCSLZu9WPn9oMQdujdL4DlYlQNkunqPkiJxFc7vjrba yoXyrY/XdtNyia7ZJmLBMgm1BEyYXGYtzXXjHLTgpFz6WuQFmTbGWmO8kSAFMBsZcj2q ZkciFz6tu1SZe35GWOOCH87QFdlzmZKMuZn+XdaOzmdB70ssEnN5PD6+S+VZM3H3ux4W JwTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u9ug9QkihPteu4k4ujdR3vfO9jchp59V55TcHSq8jHs=; b=HrtAbq1/zKkubEqryeKhq7OojRoclWIEBNTaG3wm9SHK7ilV1VJzJD1mfiD88/Ymos 7edD8r3ymd3Fc7x6JLrQ4oYPEU0oLDJaktDpLfB2WhPgHnj7/yYVC7spN6RVmYX1HgHw 0Bnkl9Wrg1jiEkFmWYIJZA1t1MraimDEYrJX3fmC/qjXtjSfV4d8HJKecQFZpr+KPyI8 sIqTik+J7sT3dCgXEeEKjiX7e1VwbUCwX9UjyB50rQJRXlbV6F5kKOO/hu+wyibFArh1 DcBHiE8tO7MsdSECJTk32AECM6g0j9d2Lk2n4jP2LFT9ZbgHQN9LBvX1rAEWMuJrQaBO urmg== X-Gm-Message-State: AOAM532s/aFXX9e3t/JOLUSmC/SAlHC6WOoNdge0lSPcCTGASeOianDM r8a1vZ1mMZTkYP3/3nPyMp4= X-Google-Smtp-Source: ABdhPJwo/T+yMlnDQfOUysqaSAbBiaybDuPFcgGD94VFZ+4clVX2Q9BidoGk/LX8LOQI9GFXQqlqUg== X-Received: by 2002:a6b:d309:: with SMTP id s9mr843201iob.186.1618453686674; Wed, 14 Apr 2021 19:28:06 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:06 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 01/13] sunrpc: Create a sunrpc directory under /sys/kernel/ Date: Wed, 14 Apr 2021 22:27:50 -0400 Message-Id: <20210415022802.31692-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia This is where we'll put per-rpc_client related files Signed-off-by: Anna Schumaker --- net/sunrpc/Makefile | 2 +- net/sunrpc/sunrpc_syms.c | 8 ++++++++ net/sunrpc/sysfs.c | 20 ++++++++++++++++++++ net/sunrpc/sysfs.h | 11 +++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 net/sunrpc/sysfs.c create mode 100644 net/sunrpc/sysfs.h diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile index 9488600451e8..1c8de397d6ad 100644 --- a/net/sunrpc/Makefile +++ b/net/sunrpc/Makefile @@ -12,7 +12,7 @@ sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ auth.o auth_null.o auth_unix.o \ svc.o svcsock.o svcauth.o svcauth_unix.o \ addr.o rpcb_clnt.o timer.o xdr.o \ - sunrpc_syms.o cache.o rpc_pipe.o \ + sunrpc_syms.o cache.o rpc_pipe.o sysfs.o \ svc_xprt.o \ xprtmultipath.o sunrpc-$(CONFIG_SUNRPC_DEBUG) += debugfs.o diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 236fadc4a439..3b57efc692ec 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -24,6 +24,7 @@ #include #include "sunrpc.h" +#include "sysfs.h" #include "netns.h" unsigned int sunrpc_net_id; @@ -103,6 +104,10 @@ init_sunrpc(void) if (err) goto out4; + err = rpc_sysfs_init(); + if (err) + goto out5; + sunrpc_debugfs_init(); #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) rpc_register_sysctl(); @@ -111,6 +116,8 @@ init_sunrpc(void) init_socket_xprt(); /* clnt sock transport */ return 0; +out5: + unregister_rpc_pipefs(); out4: unregister_pernet_subsys(&sunrpc_net_ops); out3: @@ -124,6 +131,7 @@ init_sunrpc(void) static void __exit cleanup_sunrpc(void) { + rpc_sysfs_exit(); rpc_cleanup_clids(); rpcauth_remove_module(); cleanup_socket_xprt(); diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c new file mode 100644 index 000000000000..27eda180ac5e --- /dev/null +++ b/net/sunrpc/sysfs.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2020 Anna Schumaker + */ +#include + +static struct kset *rpc_sunrpc_kset; + +int rpc_sysfs_init(void) +{ + rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); + if (!rpc_sunrpc_kset) + return -ENOMEM; + return 0; +} + +void rpc_sysfs_exit(void) +{ + kset_unregister(rpc_sunrpc_kset); +} diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h new file mode 100644 index 000000000000..f181c650aab8 --- /dev/null +++ b/net/sunrpc/sysfs.h @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2020 Anna Schumaker + */ +#ifndef __SUNRPC_SYSFS_H +#define __SUNRPC_SYSFS_H + +int rpc_sysfs_init(void); +void rpc_sysfs_exit(void); + +#endif From patchwork Thu Apr 15 02:27:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204105 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.7 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 35DB1C433B4 for ; Thu, 15 Apr 2021 02:28:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1632D611B0 for ; Thu, 15 Apr 2021 02:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbhDOC2d (ORCPT ); Wed, 14 Apr 2021 22:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhDOC2a (ORCPT ); Wed, 14 Apr 2021 22:28:30 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C892C061574 for ; Wed, 14 Apr 2021 19:28:08 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id a9so11863349ioc.8 for ; Wed, 14 Apr 2021 19:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nom4IkQ3SY1Lnfz/M9qTAf+h9BHJgOxm0EDZubW34+U=; b=aZ824QguDiImUhPn8iV1xsQdgMueZyWH2szwtX4BLZJhfarYU8kRHP+dHR3LqhNOD2 lZx0Wl1NgDlU/WbYa66PXR0ZBzrZUkPQa17M+jsHobfU7ELYRYH6PbxqCXm5+fA4TVs6 EMkqeC5nFEORNaG4bGYoBwfeOeBDVrw8w3vkHAWBw9zZIi2dA+A8kv4ihZlgeec0t5nI XIzWvEl2tAaf8w/zTBz0JNc1gYQljG2CqMWUDqzLG/rODxXY9X938PKrhpQ0bsKqA8Qw ppQd88XF6YrV7gUziCamVgAsS9wIIlZS+fUHR/RGCmVNDyAU7oT2HKc+k4pnBFllwOXd Xoww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nom4IkQ3SY1Lnfz/M9qTAf+h9BHJgOxm0EDZubW34+U=; b=OAbRK8lF6AlQ2EL9H537BukkzQtBUN/2XizqDaQCXXJ6EgQ5HMjwW0XqRC8Rl9HFIh yJaDluyMLumJEFGExYVGU6grMHejMBNTXXdcWoBKuTNp6wELGoZRxP5FnIjSvQzj4ioI a5eOCTwpky9hEtn0iNSQe218jEBbiaK12iFfTenfvBOxYOJ731ld23jGJSNAjFhJwPVw pJlkAi7BMaEGNoZM4LKm307Jt0dxQ/b0EGgNj8qJK59AujFTRkL1aNBpRX4H8oPTl2ei sND2iC8nH9u+KzRDwdNVLBvl+GePinx+/nHIFhbKvru5gF95729Vq3FORNDf9dGfU1qg /Q9Q== X-Gm-Message-State: AOAM533/Vm4CluK+JAaYzia+Bohu60OdeV6EiWe3XQs83Tpg0rRrVSko PamBEAo5Roi5W+UuIQcNAecdOSA8gmg= X-Google-Smtp-Source: ABdhPJzCHgtunFWK7H8XK9/hz4DUHL9C/zAHgYAi+ZOPGweEyKNC0ZTKuZqV4ZEAI6Csxd6AvLls+g== X-Received: by 2002:a05:6638:168e:: with SMTP id f14mr857326jat.49.1618453687834; Wed, 14 Apr 2021 19:28:07 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:07 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 02/13] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Date: Wed, 14 Apr 2021 22:27:51 -0400 Message-Id: <20210415022802.31692-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia For network namespace separation. Signed-off-by: Anna Schumaker --- net/sunrpc/sysfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 27eda180ac5e..6be3f4cfac95 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -2,19 +2,61 @@ /* * Copyright (c) 2020 Anna Schumaker */ +#include #include static struct kset *rpc_sunrpc_kset; +static struct kobject *rpc_sunrpc_client_kobj; + +static void rpc_sysfs_object_release(struct kobject *kobj) +{ + kfree(kobj); +} + +static const struct kobj_ns_type_operations * +rpc_sysfs_object_child_ns_type(struct kobject *kobj) +{ + return &net_ns_type_operations; +} + +static struct kobj_type rpc_sysfs_object_type = { + .release = rpc_sysfs_object_release, + .sysfs_ops = &kobj_sysfs_ops, + .child_ns_type = rpc_sysfs_object_child_ns_type, +}; + +static struct kobject *rpc_sysfs_object_alloc(const char *name, + struct kset *kset, struct kobject *parent) +{ + struct kobject *kobj; + + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (kobj) { + kobj->kset = kset; + if (kobject_init_and_add(kobj, &rpc_sysfs_object_type, + parent, "%s", name) == 0) + return kobj; + kobject_put(kobj); + } + return NULL; +} int rpc_sysfs_init(void) { rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); if (!rpc_sunrpc_kset) return -ENOMEM; + rpc_sunrpc_client_kobj = rpc_sysfs_object_alloc("client", rpc_sunrpc_kset, NULL); + if (!rpc_sunrpc_client_kobj) { + kset_unregister(rpc_sunrpc_kset); + rpc_sunrpc_client_kobj = NULL; + return -ENOMEM; + } return 0; } void rpc_sysfs_exit(void) { + kobject_put(rpc_sunrpc_client_kobj); kset_unregister(rpc_sunrpc_kset); } From patchwork Thu Apr 15 02:27:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204107 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=-12.9 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,UNWANTED_LANGUAGE_BODY, 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 D67ECC433ED for ; Thu, 15 Apr 2021 02:28:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6E63611B0 for ; Thu, 15 Apr 2021 02:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbhDOC2f (ORCPT ); Wed, 14 Apr 2021 22:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbhDOC2d (ORCPT ); Wed, 14 Apr 2021 22:28:33 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D4AC061574 for ; Wed, 14 Apr 2021 19:28:09 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id e186so22726845iof.7 for ; Wed, 14 Apr 2021 19:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HnBOGatoUzfHsoF4SPjvo08DYGg8lp0vHYCOJc99zbs=; b=S/Paujwr/HnkhbX2O09IsL6K8UztJLYzb17pTWoNg0JaEhbBAeTsfq9Nq25u64fzxr yy2MihsmaEqoGpNvQoxAuxign1u0UD44RDtHgNDyTstgrp6MTt5OMzDVepgTlkkPBjEb ZuJa/fv2V8RaOHCSJZ9zyJZCNYEjuydxSmxszl3cyKjyf+L6ZGmKQgF2dLIpDQxn+MCQ TO7eNPtY2CeED9zvPth1IvE3eHVxh6dEiElJxajhWggWgptsTWaKlTzQuiGEZT2vRx0S PIhMyVFpJ9vUedF2QmRkiRN4IzJA2NYNtu9C7vUjk4HwBgaC2uH0hFvqIiHdss3Gtdvg h/wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HnBOGatoUzfHsoF4SPjvo08DYGg8lp0vHYCOJc99zbs=; b=tF0q/tc5RkcwZ3Rc/AtAX87jpYat2IsmVR79oDmIat49cFoLwLPZREljGerFEShaHl 9Cde/KqVxZYRP6OfSasP0Sr6h+cn5pA3osyxXeBqWK47aPkDwi2eHflqUQzQ5ZFz/hri l9XQbit8oY74DnyaassLcVqr/3UxsHHgtCwz/6RGQgAgHWOANeFx6pP5Tp+mHWr3GNdP MOEsqfghAmCfqlASzrTqFy1gxteU/ACbr0xW6d73jrvdSVpexz9JTJEekjpnRw9fsqTU TkXr9agDhAfnP4bpGAuye0XAxZxOvwbfky4TiHXwnD5FsTF9ULVB2z+NSNs3lxbY4Zb+ 9amQ== X-Gm-Message-State: AOAM5313NkZj8W4C36jMYqOz00G+k4RSN0TkCrqVX0eUMMItk9LlMoce LyyvM/S7TRuIcXGvBCO09Io= X-Google-Smtp-Source: ABdhPJwaV9JVj/ZQAYT8aP81cfWizcWxSUkvqhQJVeNl7V9yVm3TWMgRFJMnNkhpFzPKo1DSv7sL4w== X-Received: by 2002:a6b:f909:: with SMTP id j9mr863268iog.138.1618453688965; Wed, 14 Apr 2021 19:28:08 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:08 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 03/13] sunrpc: Create per-rpc_clnt sysfs kobjects Date: Wed, 14 Apr 2021 22:27:52 -0400 Message-Id: <20210415022802.31692-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia These will eventually have files placed under them for sysfs operations. Signed-off-by: Anna Schumaker --- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 5 +++ net/sunrpc/sysfs.c | 61 +++++++++++++++++++++++++++++++++++++ net/sunrpc/sysfs.h | 8 +++++ 4 files changed, 75 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 02e7a5863d28..503653720e18 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -71,6 +71,7 @@ struct rpc_clnt { #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) struct dentry *cl_debugfs; /* debugfs directory */ #endif + void *cl_sysfs; /* sysfs directory */ /* cl_work is only needed after cl_xpi is no longer used, * and that are of similar size */ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 612f0a641f4c..ceb8d19d4cb4 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -41,6 +41,7 @@ #include #include "sunrpc.h" +#include "sysfs.h" #include "netns.h" #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) @@ -300,6 +301,7 @@ static int rpc_client_register(struct rpc_clnt *clnt, int err; rpc_clnt_debugfs_register(clnt); + rpc_sysfs_client_setup(clnt, net); pipefs_sb = rpc_get_sb_net(net); if (pipefs_sb) { @@ -327,6 +329,7 @@ static int rpc_client_register(struct rpc_clnt *clnt, out: if (pipefs_sb) rpc_put_sb_net(net); + rpc_sysfs_client_destroy(clnt); rpc_clnt_debugfs_unregister(clnt); return err; } @@ -733,6 +736,7 @@ int rpc_switch_client_transport(struct rpc_clnt *clnt, rpc_unregister_client(clnt); __rpc_clnt_remove_pipedir(clnt); + rpc_sysfs_client_destroy(clnt); rpc_clnt_debugfs_unregister(clnt); /* @@ -879,6 +883,7 @@ static void rpc_free_client_work(struct work_struct *work) * so they cannot be called in rpciod, so they are handled separately * here. */ + rpc_sysfs_client_destroy(clnt); rpc_clnt_debugfs_unregister(clnt); rpc_free_clid(clnt); rpc_clnt_remove_pipedir(clnt); diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 6be3f4cfac95..d14d54f33c65 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -4,6 +4,7 @@ */ #include #include +#include "sysfs.h" static struct kset *rpc_sunrpc_kset; static struct kobject *rpc_sunrpc_client_kobj; @@ -55,8 +56,68 @@ int rpc_sysfs_init(void) return 0; } +static void rpc_sysfs_client_release(struct kobject *kobj) +{ + struct rpc_sysfs_client *c; + + c = container_of(kobj, struct rpc_sysfs_client, kobject); + kfree(c); +} + +static const void *rpc_sysfs_client_namespace(struct kobject *kobj) +{ + return container_of(kobj, struct rpc_sysfs_client, kobject)->net; +} + +static struct kobj_type rpc_sysfs_client_type = { + .release = rpc_sysfs_client_release, + .sysfs_ops = &kobj_sysfs_ops, + .namespace = rpc_sysfs_client_namespace, +}; + void rpc_sysfs_exit(void) { kobject_put(rpc_sunrpc_client_kobj); kset_unregister(rpc_sunrpc_kset); } + +static struct rpc_sysfs_client *rpc_sysfs_client_alloc(struct kobject *parent, + struct net *net, + int clid) +{ + struct rpc_sysfs_client *p; + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (p) { + p->net = net; + p->kobject.kset = rpc_sunrpc_kset; + if (kobject_init_and_add(&p->kobject, &rpc_sysfs_client_type, + parent, "clnt-%d", clid) == 0) + return p; + kobject_put(&p->kobject); + } + return NULL; +} + +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net) +{ + struct rpc_sysfs_client *rpc_client; + + rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, net, clnt->cl_clid); + if (rpc_client) { + clnt->cl_sysfs = rpc_client; + kobject_uevent(&rpc_client->kobject, KOBJ_ADD); + } +} + +void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) +{ + struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; + + if (rpc_client) { + kobject_uevent(&rpc_client->kobject, KOBJ_REMOVE); + kobject_del(&rpc_client->kobject); + kobject_put(&rpc_client->kobject); + clnt->cl_sysfs = NULL; + } +} diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index f181c650aab8..c46afc848993 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -5,7 +5,15 @@ #ifndef __SUNRPC_SYSFS_H #define __SUNRPC_SYSFS_H +struct rpc_sysfs_client { + struct kobject kobject; + struct net *net; +}; + int rpc_sysfs_init(void); void rpc_sysfs_exit(void); +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net); +void rpc_sysfs_client_destroy(struct rpc_clnt *clnt); + #endif From patchwork Thu Apr 15 02:27:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204109 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.7 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 6F999C43460 for ; Thu, 15 Apr 2021 02:28:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EB1D611B0 for ; Thu, 15 Apr 2021 02:28:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbhDOC2f (ORCPT ); Wed, 14 Apr 2021 22:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhDOC2d (ORCPT ); Wed, 14 Apr 2021 22:28:33 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 724C1C061756 for ; Wed, 14 Apr 2021 19:28:10 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id e186so22726871iof.7 for ; Wed, 14 Apr 2021 19:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x4DaaU9yOVKZrRAH+MhLqkl5WKTJPjX+1LKTHN+yRCk=; b=CY4WgIkVwhx8UoXNsevCGV0ooJ7wJ1aCm+Tv5V1bkHqCfCnhs13JkPdTOnhl5tXh2J hJRkhY50o3wVCHrvjraxkB3Ije6+bhxaeW6HHp14GL5lrxSdNQRZC00XC4Bh/RItHhoR SXOmTICHhUbVrU7sOFxE0VD2l5zZi2a0BHjvEFTHOcNWNoogmHHsdHJ9XYJiyU841VKR ynBZLEHYWXbZ9k8Tm3J6FaCEK/pBHjiKv0QfEQq1mgop7RSqpwUl8aU5/pdP6St1n3VL 4jhyu7cYZkfvq1BZjxcW2lisHEzT4sxU9Wh86+vTYtqPiDNzodb9SY5Xn6hmf7NWDQAS i/CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x4DaaU9yOVKZrRAH+MhLqkl5WKTJPjX+1LKTHN+yRCk=; b=HKpQy5mox8p6TDjzJcDEuzHm1dOnGRZeqigWjNNGPuZ+livoxxQw0mYDdcyw7UY+5R B2lyMyA8OlAYcrLiXiYf0fXmSF0AZT1nck7mLj3EObX8ipVCh/aJBIqNThgA9nkaWAxF sRomPJx4lE6al7XvyiBSxyJpwh1a7ZeGfIj0t/RZDn7Z44I0vFFJ0oPGWs3R/ur0N8YC V5sbc5gPVVompTiOxhzzmdtntQZKJPn8Bf5irgDnuGUHvkMIIVxx99QyCdGl+fIM/qCn pzCLfPwve9n7OXCfxBP2w2zORwcaABsNfkzYfVKBaKuo5psoSj13+o128aa52zRkoPIs uPgg== X-Gm-Message-State: AOAM533Nx5WERtpNZBx7AGPpxt0qnLO9STi71Yg022Rnp+wC3aRuLsip AOMX4oRuAZ3siUyziGEVDnY= X-Google-Smtp-Source: ABdhPJybj4HJ6BqMoKPlssFSVnGR8nm4dQ6OQ5nqF8d4IHHQUBa9LQqXTOC0EkGYyoSdBcp0cyYsQQ== X-Received: by 2002:a02:a915:: with SMTP id n21mr906116jam.22.1618453689900; Wed, 14 Apr 2021 19:28:09 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:09 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 04/13] sunrpc: Prepare xs_connect() for taking NULL tasks Date: Wed, 14 Apr 2021 22:27:53 -0400 Message-Id: <20210415022802.31692-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker We won't have a task structure when we go to change IP addresses, so check for one before calling the WARN_ON() to avoid crashing. Signed-off-by: Anna Schumaker --- net/sunrpc/xprtsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 47aa47a2b07c..2bcb80c19339 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2317,7 +2317,7 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task) struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); unsigned long delay = 0; - WARN_ON_ONCE(!xprt_lock_connect(xprt, task, transport)); + WARN_ON_ONCE(task && !xprt_lock_connect(xprt, task, transport)); if (transport->sock != NULL) { dprintk("RPC: xs_connect delayed xprt %p for %lu " From patchwork Thu Apr 15 02:27:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204111 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.7 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 86499C43461 for ; Thu, 15 Apr 2021 02:28:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 605AA611CC for ; Thu, 15 Apr 2021 02:28:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbhDOC2f (ORCPT ); Wed, 14 Apr 2021 22:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbhDOC2d (ORCPT ); Wed, 14 Apr 2021 22:28:33 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87F95C06175F for ; Wed, 14 Apr 2021 19:28:11 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id v3so1241136ion.12 for ; Wed, 14 Apr 2021 19:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M01+BF9kyavBPPm+eb+RPWIBekFS3wzqz8TxPsbYnYQ=; b=rQPi3+WWnv0Zw4xYhkyotmM0+jFNhNx5eOM3zt4uEJcdQAZgNVGlhT4D6ov4He5m0Y anri2EW1elz1lZiID7GkUYbCl5i86nZWLndqWyHBd+XK2fyOfloSfg1BVkQ1DgrG3FAu meCnDEr6xS3+RjFrQKKoc+KWBTTTyDIUwUkDhfUjW2AMce8TK7xa6FYP9D6eqlLHaXsq iMDL1ST02dgXV4fFhAfnPCHAFG2j7PLaOU5EXOc/ogPS66w4kv6L6dBViw+NoeKJkTWh yxrXv7tUfZJAFSqazSeDLS6v7W2J8XL2g2OdurJNhI1Jv7lPNSsEXR0P+WiTNWKNdHTI CApw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M01+BF9kyavBPPm+eb+RPWIBekFS3wzqz8TxPsbYnYQ=; b=ZFBleNKuxzruibDbejpPtBFqrMv5ZZIZpWiKLvQq2wcIdWOFOWL6YV9d1eS78xXRvF Gwwk4cI2Zb3+/kYeS19/qfvfWTo8QJBJvCZHd4OuzESpSMX/VIT5CHGjsgFNmsx4jXkB 0y7i6qrJX7uAY9/2my923cSSz1yZeJf659PXT+dn0haVxkhoU42GCTVwgCHwCme2My2d m2xlldV3UA4ogeZbm8rUk1HzpKLKT6TBB+vBlDKr82gaRSDQYOIBSn9ZZ/QmiZ7NRSIN MNUIGNb9IsTDTPsVpYYuDWUU4lZgqhkWu+16W28vm8kuSmQKCp3mQDp8eTt4+V3WLQtI 8sDA== X-Gm-Message-State: AOAM530zO8suATnpFbhHXI2yOLpQo1Xztzx3s8zGHxODf5DsZWPdJC2X l1vF7XCt19kktOWFJGcCifWyWRKa5hc= X-Google-Smtp-Source: ABdhPJz3tFz0/wHQrwTjzeDRYNF5CV+oXsSV/on7WDxw2JmfARuWVuFshNh083NyMZllrZi6AcE1Qw== X-Received: by 2002:a05:6602:180c:: with SMTP id t12mr827795ioh.109.1618453691024; Wed, 14 Apr 2021 19:28:11 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:10 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 05/13] sunrpc: add xprt id Date: Wed, 14 Apr 2021 22:27:54 -0400 Message-Id: <20210415022802.31692-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Dan Aloni This adds a unique identifier for a sunrpc transport in sysfs, which is similarly managed to the unique IDs of clients. Signed-off-by: Dan Aloni --- include/linux/sunrpc/xprt.h | 2 ++ net/sunrpc/sunrpc_syms.c | 1 + net/sunrpc/xprt.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index d81fe8b364d0..82294d06075c 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -185,6 +185,7 @@ enum xprt_transports { struct rpc_xprt { struct kref kref; /* Reference count */ const struct rpc_xprt_ops *ops; /* transport methods */ + unsigned int id; /* transport id */ const struct rpc_timeout *timeout; /* timeout parms */ struct sockaddr_storage addr; /* server address */ @@ -368,6 +369,7 @@ struct rpc_xprt * xprt_alloc(struct net *net, size_t size, unsigned int num_prealloc, unsigned int max_req); void xprt_free(struct rpc_xprt *); +void xprt_cleanup_ids(void); static inline int xprt_enable_swap(struct rpc_xprt *xprt) diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 3b57efc692ec..b61b74c00483 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -133,6 +133,7 @@ cleanup_sunrpc(void) { rpc_sysfs_exit(); rpc_cleanup_clids(); + xprt_cleanup_ids(); rpcauth_remove_module(); cleanup_socket_xprt(); svc_cleanup_xprt_sock(); diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index a853f75d4968..6181792aec23 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1719,6 +1719,30 @@ static void xprt_free_all_slots(struct rpc_xprt *xprt) } } +static DEFINE_IDA(rpc_xprt_ids); + +void xprt_cleanup_ids(void) +{ + ida_destroy(&rpc_xprt_ids); +} + +static int xprt_alloc_id(struct rpc_xprt *xprt) +{ + int id; + + id = ida_simple_get(&rpc_xprt_ids, 0, 0, GFP_KERNEL); + if (id < 0) + return id; + + xprt->id = id; + return 0; +} + +static void xprt_free_id(struct rpc_xprt *xprt) +{ + ida_simple_remove(&rpc_xprt_ids, xprt->id); +} + struct rpc_xprt *xprt_alloc(struct net *net, size_t size, unsigned int num_prealloc, unsigned int max_alloc) @@ -1731,6 +1755,7 @@ struct rpc_xprt *xprt_alloc(struct net *net, size_t size, if (xprt == NULL) goto out; + xprt_alloc_id(xprt); xprt_init(xprt, net); for (i = 0; i < num_prealloc; i++) { @@ -1759,6 +1784,7 @@ void xprt_free(struct rpc_xprt *xprt) { put_net(xprt->xprt_net); xprt_free_all_slots(xprt); + xprt_free_id(xprt); kfree_rcu(xprt, rcu); } EXPORT_SYMBOL_GPL(xprt_free); From patchwork Thu Apr 15 02:27:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204113 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.7 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 DCEDAC43470 for ; Thu, 15 Apr 2021 02:28:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCACF611B0 for ; Thu, 15 Apr 2021 02:28:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbhDOC2f (ORCPT ); Wed, 14 Apr 2021 22:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhDOC2f (ORCPT ); Wed, 14 Apr 2021 22:28:35 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB116C061574 for ; Wed, 14 Apr 2021 19:28:12 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id e186so22726946iof.7 for ; Wed, 14 Apr 2021 19:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qRdpiHoavL/giiAlZ2MhLMoCIxtj1P8713oUh2Q7kDY=; b=CBIxmexeqTr+k2EIEO9D5OVrjnn29SE2Olb3gxP8Dkk34vNP4uXb9GBJxWirrO1mnL E9nFY3WIW9Zg2N8W2vGXc2na5lLRI4IlwDDR6yO3sti6zdSFCZAFRSillN1hT9Me7Ohp slxF2u+EjwT3QHPthPhxrdXoUev5r1uL9AGpoLV6+e+DRK7/YiyU5fdRJuwMBAb4/9uM fNeAp4YBfJxbQ+y/lzZdma9Ld8yuRgEZFDKJ0iefAJScUbjMiSEKIM9g2WkjvTW4yAiq 0805HJsKp20Ofa+39pv2mQlEULq/OD6tkFaU+IykXn8YCLUoNN+8UhJi/tVJT3qC52Yl vfLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qRdpiHoavL/giiAlZ2MhLMoCIxtj1P8713oUh2Q7kDY=; b=NGDp+o3+3160wUmFVf0Pc/7+cs0EVH279QtmXhV/qiEHwlodFOLQ1HcQuj1bENFCZ6 NyfAIFPly1ivrd2pcn9Lpj5WAyAmvSBIeubI/wz+kh3OGsNjzTq296X5587e8pcl1cnM 6u+hRZ4Sz2+9tsQj1OkgqwrxtzYHYYLAQar2D2yPzv1VQMUOsKFt6yicjEYSXrgF2BbY ZBPdc6pMgHKLDVYBkVW01iShJ3w6DE01ieK3BTyksEz5Rb3+OS3CWW9B9pcHC7l/CdxN BOvC/2FKYz5FN68KrBwLDmalKkxjbTPGDVlDZCHYrlSGipz1Hbg0A7HX8xnAIWMHCcJB /3uQ== X-Gm-Message-State: AOAM532lAx6SVRzL5EoXFtxYA8dkyFG4BVvoSeploxPuil6OHv1wtki7 95q7GShXy4r3wreTTy2IctE= X-Google-Smtp-Source: ABdhPJz2jrgfYL+7IDkwAEaqushl+bd8k02rNzYkT7Y/dhnjrR6ag62yx+5DANZhEwDGSYlOE43S3Q== X-Received: by 2002:a05:6602:2d04:: with SMTP id c4mr862304iow.182.1618453692105; Wed, 14 Apr 2021 19:28:12 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:11 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 06/13] sunrpc: add IDs to multipath Date: Wed, 14 Apr 2021 22:27:55 -0400 Message-Id: <20210415022802.31692-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia This is used to uniquely identify sunrpc multipath objects in /sys. Signed-off-by: Dan Aloni --- include/linux/sunrpc/xprtmultipath.h | 4 ++++ net/sunrpc/sunrpc_syms.c | 1 + net/sunrpc/xprtmultipath.c | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index c6cce3fbf29d..ef95a6f18ccf 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -14,6 +14,7 @@ struct rpc_xprt_switch { spinlock_t xps_lock; struct kref xps_kref; + unsigned int xps_id; unsigned int xps_nxprts; unsigned int xps_nactive; atomic_long_t xps_queuelen; @@ -71,4 +72,7 @@ extern struct rpc_xprt *xprt_iter_get_next(struct rpc_xprt_iter *xpi); extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, const struct sockaddr *sap); + +extern void xprt_multipath_cleanup_ids(void); + #endif diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index b61b74c00483..691c0000e9ea 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -134,6 +134,7 @@ cleanup_sunrpc(void) rpc_sysfs_exit(); rpc_cleanup_clids(); xprt_cleanup_ids(); + xprt_multipath_cleanup_ids(); rpcauth_remove_module(); cleanup_socket_xprt(); svc_cleanup_xprt_sock(); diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 78c075a68c04..b71dd95ad7de 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -86,6 +86,30 @@ void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, xprt_put(xprt); } +static DEFINE_IDA(rpc_xprtswitch_ids); + +void xprt_multipath_cleanup_ids(void) +{ + ida_destroy(&rpc_xprtswitch_ids); +} + +static int xprt_switch_alloc_id(struct rpc_xprt_switch *xps) +{ + int id; + + id = ida_simple_get(&rpc_xprtswitch_ids, 0, 0, GFP_KERNEL); + if (id < 0) + return id; + + xps->xps_id = id; + return 0; +} + +static void xprt_switch_free_id(struct rpc_xprt_switch *xps) +{ + ida_simple_remove(&rpc_xprtswitch_ids, xps->xps_id); +} + /** * xprt_switch_alloc - Allocate a new struct rpc_xprt_switch * @xprt: pointer to struct rpc_xprt @@ -103,6 +127,7 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt, if (xps != NULL) { spin_lock_init(&xps->xps_lock); kref_init(&xps->xps_kref); + xprt_switch_alloc_id(xps); xps->xps_nxprts = xps->xps_nactive = 0; atomic_long_set(&xps->xps_queuelen, 0); xps->xps_net = NULL; @@ -136,6 +161,7 @@ static void xprt_switch_free(struct kref *kref) struct rpc_xprt_switch, xps_kref); xprt_switch_free_entries(xps); + xprt_switch_free_id(xps); kfree_rcu(xps, xps_rcu); } From patchwork Thu Apr 15 02:27:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204115 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.7 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 9049AC433B4 for ; Thu, 15 Apr 2021 02:28:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6634F611CC for ; Thu, 15 Apr 2021 02:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229475AbhDOC2g (ORCPT ); Wed, 14 Apr 2021 22:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhDOC2g (ORCPT ); Wed, 14 Apr 2021 22:28:36 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A13C061574 for ; Wed, 14 Apr 2021 19:28:13 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id c3so12778548ils.5 for ; Wed, 14 Apr 2021 19:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ucYfPxQ2q6euyweVHd9Cs6eqlS3LoA+VSPktZIPi2pI=; b=ULlFwvLJvy53HjVBOy35f0sOwhDfzhNu+p00RiCS+YDVAUXpySUz5Hdu7wV1cz5bGr S7C1pyWGsU4V1f25Ba0qa8KGi3ivHH7Na8k5C7/tsBGDZXkaIAvq3Rw96YN2VpQeDdWj 1/GbZBPOhLvysRdDp0BTHtLNIQV5urmMXFlK0t1x39EmlnoxNgyT3k+kNmqTgEtOePS1 rAA6wOZqD5zTIxCFy2ZPJNfvpAgmMTHdM+AQoH/lgN1GY3sBznOCar1nHeF4I+JTc/IT tjqwgVbG5w+KETtYpVFc3eSVyOU8W940d/wDagRY2POurq80hVe4XKMzVAc05eOaKYxE nH+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ucYfPxQ2q6euyweVHd9Cs6eqlS3LoA+VSPktZIPi2pI=; b=GPyCnGjTgJjw6vxcHwYqkCPl814KRSrSHdY65zCCOqr6rtfitJY9T7l4xh3zb2kT2u VqzA9C7dnGet7HZUbENhD1FzmVudRRNlyEqrhHqEX38IkY6gCXXysaeoXcg6Ow0pi4/A VwkZDhmUPdAdUuzVunZd+3LNCOTiIdaV121fnyNa00w2Q59mqjad/XRbrv3TNaIKzTgG THQ30HxcuH2ggpmgOjLOyagJvxLaoQ9g6p2W5tfLHt006jIUEd8nQaUWxn5YUO692AKR vDAglx2MUUaJ09ioVclKpax1mX32HWAp5vYrQxMZ4j6gHnWLP02YigVwB8SHbyAKyLbm tKqA== X-Gm-Message-State: AOAM53256/lfNjlAupZOsYt4x5TFeoO+x13bIHHpR7QrQUgy4AR+Qtk0 GCu5lTwlu5SyynX1Ppdj/MY= X-Google-Smtp-Source: ABdhPJwmyp4zuc3J9kwvHL2Ef6eMCBAXcrgEzyC5S473NhCvLM77hR9hAmUtz75D7lX4dvAMsryPMg== X-Received: by 2002:a05:6e02:1caf:: with SMTP id x15mr1040685ill.89.1618453693241; Wed, 14 Apr 2021 19:28:13 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:12 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 07/13] sunrpc: keep track of the xprt_class in rpc_xprt structure Date: Wed, 14 Apr 2021 22:27:56 -0400 Message-Id: <20210415022802.31692-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia We need to keep track of the type for a given transport. Signed-off-by: Olga Kornievskaia Reported-by: kernel test robot Reported-by: kernel test robot --- include/linux/sunrpc/xprt.h | 2 ++ net/sunrpc/xprtrdma/transport.c | 2 ++ net/sunrpc/xprtsock.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 82294d06075c..a2edcc42e6c4 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -53,6 +53,7 @@ enum rpc_display_format_t { struct rpc_task; struct rpc_xprt; +struct xprt_class; struct seq_file; struct svc_serv; struct net; @@ -289,6 +290,7 @@ struct rpc_xprt { atomic_t inject_disconnect; #endif struct rcu_head rcu; + const struct xprt_class *xprt_class; }; #if defined(CONFIG_SUNRPC_BACKCHANNEL) diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index 78d29d1bcc20..2c2e51e54fbb 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -87,6 +87,7 @@ static unsigned int dummy; static struct ctl_table_header *sunrpc_table_header; +static struct xprt_class xprt_rdma; static struct ctl_table xr_tunables_table[] = { { .procname = "rdma_slot_table_entries", @@ -347,6 +348,7 @@ xprt_setup_rdma(struct xprt_create *args) /* Ensure xprt->addr holds valid server TCP (not RDMA) * address, for any side protocols which peek at it */ xprt->prot = IPPROTO_TCP; + xprt->xprt_class = &xprt_rdma; xprt->addrlen = args->addrlen; memcpy(&xprt->addr, sap, xprt->addrlen); diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 2bcb80c19339..5ff37badd335 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -91,6 +91,11 @@ static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT; static struct ctl_table_header *sunrpc_table_header; +static struct xprt_class xs_local_transport; +static struct xprt_class xs_udp_transport; +static struct xprt_class xs_tcp_transport; +static struct xprt_class xs_bc_tcp_transport; + /* * FIXME: changing the UDP slot table size should also resize the UDP * socket buffers for existing UDP transports @@ -2777,6 +2782,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = 0; + xprt->xprt_class = &xs_local_transport; xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; xprt->bind_timeout = XS_BIND_TO; @@ -2846,6 +2852,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = IPPROTO_UDP; + xprt->xprt_class = &xs_udp_transport; /* XXX: header size can vary due to auth type, IPv6, etc. */ xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); @@ -2926,6 +2933,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = IPPROTO_TCP; + xprt->xprt_class = &xs_tcp_transport; xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; xprt->bind_timeout = XS_BIND_TO; @@ -2999,6 +3007,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = IPPROTO_TCP; + xprt->xprt_class = &xs_bc_tcp_transport; xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; xprt->timeout = &xs_tcp_default_timeout; From patchwork Thu Apr 15 02:27:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204117 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.7 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 F2191C43600 for ; Thu, 15 Apr 2021 02:28:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6C51611B0 for ; Thu, 15 Apr 2021 02:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229696AbhDOC2h (ORCPT ); Wed, 14 Apr 2021 22:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhDOC2h (ORCPT ); Wed, 14 Apr 2021 22:28:37 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBE17C061574 for ; Wed, 14 Apr 2021 19:28:14 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id b10so22710883iot.4 for ; Wed, 14 Apr 2021 19:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ci+N8cKSZsHwpbXnPcwWXMh4mMw5JQW2neWS/ND3vgo=; b=K4M4uIYF2DVQZGN76hQwdL5hAYVAwwPrLojz0UoAfJA10VbHsJgsukpX4jTFaXAnsR xPppaNKLkUdbTf3RRx7AqUkQko1nwOxbjULhqob5gwCdfs5AXa3r0w7J+xa7ypyd1jFx TqI5rciEjGBW9Dz4ZnPII9E9zukv+V3bidt6S/LAwysyc4GO3LBlfUWtMuh6NkF8cV8h SjCLZVEa/JI/uVy4rJ0WdZXnHcwtMhvVOhTn5N3lDMxaHXS4UQ+jWmwO0Zm0Wevo0bg/ 4KvVysIcNwEOTohNqkqY9tAOZ7f2Ev3qWcVWnk/P9Jly+YUdpAEq2+SpvVE/0l9ouVAH Rhlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ci+N8cKSZsHwpbXnPcwWXMh4mMw5JQW2neWS/ND3vgo=; b=eRjWCGGVE/y9h/dVApe8qgcdqGzdj8+TGw6T91gBOPbUGh7Mu0aNjV7WXtfrkp125p Ei+7cXnt3gf26IAaowGkEMcmJaPTDrkWyIWcPAp/Mk6q/Dvliujl38oWMx48wjitXwhi ffL4+G9hMe6RN45mlDhL1Go3HsD3Dq2sFQNi/ElMxfxzKv7jkhN1Ii2FHSj5zVoC/dxE auwBMrVpz3eLrq84/zSHfaJFhk/LtnhRJE+xfmZX/0LQDJ90GuSR722zI4lmqEd34QHR F06Rw8VFgeBFT9e816NZlu83x+jt1sgHusNO6uil5f1ddmNquHCYFI1QUb/MlYvGuia8 qLng== X-Gm-Message-State: AOAM533P+lxr1BVOkGriAPV6yTqTfyV9aN1LEn396stQcSx9lWuBn+vJ DXb77BL3Ye3B77QKqJp4qeQ= X-Google-Smtp-Source: ABdhPJyaE7hBA6jIVfblfcRpFsBogRH31ZZvAVxO54Q5ZSjj9qZAwb0Ep4YZxLSqzCu2kGxfSO9PUA== X-Received: by 2002:a5e:c709:: with SMTP id f9mr862223iop.56.1618453694283; Wed, 14 Apr 2021 19:28:14 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:13 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 08/13] sunrpc: add xprt_switch direcotry to sunrpc's sysfs Date: Wed, 14 Apr 2021 22:27:57 -0400 Message-Id: <20210415022802.31692-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Add xprt_switch directory to the sysfs and create individual xprt_swith subdirectories for multipath transport group. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprtmultipath.h | 1 + net/sunrpc/sysfs.c | 97 ++++++++++++++++++++++++++-- net/sunrpc/sysfs.h | 10 +++ net/sunrpc/xprtmultipath.c | 4 ++ 4 files changed, 105 insertions(+), 7 deletions(-) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index ef95a6f18ccf..47b0a85cdcfa 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -24,6 +24,7 @@ struct rpc_xprt_switch { const struct rpc_xprt_iter_ops *xps_iter_ops; + void *xps_sysfs; struct rcu_head xps_rcu; }; diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index d14d54f33c65..0c34330714ab 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -7,7 +7,7 @@ #include "sysfs.h" static struct kset *rpc_sunrpc_kset; -static struct kobject *rpc_sunrpc_client_kobj; +static struct kobject *rpc_sunrpc_client_kobj, *rpc_sunrpc_xprt_switch_kobj; static void rpc_sysfs_object_release(struct kobject *kobj) { @@ -47,13 +47,22 @@ int rpc_sysfs_init(void) rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); if (!rpc_sunrpc_kset) return -ENOMEM; - rpc_sunrpc_client_kobj = rpc_sysfs_object_alloc("client", rpc_sunrpc_kset, NULL); - if (!rpc_sunrpc_client_kobj) { - kset_unregister(rpc_sunrpc_kset); - rpc_sunrpc_client_kobj = NULL; - return -ENOMEM; - } + rpc_sunrpc_client_kobj = + rpc_sysfs_object_alloc("rpc-clients", rpc_sunrpc_kset, NULL); + if (!rpc_sunrpc_client_kobj) + goto err_client; + rpc_sunrpc_xprt_switch_kobj = + rpc_sysfs_object_alloc("xprt-switches", rpc_sunrpc_kset, NULL); + if (!rpc_sunrpc_xprt_switch_kobj) + goto err_switch; return 0; +err_switch: + kobject_put(rpc_sunrpc_client_kobj); + rpc_sunrpc_client_kobj = NULL; +err_client: + kset_unregister(rpc_sunrpc_kset); + rpc_sunrpc_kset = NULL; + return -ENOMEM; } static void rpc_sysfs_client_release(struct kobject *kobj) @@ -64,20 +73,40 @@ static void rpc_sysfs_client_release(struct kobject *kobj) kfree(c); } +static void rpc_sysfs_xprt_switch_release(struct kobject *kobj) +{ + struct rpc_sysfs_xprt_switch *xprt_switch; + + xprt_switch = container_of(kobj, struct rpc_sysfs_xprt_switch, kobject); + kfree(xprt_switch); +} + static const void *rpc_sysfs_client_namespace(struct kobject *kobj) { return container_of(kobj, struct rpc_sysfs_client, kobject)->net; } +static const void *rpc_sysfs_xprt_switch_namespace(struct kobject *kobj) +{ + return container_of(kobj, struct rpc_sysfs_xprt_switch, kobject)->net; +} + static struct kobj_type rpc_sysfs_client_type = { .release = rpc_sysfs_client_release, .sysfs_ops = &kobj_sysfs_ops, .namespace = rpc_sysfs_client_namespace, }; +static struct kobj_type rpc_sysfs_xprt_switch_type = { + .release = rpc_sysfs_xprt_switch_release, + .sysfs_ops = &kobj_sysfs_ops, + .namespace = rpc_sysfs_xprt_switch_namespace, +}; + void rpc_sysfs_exit(void) { kobject_put(rpc_sunrpc_client_kobj); + kobject_put(rpc_sunrpc_xprt_switch_kobj); kset_unregister(rpc_sunrpc_kset); } @@ -99,6 +128,27 @@ static struct rpc_sysfs_client *rpc_sysfs_client_alloc(struct kobject *parent, return NULL; } +static struct rpc_sysfs_xprt_switch * +rpc_sysfs_xprt_switch_alloc(struct kobject *parent, + struct rpc_xprt_switch *xprt_switch, + struct net *net) +{ + struct rpc_sysfs_xprt_switch *p; + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (p) { + p->net = net; + p->kobject.kset = rpc_sunrpc_kset; + if (kobject_init_and_add(&p->kobject, + &rpc_sysfs_xprt_switch_type, + parent, "switch-%d", + xprt_switch->xps_id) == 0) + return p; + kobject_put(&p->kobject); + } + return NULL; +} + void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net) { struct rpc_sysfs_client *rpc_client; @@ -110,6 +160,27 @@ void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net) } } +void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, + struct rpc_xprt *xprt) +{ + struct rpc_sysfs_xprt_switch *rpc_xprt_switch; + struct net *net; + + if (xprt_switch->xps_net) + net = xprt_switch->xps_net; + else + net = xprt->xprt_net; + rpc_xprt_switch = + rpc_sysfs_xprt_switch_alloc(rpc_sunrpc_xprt_switch_kobj, + xprt_switch, net); + if (rpc_xprt_switch) { + xprt_switch->xps_sysfs = rpc_xprt_switch; + rpc_xprt_switch->xprt_switch = xprt_switch; + rpc_xprt_switch->xprt = xprt; + kobject_uevent(&rpc_xprt_switch->kobject, KOBJ_ADD); + } +} + void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) { struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; @@ -121,3 +192,15 @@ void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) clnt->cl_sysfs = NULL; } } + +void rpc_sysfs_xprt_switch_destroy(struct rpc_xprt_switch *xprt_switch) +{ + struct rpc_sysfs_xprt_switch *rpc_xprt_switch = xprt_switch->xps_sysfs; + + if (rpc_xprt_switch) { + kobject_uevent(&rpc_xprt_switch->kobject, KOBJ_REMOVE); + kobject_del(&rpc_xprt_switch->kobject); + kobject_put(&rpc_xprt_switch->kobject); + xprt_switch->xps_sysfs = NULL; + } +} diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index c46afc848993..9b6acd3fd3dc 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -10,10 +10,20 @@ struct rpc_sysfs_client { struct net *net; }; +struct rpc_sysfs_xprt_switch { + struct kobject kobject; + struct net *net; + struct rpc_xprt_switch *xprt_switch; + struct rpc_xprt *xprt; +}; + int rpc_sysfs_init(void); void rpc_sysfs_exit(void); void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net); void rpc_sysfs_client_destroy(struct rpc_clnt *clnt); +void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, + struct rpc_xprt *xprt); +void rpc_sysfs_xprt_switch_destroy(struct rpc_xprt_switch *xprt); #endif diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index b71dd95ad7de..1ed16e4cc465 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -19,6 +19,8 @@ #include #include +#include "sysfs.h" + typedef struct rpc_xprt *(*xprt_switch_find_xprt_t)(struct rpc_xprt_switch *xps, const struct rpc_xprt *cur); @@ -133,6 +135,7 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt, xps->xps_net = NULL; INIT_LIST_HEAD(&xps->xps_xprt_list); xps->xps_iter_ops = &rpc_xprt_iter_singular; + rpc_sysfs_xprt_switch_setup(xps, xprt); xprt_switch_add_xprt_locked(xps, xprt); } @@ -161,6 +164,7 @@ static void xprt_switch_free(struct kref *kref) struct rpc_xprt_switch, xps_kref); xprt_switch_free_entries(xps); + rpc_sysfs_xprt_switch_destroy(xps); xprt_switch_free_id(xps); kfree_rcu(xps, xps_rcu); } From patchwork Thu Apr 15 02:27:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204119 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.7 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 DBA0EC433ED for ; Thu, 15 Apr 2021 02:28:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDE87611CC for ; Thu, 15 Apr 2021 02:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhDOC2i (ORCPT ); Wed, 14 Apr 2021 22:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhDOC2h (ORCPT ); Wed, 14 Apr 2021 22:28:37 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C227CC061574 for ; Wed, 14 Apr 2021 19:28:15 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id c3so12778612ils.5 for ; Wed, 14 Apr 2021 19:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=raMDgmlchq+DKNX0qxvB0dsQ0FtPW2sX0aUw2dFGIAM=; b=XGwU1Qk+u058kCmimlN05A41qh1Rr5llkdp2gzxsZ+F3MZNTbGtxlC1A6fGy4jvfdh 6e5XeUjxY1RJtJ1d9EW4l7sFnbjOlfBLq5FLs8bLw2/6bo8tT1KnRmLBUJrysWG966QX DHuH6VgiuPKI774jcZ1L3/5qProWzhqaK9qwc78+fVDQ43Box36qFSGLMJUY5oLDZKCc AGhhCsTa+aO1uWrEHCEGgV0A4m64Eygr+9FggqNLpoCGrXHJzLVMkK1sDimTOJ8PQJOe +N2UzKgZLfzVhRSrdjO2OT1XrlT+3RomvH133tyH+F2ZvW0MxOTQPYKsqNaf4sMBGqYz yAkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=raMDgmlchq+DKNX0qxvB0dsQ0FtPW2sX0aUw2dFGIAM=; b=EGWkU1bWT56949fYHwNORFAvk/IQcraqtk15rz4zJrvkWEV2RaVJMkomvy06E3x5ah OPtsviUi9xavpmQaoMpylo3/8RYnuMc7JGyd9TWGp/i/kqb+hWECotEYryx9be0MVayF 559NcKJrJ55Og0eVBlVQylMsWU2dvYFvd+UexwaMbnlqei9jqrBtBDbrUUAkQj6Xtwqk QDSLdgE4866K5lwt4xzI+KrQ0Ol9wU0jgZpB1j+Bb3s8zx2kDoD/LQ2z3nLW4ddG18dm YV1C4TDxe8LNR/PdAYGUDmznxHB7T32HCJYnHNpZn+pu4jDDFX7RLfqpOO6ON3SJjc1E hrxA== X-Gm-Message-State: AOAM531AyBJAvk0BCDz0jSzQAQsHUziqPgbc12MocF6bJ6dUReoSlswU 1tP2dz6N4w0N/7yLQEhfJO8= X-Google-Smtp-Source: ABdhPJyYCU67vqQieLZL/TNOcXxzYv9NKAJ00QEInKkjkOngCqG4GohcD+kAO7pdqMfymmyn55Eadw== X-Received: by 2002:a05:6e02:120e:: with SMTP id a14mr989513ilq.273.1618453695211; Wed, 14 Apr 2021 19:28:15 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:14 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 09/13] sunrpc: add a symlink from rpc-client directory to the xprt_switch Date: Wed, 14 Apr 2021 22:27:58 -0400 Message-Id: <20210415022802.31692-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia An rpc client uses a transport switch and one ore more transports associated with that switch. Since transports are shared among rpc clients, create a symlink into the xprt_switch directory instead of duplicating entries under each rpc client. Signed-off-by: Olga Kornievskaia Reported-by: kernel test robot --- net/sunrpc/clnt.c | 2 +- net/sunrpc/sysfs.c | 22 ++++++++++++++++++++-- net/sunrpc/sysfs.h | 6 +++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index ceb8d19d4cb4..fad87dba5114 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -301,7 +301,6 @@ static int rpc_client_register(struct rpc_clnt *clnt, int err; rpc_clnt_debugfs_register(clnt); - rpc_sysfs_client_setup(clnt, net); pipefs_sb = rpc_get_sb_net(net); if (pipefs_sb) { @@ -426,6 +425,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, /* save the nodename */ rpc_clnt_set_nodename(clnt, nodename); + rpc_sysfs_client_setup(clnt, xps, rpc_net_ns(clnt)); err = rpc_client_register(clnt, args->authflavor, args->client_name); if (err) goto out_no_path; diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 0c34330714ab..6e91e271a37b 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -149,14 +149,27 @@ rpc_sysfs_xprt_switch_alloc(struct kobject *parent, return NULL; } -void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net) +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, + struct rpc_xprt_switch *xprt_switch, + struct net *net) { struct rpc_sysfs_client *rpc_client; - rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, net, clnt->cl_clid); + rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, + net, clnt->cl_clid); if (rpc_client) { + char name[23]; + struct rpc_sysfs_xprt_switch *xswitch = + (struct rpc_sysfs_xprt_switch *)xprt_switch->xps_sysfs; + int ret; + clnt->cl_sysfs = rpc_client; + rpc_client->clnt = clnt; + rpc_client->xprt_switch = xprt_switch; kobject_uevent(&rpc_client->kobject, KOBJ_ADD); + snprintf(name, sizeof(name), "switch-%d", xprt_switch->xps_id); + ret = sysfs_create_link_nowarn(&rpc_client->kobject, + &xswitch->kobject, name); } } @@ -186,6 +199,11 @@ void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; if (rpc_client) { + char name[23]; + + snprintf(name, sizeof(name), "switch-%d", + rpc_client->xprt_switch->xps_id); + sysfs_remove_link(&rpc_client->kobject, name); kobject_uevent(&rpc_client->kobject, KOBJ_REMOVE); kobject_del(&rpc_client->kobject); kobject_put(&rpc_client->kobject); diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index 9b6acd3fd3dc..9a0625b1cd65 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -8,6 +8,8 @@ struct rpc_sysfs_client { struct kobject kobject; struct net *net; + struct rpc_clnt *clnt; + struct rpc_xprt_switch *xprt_switch; }; struct rpc_sysfs_xprt_switch { @@ -20,7 +22,9 @@ struct rpc_sysfs_xprt_switch { int rpc_sysfs_init(void); void rpc_sysfs_exit(void); -void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net); +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, + struct rpc_xprt_switch *xprt_switch, + struct net *net); void rpc_sysfs_client_destroy(struct rpc_clnt *clnt); void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, struct rpc_xprt *xprt); From patchwork Thu Apr 15 02:27:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204121 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.7 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 CB389C433B4 for ; Thu, 15 Apr 2021 02:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4921611B0 for ; Thu, 15 Apr 2021 02:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbhDOC2j (ORCPT ); Wed, 14 Apr 2021 22:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhDOC2j (ORCPT ); Wed, 14 Apr 2021 22:28:39 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA1AC061574 for ; Wed, 14 Apr 2021 19:28:16 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id x16so22744018iob.1 for ; Wed, 14 Apr 2021 19:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vxuhr6yv+e4YAQl2ln8omMyqcJzGoDRDt9S73WJ8pE8=; b=qKnvJPp66pNsCcYJd1j5EA8Xr/TMrQd5uWGmXERxe5nhAhzRr0Kg+T/sPejXXsRuzc d5EHhaVMDUxN2won/328ANKg3tJd+6JoHNAijMvXZ4Ur+U1BaDc+aEDAIJADPF//R4CR pZUDYwHqeJ3LOb8p0o/AN/lhY1HTGMheMZEJOUxTTK23YqOZk3hdYGgly2aowKXtBG1l w4jNS4FsPef5DZNF6wv8YPxfG4OOBdZBI4jDq/yFfSSWxi6docRhU79mUA5s6Br+j5N5 6BFhR2k0esqXpsf7nSkDS2xaozahr8Or0OKpvcKdFE5Z3FHLza8Kgw38+bVMzZju/Rh8 OJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vxuhr6yv+e4YAQl2ln8omMyqcJzGoDRDt9S73WJ8pE8=; b=aZvVZhYybEpak8i2WJH4VB3PfzTrFi57skLMq1IjZko7twYUR5ha5b+M3GN/0JQKcQ PvjnK9N9CXOSuxiuyCopyoquvEvIwS/lNuf3vPuMzbvQEO/2WdqlRzX02YCvyGT+WkLu 5GZ0ADn7zZ5Kw/KwEwh2mGIz9ZMbbrrvxFnIwKjWeNODrCsACOLlrOvOLQZx+ntGpc93 +h/YmocSgdaeIaUIby1lB91vOZt8rh9gJxY80s7SDt8kvtpsDrAU7edUWicHJ8H2xSJJ LEA8KclGACkOOM+JFwHshHZ+QridBj/G9IWDhEFSV5SE+IpWmit+qNujbrbqQ24veo8+ KS3Q== X-Gm-Message-State: AOAM530h5sdaCak2QVWcHkHfH+X0mZniqcWZXZAZXic4f2WCSZ24pgx2 +dumYiKrO7xTP80CG8uLF3o= X-Google-Smtp-Source: ABdhPJwOTKk2hVBcnyk00oI+EyO08cfTIOf7SXFR//8wIirs7SrJEgjBWBU161YOraDbk293SVY9Bw== X-Received: by 2002:a05:6602:1612:: with SMTP id x18mr817169iow.139.1618453696370; Wed, 14 Apr 2021 19:28:16 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:15 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 10/13] sunrpc: add add sysfs directory per xprt under each xprt_switch Date: Wed, 14 Apr 2021 22:27:59 -0400 Message-Id: <20210415022802.31692-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Add individual transport directories under each transport switch group. For instance, for each nconnect=X connections there will be a transport directory. Naming conventions also identifies transport type -- xprt-- where type is udp, tcp, rdma, local, bc. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/sysfs.c | 83 +++++++++++++++++++++++++++++++++++++ net/sunrpc/sysfs.h | 9 ++++ net/sunrpc/xprtmultipath.c | 2 + 4 files changed, 95 insertions(+) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index a2edcc42e6c4..1e4906759a6a 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -291,6 +291,7 @@ struct rpc_xprt { #endif struct rcu_head rcu; const struct xprt_class *xprt_class; + void *xprt_sysfs; }; #if defined(CONFIG_SUNRPC_BACKCHANNEL) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 6e91e271a37b..897939184f11 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -81,6 +81,14 @@ static void rpc_sysfs_xprt_switch_release(struct kobject *kobj) kfree(xprt_switch); } +static void rpc_sysfs_xprt_switch_xprt_release(struct kobject *kobj) +{ + struct rpc_sysfs_xprt_switch_xprt *xprt; + + xprt = container_of(kobj, struct rpc_sysfs_xprt_switch_xprt, kobject); + kfree(xprt); +} + static const void *rpc_sysfs_client_namespace(struct kobject *kobj) { return container_of(kobj, struct rpc_sysfs_client, kobject)->net; @@ -91,6 +99,12 @@ static const void *rpc_sysfs_xprt_switch_namespace(struct kobject *kobj) return container_of(kobj, struct rpc_sysfs_xprt_switch, kobject)->net; } +static const void *rpc_sysfs_xprt_switch_xprt_namespace(struct kobject *kobj) +{ + return container_of(kobj, struct rpc_sysfs_xprt_switch_xprt, + kobject)->net; +} + static struct kobj_type rpc_sysfs_client_type = { .release = rpc_sysfs_client_release, .sysfs_ops = &kobj_sysfs_ops, @@ -103,6 +117,12 @@ static struct kobj_type rpc_sysfs_xprt_switch_type = { .namespace = rpc_sysfs_xprt_switch_namespace, }; +static struct kobj_type rpc_sysfs_xprt_switch_xprt_type = { + .release = rpc_sysfs_xprt_switch_xprt_release, + .sysfs_ops = &kobj_sysfs_ops, + .namespace = rpc_sysfs_xprt_switch_xprt_namespace, +}; + void rpc_sysfs_exit(void) { kobject_put(rpc_sunrpc_client_kobj); @@ -149,6 +169,39 @@ rpc_sysfs_xprt_switch_alloc(struct kobject *parent, return NULL; } +static struct rpc_sysfs_xprt_switch_xprt * +rpc_sysfs_xprt_switch_xprt_alloc(struct kobject *parent, + struct rpc_xprt *xprt, + struct net *net) +{ + struct rpc_sysfs_xprt_switch_xprt *p; + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (p) { + char type[6]; + + p->net = net; + p->kobject.kset = rpc_sunrpc_kset; + if (xprt->xprt_class->ident == XPRT_TRANSPORT_RDMA) + snprintf(type, sizeof(type), "rdma"); + else if (xprt->xprt_class->ident == XPRT_TRANSPORT_TCP) + snprintf(type, sizeof(type), "tcp"); + else if (xprt->xprt_class->ident == XPRT_TRANSPORT_UDP) + snprintf(type, sizeof(type), "udp"); + else if (xprt->xprt_class->ident == XPRT_TRANSPORT_LOCAL) + snprintf(type, sizeof(type), "local"); + else if (xprt->xprt_class->ident == XPRT_TRANSPORT_BC_TCP) + snprintf(type, sizeof(type), "bc"); + if (kobject_init_and_add(&p->kobject, + &rpc_sysfs_xprt_switch_xprt_type, + parent, "xprt-%d-%s", xprt->id, + type) == 0) + return p; + kobject_put(&p->kobject); + } + return NULL; +} + void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct rpc_xprt_switch *xprt_switch, struct net *net) @@ -194,6 +247,23 @@ void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, } } +void rpc_sysfs_xprt_switch_xprt_setup(struct rpc_xprt_switch *xprt_switch, + struct rpc_xprt *xprt) +{ + struct rpc_sysfs_xprt_switch_xprt *rpc_xprt_switch_xprt; + struct rpc_sysfs_xprt_switch *switch_obj = + (struct rpc_sysfs_xprt_switch *)xprt_switch->xps_sysfs; + + rpc_xprt_switch_xprt = + rpc_sysfs_xprt_switch_xprt_alloc(&switch_obj->kobject, + xprt, xprt->xprt_net); + if (rpc_xprt_switch_xprt) { + xprt->xprt_sysfs = rpc_xprt_switch_xprt; + rpc_xprt_switch_xprt->xprt = xprt; + kobject_uevent(&rpc_xprt_switch_xprt->kobject, KOBJ_ADD); + } +} + void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) { struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; @@ -222,3 +292,16 @@ void rpc_sysfs_xprt_switch_destroy(struct rpc_xprt_switch *xprt_switch) xprt_switch->xps_sysfs = NULL; } } + +void rpc_sysfs_xprt_switch_xprt_destroy(struct rpc_xprt *xprt) +{ + struct rpc_sysfs_xprt_switch_xprt *rpc_xprt_switch_xprt = + xprt->xprt_sysfs; + + if (rpc_xprt_switch_xprt) { + kobject_uevent(&rpc_xprt_switch_xprt->kobject, KOBJ_REMOVE); + kobject_del(&rpc_xprt_switch_xprt->kobject); + kobject_put(&rpc_xprt_switch_xprt->kobject); + xprt->xprt_sysfs = NULL; + } +} diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index 9a0625b1cd65..52abe443ee8d 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -19,6 +19,12 @@ struct rpc_sysfs_xprt_switch { struct rpc_xprt *xprt; }; +struct rpc_sysfs_xprt_switch_xprt { + struct kobject kobject; + struct net *net; + struct rpc_xprt *xprt; +}; + int rpc_sysfs_init(void); void rpc_sysfs_exit(void); @@ -29,5 +35,8 @@ void rpc_sysfs_client_destroy(struct rpc_clnt *clnt); void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, struct rpc_xprt *xprt); void rpc_sysfs_xprt_switch_destroy(struct rpc_xprt_switch *xprt); +void rpc_sysfs_xprt_switch_xprt_setup(struct rpc_xprt_switch *xprt_switch, + struct rpc_xprt *xprt); +void rpc_sysfs_xprt_switch_xprt_destroy(struct rpc_xprt *xprt); #endif diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 1ed16e4cc465..eba45cbf8448 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -33,6 +33,7 @@ static void xprt_switch_add_xprt_locked(struct rpc_xprt_switch *xps, { if (unlikely(xprt_get(xprt) == NULL)) return; + rpc_sysfs_xprt_switch_xprt_setup(xps, xprt); list_add_tail_rcu(&xprt->xprt_switch, &xps->xps_xprt_list); smp_wmb(); if (xps->xps_nxprts == 0) @@ -66,6 +67,7 @@ static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, return; xps->xps_nactive--; xps->xps_nxprts--; + rpc_sysfs_xprt_switch_xprt_destroy(xprt); if (xps->xps_nxprts == 0) xps->xps_net = NULL; smp_wmb(); From patchwork Thu Apr 15 02:28:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204123 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.7 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 047C7C43460 for ; Thu, 15 Apr 2021 02:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D52C9611CC for ; Thu, 15 Apr 2021 02:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbhDOC2l (ORCPT ); Wed, 14 Apr 2021 22:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhDOC2k (ORCPT ); Wed, 14 Apr 2021 22:28:40 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9085C061574 for ; Wed, 14 Apr 2021 19:28:17 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id r5so10730491ilb.2 for ; Wed, 14 Apr 2021 19:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7e2Uku8Qwn+tDIg2fezrb9mpCWvmkj+bjrtpzR8Rlkk=; b=Nq0Zv6yD40H0oIdUYQgDr0piH3fBlv/cv4vgpGGQE+if2W5IEc9RBoU1vqoDYRXPjb znveWqOaLnbq94TcKAhxxsMW8J4kM0vKdCMJ48U+124aHtjYMRhBz6TIejcNohN3hD/i kHRVwoxCHiNX4qYLr2+b/2Sh1KRo1F5wRXyJByNJQUYM3O/qoK/FwScMcR11BgWbuB+O i7zAMB7pzsEwfP1kTZfpuyh+sQRVqwC+DhqKBBo9sM1t0yl0RS5zmHPeyFvoSJB3I9rE LUVo8oR4pwoDLPv2FrhrwOKGb+FSJH4s/ow2+3Blz7bbaMeCUVlqNI2H3GCUvmqRjuUk /66w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7e2Uku8Qwn+tDIg2fezrb9mpCWvmkj+bjrtpzR8Rlkk=; b=Rv29bDwcjhYT7Z6s3BjcmOXdynj8w5BNtpaEqQ3UnrriQw14XYVVqN+T7EkzHdG1hc aH/7OCuL9t4h3drbupQpRXlszCNx36WiWZsgDmgSesSLhaN2+iqY/jSVNlOZ1onYXXrn ZnHeT2OBxtbkQ/Vj4PtF8epnUX0B5d9s4G8fAWuX6RzCVlKsDEvEDG1kAbAWSWZevCzl AgBUTS0l2aqpKQRN83WHWM/U2L0SN2c41YK6wA2IUwF0nkdgiCeokScGGIa+pnZioKVB PZxPMGt/c+BtpcNdNRZsSSnxU22TYtL1gZj36OzOjEyTs6Gy2fyaCNqIh5Q9GMEl6uDC 9pgw== X-Gm-Message-State: AOAM533jT2RBR0wIKD6s/eXMMaNd8WrZNz/4n7XLYxZK27UuAqzvvmk4 P2Zit/kc6jS70tWeovw804I= X-Google-Smtp-Source: ABdhPJyGuCm/pjAHvApo3mscSGEyZDRha9nNkfTLKzigwZueP68JkoQK+u8NPVT6bpW1cIAFL6ucTQ== X-Received: by 2002:a05:6e02:e0a:: with SMTP id a10mr939416ilk.271.1618453697371; Wed, 14 Apr 2021 19:28:17 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:16 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 11/13] sunrpc: add dst_attr attributes to the sysfs xprt directory Date: Wed, 14 Apr 2021 22:28:00 -0400 Message-Id: <20210415022802.31692-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Allow to query and set the destination's address of a transport. Setting of the destination address is allowed only for TCP or RDMA based connections. Signed-off-by: Olga Kornievskaia Reported-by: kernel test robot --- net/sunrpc/sysfs.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 897939184f11..35d8109931cb 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -4,6 +4,9 @@ */ #include #include +#include +#include + #include "sysfs.h" static struct kset *rpc_sunrpc_kset; @@ -42,6 +45,70 @@ static struct kobject *rpc_sysfs_object_alloc(const char *name, return NULL; } +static inline struct rpc_xprt * +rpc_sysfs_xprt_kobj_get_xprt(struct kobject *kobj) +{ + struct rpc_sysfs_xprt_switch_xprt *x = container_of(kobj, + struct rpc_sysfs_xprt_switch_xprt, kobject); + struct rpc_xprt *xprt; + + rcu_read_lock(); + xprt = xprt_get(rcu_dereference(x->xprt)); + rcu_read_unlock(); + return xprt; +} + +static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); + ssize_t ret; + + if (!xprt) + return 0; + if (xprt->xprt_class->ident == XPRT_TRANSPORT_LOCAL) + ret = sprintf(buf, "localhost"); + else + ret = rpc_ntop((struct sockaddr *)&xprt->addr, buf, PAGE_SIZE); + buf[ret] = '\n'; + xprt_put(xprt); + return ret + 1; +} + +static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); + struct sockaddr *saddr; + int port; + + if (!xprt) + return 0; + if (!(xprt->xprt_class->ident == XPRT_TRANSPORT_TCP || + xprt->xprt_class->ident == XPRT_TRANSPORT_RDMA)) { + xprt_put(xprt); + return -EOPNOTSUPP; + } + + wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE); + saddr = (struct sockaddr *)&xprt->addr; + port = rpc_get_port(saddr); + + kfree(xprt->address_strings[RPC_DISPLAY_ADDR]); + xprt->address_strings[RPC_DISPLAY_ADDR] = kstrndup(buf, count - 1, + GFP_KERNEL); + xprt->addrlen = rpc_pton(xprt->xprt_net, buf, count - 1, saddr, + sizeof(*saddr)); + rpc_set_port(saddr, port); + + xprt->ops->connect(xprt, NULL); + clear_bit(XPRT_LOCKED, &xprt->state); + xprt_put(xprt); + return count; +} + int rpc_sysfs_init(void) { rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); @@ -105,6 +172,14 @@ static const void *rpc_sysfs_xprt_switch_xprt_namespace(struct kobject *kobj) kobject)->net; } +static struct kobj_attribute rpc_sysfs_xprt_dstaddr = __ATTR(dstaddr, + 0644, rpc_sysfs_xprt_dstaddr_show, rpc_sysfs_xprt_dstaddr_store); + +static struct attribute *rpc_sysfs_xprt_attrs[] = { + &rpc_sysfs_xprt_dstaddr.attr, + NULL, +}; + static struct kobj_type rpc_sysfs_client_type = { .release = rpc_sysfs_client_release, .sysfs_ops = &kobj_sysfs_ops, @@ -119,6 +194,7 @@ static struct kobj_type rpc_sysfs_xprt_switch_type = { static struct kobj_type rpc_sysfs_xprt_switch_xprt_type = { .release = rpc_sysfs_xprt_switch_xprt_release, + .default_attrs = rpc_sysfs_xprt_attrs, .sysfs_ops = &kobj_sysfs_ops, .namespace = rpc_sysfs_xprt_switch_xprt_namespace, }; From patchwork Thu Apr 15 02:28:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204125 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.7 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 82CA2C433ED for ; Thu, 15 Apr 2021 02:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CA3B611B0 for ; Thu, 15 Apr 2021 02:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbhDOC2l (ORCPT ); Wed, 14 Apr 2021 22:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhDOC2l (ORCPT ); Wed, 14 Apr 2021 22:28:41 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A38C061574 for ; Wed, 14 Apr 2021 19:28:18 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id b17so18907402ilh.6 for ; Wed, 14 Apr 2021 19:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J7vuUpogqSvc8cLlPB7IW3hqKwPWBq5Mgun+BSaMlLw=; b=rE0RWTkyyEXpBVDGHnFidCJTfPu/YkJ98wAiyZNv9/UwMi6Ek4XYYtJWH1oS84QCAw Xdssb6N4l7o8DBrxjNLDghGFmOfWUcCWCGwtroAcmHD2OM7joUY7mRKGjZ+Ixgt58bH/ cEpsDNGfiSqkHc19uMCSVJB9AerXtXJGwxrmkIpRC2RHd8W6aYnh1KAvJuKTR/Sa6TgJ pWLeIxNgn54D1+gMbyy1F7RMgBlxL2KzsNT03S/6LAdwed9RVhbrJlhD5HB5CvjDNtnn JCKTycmVdQXBN6o+7p6XugbzslhBB9zJMFPXkhN3oUnwHTOtU9IDAOjn8Sr2oAalsmlM GOBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J7vuUpogqSvc8cLlPB7IW3hqKwPWBq5Mgun+BSaMlLw=; b=oTQ5+VRIv7TsGezovZHAlzvqUfhKSmwWVVglas5m9wJBhqjyyhEq8dky4QHijTz/oY cIFPCtblQe+laUa/5OYX95jUo1ZOblG9cKAFZVPiEPUhtBIRCqxqfiZ3cQZODkeeGBDK Ow9KlrFk6HuBLzhqA9nv7JjFdHv3tJTr8CtTUFrTRzV7yWlAG+TKiuSYkTUa4QhlSxUZ fzdtRc+b73H6TXgaDpOfqdOlWT/1Yp1P2FoJaNSgN+rnR+DgWjW2kFIzgL2wNM6/e1lq QjFdD3VjGhMgUlJooFsPvhhGmx4v/Ka+BgJEgz97pU6Dqs+9jkcR9tKzYovh24o6GQhj IRWg== X-Gm-Message-State: AOAM532ovqZ61XrkDuvUl2hJmq5NL/0qBTWiuPHCZAyYIJ/dY8hp7HF5 A2tOFsKOXmm4FfnRS5djv/w= X-Google-Smtp-Source: ABdhPJwHs670byDqv2itCPZCunBXFvXXqiYIiUgKjZc4TfevCPEg9J/JDUDFoKDFgxX7kbkl/J18tA== X-Received: by 2002:a05:6e02:1d9e:: with SMTP id h30mr983586ila.214.1618453698370; Wed, 14 Apr 2021 19:28:18 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:17 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 12/13] sunrpc: provide transport info in the sysfs directory Date: Wed, 14 Apr 2021 22:28:01 -0400 Message-Id: <20210415022802.31692-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Allow to query transport's attributes. Currently showing following fields of the rpc_xprt structure: state, last_used, cong, cwnd, max_reqs, min_reqs, num_reqs, sizes of queues binding, sending, pending, backlog. Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 35d8109931cb..7a56e30b92c5 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -76,6 +76,56 @@ static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, return ret + 1; } +static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); + ssize_t ret; + int locked, connected, connecting, close_wait, bound, binding, + closing, congested, cwnd_wait, write_space; + + if (!xprt) + return 0; + + if (!xprt->state) { + ret = sprintf(buf, "state=CLOSED\n"); + } else { + locked = test_bit(XPRT_LOCKED, &xprt->state); + connected = test_bit(XPRT_CONNECTED, &xprt->state); + connecting = test_bit(XPRT_CONNECTING, &xprt->state); + close_wait = test_bit(XPRT_CLOSE_WAIT, &xprt->state); + bound = test_bit(XPRT_BOUND, &xprt->state); + binding = test_bit(XPRT_BINDING, &xprt->state); + closing = test_bit(XPRT_CLOSING, &xprt->state); + congested = test_bit(XPRT_CONGESTED, &xprt->state); + cwnd_wait = test_bit(XPRT_CWND_WAIT, &xprt->state); + write_space = test_bit(XPRT_WRITE_SPACE, &xprt->state); + + ret = sprintf(buf, "state=%s %s %s %s %s %s %s %s %s %s\n", + locked ? "LOCKED" : "", + connected ? "CONNECTED" : "", + connecting ? "CONNECTING" : "", + close_wait ? "CLOSE_WAIT" : "", + bound ? "BOUND" : "", + binding ? "BOUNDING" : "", + closing ? "CLOSING" : "", + congested ? "CONGESTED" : "", + cwnd_wait ? "CWND_WAIT" : "", + write_space ? "WRITE_SPACE" : ""); + } + ret += sprintf(buf + ret, "last_used=%lu\ncur_cong=%lu\ncong_win=%lu\n" + "max_num_slots=%u\nmin_num_slots=%u\nnum_reqs=%u\n" + "binding_q_len=%u\nsending_q_len=%u\npending_q_len=%u\n" + "backlog_q_len=%u", xprt->last_used, xprt->cong, + xprt->cwnd, xprt->max_reqs, xprt->min_reqs, + xprt->num_reqs, xprt->binding.qlen, xprt->sending.qlen, + xprt->pending.qlen, xprt->backlog.qlen); + buf[ret] = '\n'; + xprt_put(xprt); + return ret + 1; +} + static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) @@ -175,8 +225,12 @@ static const void *rpc_sysfs_xprt_switch_xprt_namespace(struct kobject *kobj) static struct kobj_attribute rpc_sysfs_xprt_dstaddr = __ATTR(dstaddr, 0644, rpc_sysfs_xprt_dstaddr_show, rpc_sysfs_xprt_dstaddr_store); +static struct kobj_attribute rpc_sysfs_xprt_info = __ATTR(xprt_info, + 0444, rpc_sysfs_xprt_info_show, NULL); + static struct attribute *rpc_sysfs_xprt_attrs[] = { &rpc_sysfs_xprt_dstaddr.attr, + &rpc_sysfs_xprt_info.attr, NULL, }; From patchwork Thu Apr 15 02:28:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12204127 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.7 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 8C52DC433B4 for ; Thu, 15 Apr 2021 02:28:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73FEF611B0 for ; Thu, 15 Apr 2021 02:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbhDOC2m (ORCPT ); Wed, 14 Apr 2021 22:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhDOC2l (ORCPT ); Wed, 14 Apr 2021 22:28:41 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D464CC061574 for ; Wed, 14 Apr 2021 19:28:19 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id x16so22744118iob.1 for ; Wed, 14 Apr 2021 19:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VHn8kyaxpvuxiGlh5h7Y6bmqsgwXzLA56QHLJITMaS8=; b=MsT+FnrwVLVUy4JgdcfK54CTNeEuPH86MikhVENR39H3flI+IA//BIJNccqGgmteqq i4P3bjNKnKjRs/kGIh7EI/2aGE50AH/+R3RJnHQPnGdVPORP4PO09e1zcwWnyJjzD5HS KnLJKyZ6p5vOxh+v1/XVSFVgdLVwfriZJnajHOx5LkVlWKzRCIgWNVl5xoqr+AtZTPgA ZW1Ku0kB9ksRkFXpG2Kpwh0mx9NxuA+VTiXU1J2V8Zmjub/dHPlMcccSB65R0ggNN3Vk +sWArHoWZDRgQkMJNzgx2f1SZDfxziKkyMwuProbz2OM0KIpmN/jw0tIskb2HmzPZ5cg kXnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VHn8kyaxpvuxiGlh5h7Y6bmqsgwXzLA56QHLJITMaS8=; b=Ppd5wliAr9du0bWog1sWkyAuX4eaauZ+L2CGDDKNLz0mRDDR6yvlcgdui05DtX019g sYSjY4EAAuWF7ufCmvFbF33V2uwLioIzZ9MO8Rqk7bo/AnvumWavw619JU1IRQ6blN8W tzsbbRIXP00TQFfk3EADe2oAVMOImx/eM1m45CDE/wfU9igY8QiJzioWebp8tYvMFMDo o46STAlfJYEIlkX27bcRqnaCOj3z1LXr4WkeFMCJ2RJzSlDzPaxtiCfTQRzgXQFp6tqE PWfEyAOfnN9LWB+rQ8z4AVuiPagUO9wXE/CJhEH+VdDX1ix6kX/jhdTIuQ14gGEFds/l Y63g== X-Gm-Message-State: AOAM5323wxazCplPtNLQGcPSM8NUULfTl4QQLXf/9e4p5P/16nMbqX0M VMgLzcwNjNjeZXo4lkR7MUY= X-Google-Smtp-Source: ABdhPJwsOqDo8+JP5dux0oEHH3037jbgPQfbwfBJap9Ihj3w5ujvikCyg1sBn7AZKZd8Ij4iYuOljQ== X-Received: by 2002:a5d:8893:: with SMTP id d19mr832859ioo.167.1618453699328; Wed, 14 Apr 2021 19:28:19 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s11sm608917ilh.47.2021.04.14.19.28.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 19:28:18 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 13/13] sunrpc: provide multipath info in the sysfs directory Date: Wed, 14 Apr 2021 22:28:02 -0400 Message-Id: <20210415022802.31692-14-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210415022802.31692-1-olga.kornievskaia@gmail.com> References: <20210415022802.31692-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Allow to query xrpt_switch attributes. Currently showing the following fields of the rpc_xprt_switch structure: xps_nxprts, xps_nactive, xps_queuelen. Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 7a56e30b92c5..94b47d6c6b79 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -58,6 +58,19 @@ rpc_sysfs_xprt_kobj_get_xprt(struct kobject *kobj) return xprt; } +static inline struct rpc_xprt_switch * +rpc_sysfs_xprt_switch_kobj_get_xprt(struct kobject *kobj) +{ + struct rpc_sysfs_xprt_switch *x = container_of(kobj, + struct rpc_sysfs_xprt_switch, kobject); + struct rpc_xprt_switch *xprt_switch; + + rcu_read_lock(); + xprt_switch = xprt_switch_get(rcu_dereference(x->xprt_switch)); + rcu_read_unlock(); + return xprt_switch; +} + static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -126,6 +139,24 @@ static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, return ret + 1; } +static ssize_t rpc_sysfs_xprt_switch_info_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct rpc_xprt_switch *xprt_switch = + rpc_sysfs_xprt_switch_kobj_get_xprt(kobj); + ssize_t ret; + + if (!xprt_switch) + return 0; + ret = sprintf(buf, "num_xprts=%u\nnum_active=%u\nqueue_len=%ld", + xprt_switch->xps_nxprts, xprt_switch->xps_nactive, + atomic_long_read(&xprt_switch->xps_queuelen)); + buf[ret] = '\n'; + xprt_switch_put(xprt_switch); + return ret + 1; +} + static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) @@ -234,6 +265,14 @@ static struct attribute *rpc_sysfs_xprt_attrs[] = { NULL, }; +static struct kobj_attribute rpc_sysfs_xprt_switch_info = + __ATTR(xprt_switch_info, 0444, rpc_sysfs_xprt_switch_info_show, NULL); + +static struct attribute *rpc_sysfs_xprt_switch_attrs[] = { + &rpc_sysfs_xprt_switch_info.attr, + NULL, +}; + static struct kobj_type rpc_sysfs_client_type = { .release = rpc_sysfs_client_release, .sysfs_ops = &kobj_sysfs_ops, @@ -242,6 +281,7 @@ static struct kobj_type rpc_sysfs_client_type = { static struct kobj_type rpc_sysfs_xprt_switch_type = { .release = rpc_sysfs_xprt_switch_release, + .default_attrs = rpc_sysfs_xprt_switch_attrs, .sysfs_ops = &kobj_sysfs_ops, .namespace = rpc_sysfs_xprt_switch_namespace, };