From patchwork Mon Apr 26 17:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 1F827C43461 for ; Mon, 26 Apr 2021 17:20:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE51D610A2 for ; Mon, 26 Apr 2021 17:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237083AbhDZRUv (ORCPT ); Mon, 26 Apr 2021 13:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236895AbhDZRUk (ORCPT ); Mon, 26 Apr 2021 13:20:40 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF23C06138C for ; Mon, 26 Apr 2021 10:19:53 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id p15so11500219iln.3 for ; Mon, 26 Apr 2021 10:19:53 -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=gf/HTiMOF7lEE7p7o4BD7uDS+joARQgZSioVyNny/f4=; b=g4kLWKC7MuOmJ40y5LRQbWL8lbJEhYprWTjsmMpe6gqP3TeGlp3wtfwGviNWDSjGK5 XpO3IEaS+wu58mKIUd5jXkty8NXfBZVHgJmF4Y3+/4uBnvNH3MMjj3mhQPKsBPo/j24F zsOtyuEfmxlKOASkRNcVJwNHkQnvVhriURINH1BLmPCePtAMssg815unwPyw371e1SCe HzQTY8MdfCjWm3i9eDWmdsfw7TkLm5zVAGuG3GrVCDwkbl4TyP80nOnMvYhKFEQQLbZb HVQCExuFCX0DAqbcRY6WE52UsFSvn98GtomjdOfoqMbjdvLyjNeAst+qUaiqaKwYatXy r7XA== 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=gf/HTiMOF7lEE7p7o4BD7uDS+joARQgZSioVyNny/f4=; b=DbyKYfvyoQdn8ygqSFZZRvT1CFwftul3yjIA7X8pZ2yJjjyt1/UlnqislXUTUcQUhk ONyPbCX7AzqUH2/LkZcDDYX9NqQ8ilX63LPpOaAynYu5rN/nJLFZtK5bmFcckB5UsiB4 ThkAY6WCOqC/5WuZ5lLrp2m3tOGvVoHNLDnYmZ9Yw2Dyq22d8LoapaWxniNDoT42J9fy 47YybquqvG6hMLYyTyrbiS6oo++FYXaS8/SvsKohJiUiy4j1wO/emj9E1GcchL/nd2/7 78kYGZApsQQl+NEmE8BWmctaXhkWbzXd6DL2QnyMYfy0YvyAS4SFi6KyLSmpMYdRu44M PKkw== X-Gm-Message-State: AOAM532r69v5bK+zmQyh+iSQYu5jBY6noIFHBllcjxQjUe7i9M0htGay ycclFfIbCMgNZQDTgwvLoWY= X-Google-Smtp-Source: ABdhPJw3zqt8qsx1g8EaCBwm2X4X/iHfDrU7PABQ8vrDst9OmEPrKpkWiWcnShZ5nITB1qJFN5SRZg== X-Received: by 2002:a92:d688:: with SMTP id p8mr14620171iln.268.1619457591132; Mon, 26 Apr 2021 10:19:51 -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 x13sm207297ilq.85.2021.04.26.10.19.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:50 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 01/13] sunrpc: Create a sunrpc directory under /sys/kernel/ Date: Mon, 26 Apr 2021 13:19:35 -0400 Message-Id: <20210426171947.99233-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 Signed-off-by: Olga Kornievskaia --- 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 Mon Apr 26 17:19:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 70ABDC43462 for ; Mon, 26 Apr 2021 17:20:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46BE1610A2 for ; Mon, 26 Apr 2021 17:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237091AbhDZRUv (ORCPT ); Mon, 26 Apr 2021 13:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236884AbhDZRUk (ORCPT ); Mon, 26 Apr 2021 13:20:40 -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 9EA49C06138B for ; Mon, 26 Apr 2021 10:19:52 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id b17so47242000ilh.6 for ; Mon, 26 Apr 2021 10:19:52 -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=i4aCM5UfvziQ7sazTrpdsnh7+wCB9a6RVTMhW0Gm1zc=; b=ffZvDwU1ENdQqreRESHRB+LFUyL5IZiKEOjqdpt/K1bRrFMoKEpeBlAYkz1vupRrnn cuMfvP7Fvk2pysTVBjh8MBsm2Ki30QUDkBTSAgrXmX//t29CgQGv57LCXX8DLeqv5hcP m39xzxXY8b+aG22Te+3lEMIAR5f+dkmowCFWOWkruA3iza8QMwA2hfnKDIBHhYbZnTol vvhbyqutPI37BtaiXWGa8orYZqjfgnwgdaZQyh2D/ErPwf8muiK7hqES41RskcdjsteC fgqgB6tykCNoEWkViRAiojir8FObden9vAF/aG0kVin7XkXz0upkR54nDVxXKoAyMOrl Zoag== 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=i4aCM5UfvziQ7sazTrpdsnh7+wCB9a6RVTMhW0Gm1zc=; b=CGDkkPMjqvQ9plOh3RTaQDOJJi2uBgOWOwU1kC76L48uXvvQ6dm4HPTNn8X1AEVNwY dxv3mP57a8/yKUDVVx4zZTvEpOLMuqy43R3yEmt5A3MDUvwnOP99wKa+8NM6r2VxXEOu G0NlDgstSKdR4gCXJf43/7eXBHCa5jeowcTMziafHRwkR/7JMulS0P137V+mMm456hP9 rrMa9mJ7p3goTS2v333OIuAB4kls5YE4kx5Rxl/1d7rrFJ5sgziu+YPgGWxxXEyeECvg Z+AVfvszUyT34riqTS4EyHnclwTZWRVh+qxHPXkY7dBR+aqG57Tsu4r88/jkI1M4e4PD 3DiQ== X-Gm-Message-State: AOAM530+va1kItKyvwqQg7FM8bA/5QwxcsYHg/XyMMnL2PAtKyoZ0Cck JgtLjDEmxzPUgc6939+iRVQ= X-Google-Smtp-Source: ABdhPJyVoke10QqZCUc3380HQpowbxEcYslijblTtH+43h/qjhJYnmXgVtia/YaTPYMgVVesCYk8wA== X-Received: by 2002:a92:ab01:: with SMTP id v1mr9397159ilh.190.1619457592135; Mon, 26 Apr 2021 10:19:52 -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 x13sm207297ilq.85.2021.04.26.10.19.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:51 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 02/13] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Date: Mon, 26 Apr 2021 13:19:36 -0400 Message-Id: <20210426171947.99233-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 Signed-off-by: Olga Kornievskaia --- 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 Mon Apr 26 17:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 96B20C43460 for ; Mon, 26 Apr 2021 17:20:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62796610A2 for ; Mon, 26 Apr 2021 17:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236789AbhDZRUn (ORCPT ); Mon, 26 Apr 2021 13:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236475AbhDZRUj (ORCPT ); Mon, 26 Apr 2021 13:20:39 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09353C06138D for ; Mon, 26 Apr 2021 10:19:54 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id p8so4066061iol.11 for ; Mon, 26 Apr 2021 10:19:54 -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=wFro3kd9/asNeGAHcRnc8A/mXkcLdDGOdfZLm7tmntI=; b=CVxsWX7KT6Pq5F5jS8Y95N36IfiRlyepTKAUdeieJ7IE2imRuuGhe7fbv/GvCZM2i3 aZo8b6NbCj/u3SJykRuJ9F3pQaU72WRJKaVg1C1g/XEruEp5gaxE53MSJfij3A2o4TpP r8WYCdJMcoGdj+rSW4HxzMkEJZQ9ulWAGTp232Ny6R2uqCMO7bvdTnzhApisTTaT+Bja 47eg7v0qKMawpUS5VFaFKtjUF5ZAOe8AD+N+mrsVsNp3zEt8YqDMFj4HOpxpHJjvIxTl aZqB62j2Znvc4Fj/Rj5VjlnSlP1gHvM8G1Y8yFOmFHBNVglkBTkvdaidryFHdxjBnvdQ IfAQ== 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=wFro3kd9/asNeGAHcRnc8A/mXkcLdDGOdfZLm7tmntI=; b=JUIkXT6JYTA8rvGYT20FXCwCZbRse1uf41HrSxNaAVDoUbi7b5n9+KwKlxbrgSXHTG 3f5mmm1KkzLYGU980/ZJCvtFFdt0X3uyUgB7AbwwtlGjPcoJKTl96DiAIcr4iKI695lJ LQGHPdjdqFuxX8YeLUD8/Ab+/A7XVFCHxt45du/qXuTil06Oxu/uaiTLsVa+BjgKFOtw gRR76cbUfftZtSG+48y+vaIVBV4mDFw097KtYAQUCApZ/oHpUKcdrY6xKvL6+aLiATGm 0fWYHtQXmQpfrahXsCcAXHudh9DDqP62CiwedHSRVxmq7XeLJq7pPvPy9kw5c2oW0s3s qibQ== X-Gm-Message-State: AOAM532+KaEVPh2fmPZO+uTy2NBDWz2UKq0xyyBBj2iVFdVWIMvrrrK/ zxCFcs7HzHrTqGuqwsVRIws= X-Google-Smtp-Source: ABdhPJweaR49G9p8O/ERFJ3tU8m9NaHq7optZnmfKh3Jh/DflgYMrzz7FMdXS+zc6Hx6gRL5N9rRJA== X-Received: by 2002:a6b:710b:: with SMTP id q11mr15270880iog.196.1619457593514; Mon, 26 Apr 2021 10:19:53 -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 x13sm207297ilq.85.2021.04.26.10.19.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:52 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 03/13] sunrpc: Create per-rpc_clnt sysfs kobjects Date: Mon, 26 Apr 2021 13:19:37 -0400 Message-Id: <20210426171947.99233-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 Signed-off-by: Olga Kornievskaia --- 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 c2a01125be1a..dab1abfef5cd 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 Mon Apr 26 17:19:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 298B1C433B4 for ; Mon, 26 Apr 2021 17:20:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE2E2610A2 for ; Mon, 26 Apr 2021 17:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237027AbhDZRUq (ORCPT ); Mon, 26 Apr 2021 13:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236841AbhDZRUj (ORCPT ); Mon, 26 Apr 2021 13:20:39 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54895C06138E for ; Mon, 26 Apr 2021 10:19:55 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id v123so5703179ioe.10 for ; Mon, 26 Apr 2021 10:19:55 -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=yV4RoRoB2tILS34+fpesh6cjG3ew0tRbFeD0KUnY3Ss=; b=efleueftMbvfq6GbbGowcTszLdcy9tL57Gsfv8uMljO2H7KHjjomUyi/dsKlfRahas RvGL6vfyE6QlM3Z1TE/lthIN6E5+00GIcuWx/UKxZ9pC23ruoOa1rD0tjFTxi+oT7bNm 07d5EaBXRODLGtKDHnAv2vKDSOKBVCGwlEC0k0iuWRlgi7D4tSYSXdiq8D1/TlSfVUi4 g5IXawvPM93arR2v57sQ2x90kiSDvpgK/Y3/r1NeQtQ32lSHrJD/ytwTKWkqS/OO5m3Q R1ziAPb26/iMPLNiZYKnaB8ml01z6M6TM19X4BTOJx1uC8XeUMwSQCOut8a4FoKmMDC1 UmMQ== 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=yV4RoRoB2tILS34+fpesh6cjG3ew0tRbFeD0KUnY3Ss=; b=jGyZws0g1v7Z7V+POJmJzU7JVuDmdDgrHTD6vyB8JHiHlxqt+yGiWi79yhbEKXZqI0 coPXDOhNUJKpzabqHGgAVWMRqe9q90KgX3/XpT0+NJi0i+AOAMxmp6nNGXfS6w1rFF4C enQ+c7GL/nx0gvBysODMkyGHJHdOlQ4TsMJOrtGEioOpanyP9/NnHdupg0dP7EJhpgxY 2jLx36Eolib3DnieBaHx479Qh3mAp0s+7tYoXyDVqLXzpNlx1qQy6ANckF2N11RuTIzz NVqfQX+k4JMsdElr0DaefOlrk+sRXlUBVtVMemS1bkrpRU8SvdmJmI3JxVtMk/j4Agy1 hssA== X-Gm-Message-State: AOAM530B+nPMCWzC4Iqfe3gi1QltNQ7p9797W80TytlBnLtEDbzJGoXl Ic8oh7peT+yYOQ9N19O5Mlc= X-Google-Smtp-Source: ABdhPJyGSEa2BSX7IWk4ICuLQWSX1EouL1b4Y/qLx+xwOVuwNlNagbbwussFgaa7eLQ8KB4SkdvVNw== X-Received: by 2002:a05:6602:1da:: with SMTP id w26mr15446047iot.170.1619457594779; Mon, 26 Apr 2021 10:19:54 -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 x13sm207297ilq.85.2021.04.26.10.19.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:54 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 04/13] sunrpc: Prepare xs_connect() for taking NULL tasks Date: Mon, 26 Apr 2021 13:19:38 -0400 Message-Id: <20210426171947.99233-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 Signed-off-by: Olga Kornievskaia --- 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 Mon Apr 26 17:19:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 C7B48C433ED for ; Mon, 26 Apr 2021 17:20:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DCA061185 for ; Mon, 26 Apr 2021 17:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236715AbhDZRUq (ORCPT ); Mon, 26 Apr 2021 13:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236845AbhDZRUj (ORCPT ); Mon, 26 Apr 2021 13:20:39 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B38C06138F for ; Mon, 26 Apr 2021 10:19:56 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id t21so5943922iob.2 for ; Mon, 26 Apr 2021 10:19:56 -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=rHzBpwJvTvHqQjiOwfvuYiOBLOQx3SSYI4e3E1a/UCY=; b=BvYHmZ4XMGYFfqiHp8K29N/cv1WmfJWo+35iEeP7Hp8lsCO26mxTx4lOW4MkgA0S6X iE0Krv/3kGyu7dJXJxQEARMcUkv6zee8Lobf6D3XPtHIqe9pFCN0ByXF8JCv4kWCZ/GW CwMnKHhxdPfYwi9imMBBFqXdVJKy3zB1oDhR1D7umvC4pTe8Lcceob3k+s1d6U6DNehh 5MXdFV0erAE+YSXEVrCyAsiSDGk6YeQs3zpDBoeECs0FlR1AC9GZnZKKihMUQbNoL0G7 j1vKp7+JdPT5sxaohuINAAbVFk2dOmJf4Wb3SuV0IKVRE3UluCMxyrm0uSLKQTSzNDQ9 /nBg== 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=rHzBpwJvTvHqQjiOwfvuYiOBLOQx3SSYI4e3E1a/UCY=; b=ServJwTe7INHFEpZr1eT3C3m6idKwIPixJofLVmsbBd8Mdjybfeyk2aBhsON1qavKq 7Q4WFYvN7WIo7JbytmIvVs/Dapgl883qh82U0wqzYbk1vg+JPDHR5SZLkrQ7ElfZXXee i7R+1GKsJiB5Q2W0mW2tKls2L6zSaysCyRpdLmLHDZ8zHOhDiiDspjiPAqcProzaWeWl e9FfMXY1yI93TcqVINYeW+gny42J4RXDu+GhE+RoZUhQ3kBXP/5rOpd0Cq8V0ZczieV7 nNH3zNyWjs34NmHec5gZwVw8BB2sypWxJ1NBfrrhxYufj5Z831Qa/Vml4blS7wQuxzHO BXUg== X-Gm-Message-State: AOAM531kL4c8Xd4hKAJk5UjirPcICvxSDU5IwRglD5WqiUM68evPebPW ofK8Bo3zA0DHbn6QERfGC8QAgw2Cxrgbtg== X-Google-Smtp-Source: ABdhPJysd5DihesdXMI5/3vRxfAp0KvNR7B78U3B5KG7DRHJntb4T5+w0HNHQ7DeOPUbTihsigZAzw== X-Received: by 2002:a6b:7314:: with SMTP id e20mr15321646ioh.74.1619457595680; Mon, 26 Apr 2021 10:19:55 -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 x13sm207297ilq.85.2021.04.26.10.19.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:55 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 05/13] sunrpc: add xprt id Date: Mon, 26 Apr 2021 13:19:39 -0400 Message-Id: <20210426171947.99233-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 Signed-off-by: Olga Kornievskaia --- 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 e5b5a960a69b..fd58a3a16add 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1722,6 +1722,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) @@ -1734,6 +1758,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++) { @@ -1762,6 +1787,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 Mon Apr 26 17:19:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 16F63C43460 for ; Mon, 26 Apr 2021 17:20:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB28E61185 for ; Mon, 26 Apr 2021 17:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236845AbhDZRUs (ORCPT ); Mon, 26 Apr 2021 13:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236131AbhDZRUj (ORCPT ); Mon, 26 Apr 2021 13:20:39 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D150C061342 for ; Mon, 26 Apr 2021 10:19:57 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id t21so5943964iob.2 for ; Mon, 26 Apr 2021 10:19:57 -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=+Fg1CTEpqXVj95kKutPWoBVqcxEtRPxgNEonrsSkYnU=; b=T+bZ1Pi+9f1+8SNltSJWUMZ3WPt8l+x0e+1Y+blH9uONSfWta8ZlZcYps5kc5QFR45 dFk6B9V4uIA5FQhnukDbi5vDXGacarIJfPbMgkIp3TcogKpZOvfVx8PuuFJe/wPoojEc LUtkczjj+ef2QOZ/qpK4Cog2Qel8yv2atTIjrViemZElmKGTR8LtqEeaIRObaRnX55iW TYSPNniIJL8dNyldrQ9d0QzT5TxtDAGloG6PkjiqKHFUo5e/2GZ1l3AbarRPI9uJFAOP MzUllNfYPFOe6ki6vMulKIcPAATHsj5yocWnuO3oWghp9Wlw2lgVBgHfViiCK7X48b32 sG4Q== 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=+Fg1CTEpqXVj95kKutPWoBVqcxEtRPxgNEonrsSkYnU=; b=I6Mmbt0EkaU31f21l6nVgTBoQ0uG8ppGbGwt+Wxfa/5ETJWZ8Xqs/iQO3krcjhCuWu O2JSHF+VaSg+DxUfG8olxZKnO2XSzGyDUbQpu+NBtQF+SE8QT6cbMuRHH7ATa6Tp2dXQ uUFYzHVjOIQRJULarZv+ZFyl1AcLpoGrwu+p6ckg3ws17ZLHMYD7ZoG4zD69SMXKZLXr aIwf4FYYvhFp/3ycNNH05SrpzW6naVbl496nUneZRNmnMQXZtCqiVP6MCq6h8oodAYOa yZmQLmOuDQvviMLjTmRzioCr+hwwhtOPfUgjIp3lLiTAMuXPne6vKfIXyZEIFrT7WowJ y9RA== X-Gm-Message-State: AOAM533fqanAPM52BglLWqhRCwJQbojkrpc/rxqDDq/39/r/NSfYHmUi iBx7aCyQ3S1ZchUnwiCugyY= X-Google-Smtp-Source: ABdhPJyFNC0H8XAj/meYUgoFh6LBMjCHXuw1+HLOiUbAZQevA3c7/1BwTgbtJn6sNyvT6UIuHHnRrQ== X-Received: by 2002:a05:6602:1641:: with SMTP id y1mr8853731iow.54.1619457596903; Mon, 26 Apr 2021 10:19:56 -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 x13sm207297ilq.85.2021.04.26.10.19.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:56 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 06/13] sunrpc: add IDs to multipath Date: Mon, 26 Apr 2021 13:19:40 -0400 Message-Id: <20210426171947.99233-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 Signed-off-by: Olga Kornievskaia --- 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..4969a4c216f7 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, gfp_t gfp_flags) +{ + int id; + + id = ida_simple_get(&rpc_xprtswitch_ids, 0, 0, gfp_flags); + 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, gfp_flags); 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 Mon Apr 26 17:19:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 42B38C433B4 for ; Mon, 26 Apr 2021 17:20:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A772613A9 for ; Mon, 26 Apr 2021 17:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236131AbhDZRUt (ORCPT ); Mon, 26 Apr 2021 13:20:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236883AbhDZRUk (ORCPT ); Mon, 26 Apr 2021 13:20:40 -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 725F2C061574 for ; Mon, 26 Apr 2021 10:19:58 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id p8so4066303iol.11 for ; Mon, 26 Apr 2021 10:19:58 -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=OEB3fsVvOc0l4sGUbovZ3sxmkNfiwInhgmEzkRx418Q=; b=SB4Q0O6os1GmuURZAOdi+CUC228xfPbAOZIMAOEx6PqWSdwvU2OKv7HlhXBR6vceK5 lmG5CE+76+tcm2ObrgyGNB0o0mvU2YzUJ87rz3gB5rdk+qZjXAthql0rpNtitj/8fO2O iQvyIhFbP9G1MlHR6aMoRoUf1dq3RMDw+WBvAdcwvI0WcWVktLGrMHlgsIcQFDj+36Fb B3bAKrmUsQ8eRB9jX41vqdVg757k/pQhM8CzkVjxtbnv43U3RERE2kDoyjN9NJRuh3FK jgp6gi/nkpYtSb4hlqKC0ZISm+eyhIGQtq4KeBBMeqfqICBl2KO+yrPNne6ty0A0affJ L3JA== 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=OEB3fsVvOc0l4sGUbovZ3sxmkNfiwInhgmEzkRx418Q=; b=Ly/TogN54cj1ZtFxZQxOezpnorjqmVRDP95FdCYSp2x+6NYn6QE0qjyswtLZd7u4Q/ CuP7EHifjk4Q/QVlDsbMp3HjTuo40byD9m8Ot12JrNJIgvJ+I+vHYIlPTecjOGLwQPg2 AQMe64Cm93j3Ua3IZ1hni8fhtlRZS2ThH2xLw37afs1QO1lCOjEpQKZsNsFghav1sFMW At5bYWTRmbcRAKcV+za86fd4K4qKuIuw/xFyyC2wzyp4L0SNMH5CXrFurLcyce8OKtxi MEqwPAhyAa7HDniZUSLL2Dtn7hrLzyfPhPsTdpQ4j6Kh4GNmySQJah0Jf6TLYQIDSyzw JVTQ== X-Gm-Message-State: AOAM530gmeQia02rilnUTSskVEdfpODEckah8mFS0Ii7pikPQCCfry6I NOSTUoed2HAwGq6LSXCFNKw= X-Google-Smtp-Source: ABdhPJxtFe50gIWXlVsEb7rHEaHHf+L8RT7bwiaUEH7rFPEC6h/sTvjWDSz8bm60mX8V4T+RVcg2Cg== X-Received: by 2002:a5d:9917:: with SMTP id x23mr15111202iol.22.1619457597980; Mon, 26 Apr 2021 10:19:57 -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 x13sm207297ilq.85.2021.04.26.10.19.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:57 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 07/13] sunrpc: keep track of the xprt_class in rpc_xprt structure Date: Mon, 26 Apr 2021 13:19:41 -0400 Message-Id: <20210426171947.99233-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 --- 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 09953597d055..71500eb89bff 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -73,6 +73,7 @@ unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE; unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE; unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRWR; int xprt_rdma_pad_optimize; +static struct xprt_class xprt_rdma; #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) @@ -349,6 +350,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 Mon Apr 26 17:19:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 4DE83C433B4 for ; Mon, 26 Apr 2021 17:20:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 220B161075 for ; Mon, 26 Apr 2021 17:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236774AbhDZRUz (ORCPT ); Mon, 26 Apr 2021 13:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236184AbhDZRUm (ORCPT ); Mon, 26 Apr 2021 13:20:42 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E270C061756 for ; Mon, 26 Apr 2021 10:19:59 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id j12so2372116ils.4 for ; Mon, 26 Apr 2021 10:19:59 -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=JnukR7EdQqY8PvozClts/MwX3SH4ugLOmxenrgo63Kc=; b=AJwVfu2bfFaj3x58+kUuHw6o6CifkuLqwqlOehxSMTtD26pq80hfBggYgIadhTTXnk VHLDZk9jEZQliSNWepIETV4Yd6FN4XFWW0481vqusb8kTVKKe75hANlJBjkr6Xmiyscw QAyfyYvSY0jKy+rf4ehCkDWE/lpFN44WsZvqa53FsuoEINX24jnK7rFgHm3fmBOHhcSx xIbv0C0pUtO9g7olQ4/KGu2GxqDL3xLI2eULISbAy4f1xOFbPkidBmKhnoKJMRoKxk2E OeRkCJ6bEqG7nGRtlAm4DeuHQ0N70EM2ATQu2sD7jUBj+OxADrTmdeTzyJk8RPpRxiWl nfcg== 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=JnukR7EdQqY8PvozClts/MwX3SH4ugLOmxenrgo63Kc=; b=gou76UxoAulIkpcFSt7OqEwAdMbkTUscmg3w1oTrqYOs0eOZ+Rf0ygm7Cm1/kVBvYC K4N1boNAxIcH/vyFjYOy00o4jl9bskB9CckgI0fUwEzjGrUaarIe88jeoyAQLccFgPQI VXOp5f4sJeCcNyFRIJirTB4sZ43W2J5xW/P9k1fWXoeJTdEv3TcdlsrlVdhxzrFM85pB Jn5+yQucxvERO3eCaLEq/1Up2vmILeRQK/bOAZrc9J6pD7j2Mi86jT32eKO2aUmonzbS KuALlWLTk6aetYnqh4ZZ9rVamPY/DzMiJzUVNrh+8wJamwQMuHoMPr6U/HYlzyqtQRrx Dj2g== X-Gm-Message-State: AOAM533ilUAO4JeZKvvVcPBy7MxaBhlHnlodW/1epav8Dj7NsBEbGm0f 9GplinmzmDQFOMQ1AqNIUbw= X-Google-Smtp-Source: ABdhPJxFLxQON/2Kqg/R9MmWXjwTCUf1OEsVtOTn0HFhh6vMXuY6FgjDih5K3QekF2nogWkpHrnZhQ== X-Received: by 2002:a05:6e02:1c42:: with SMTP id d2mr13791022ilg.287.1619457599048; Mon, 26 Apr 2021 10:19:59 -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 x13sm207297ilq.85.2021.04.26.10.19.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:58 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 08/13] sunrpc: add xprt_switch direcotry to sunrpc's sysfs Date: Mon, 26 Apr 2021 13:19:42 -0400 Message-Id: <20210426171947.99233-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 | 99 ++++++++++++++++++++++++++-- net/sunrpc/sysfs.h | 10 +++ net/sunrpc/xprtmultipath.c | 4 ++ 4 files changed, 107 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..03ea6d3ace95 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,28 @@ 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, + gfp_t gfp_flags) +{ + struct rpc_sysfs_xprt_switch *p; + + p = kzalloc(sizeof(*p), gfp_flags); + 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 +161,28 @@ 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, + gfp_t gfp_flags) +{ + 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, gfp_flags); + 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 +194,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..52ec472bd4a9 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, gfp_t gfp_flags); +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 4969a4c216f7..2d73a35df9ee 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, gfp_flags); 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 Mon Apr 26 17:19:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 F3EDEC43460 for ; Mon, 26 Apr 2021 17:20:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5EAC610A2 for ; Mon, 26 Apr 2021 17:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236895AbhDZRU6 (ORCPT ); Mon, 26 Apr 2021 13:20:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237050AbhDZRUq (ORCPT ); Mon, 26 Apr 2021 13:20:46 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A870C06175F for ; Mon, 26 Apr 2021 10:20:00 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id y10so6503321ilv.0 for ; Mon, 26 Apr 2021 10:20:00 -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=C48GAA8S+IcSfL9O3pFMYAcocl3KuQHF61IzCT1Om5w=; b=GlnPQDvoHP72U0hEXXuxHMMhVpUCM4ksBry0zJSSRDp/1Sj1/V/DXGPG3NZ2dNd9p4 kzOpLFK5ekNN/cmsGktfBt8mBkuhi+yEad+SMGZKdA8Jb2gB2OzQvs9olm2V3SV6+8F3 tr8C5lOk57DYUTxXFYKGasZeaOYUTS88cfeVydrTqJ3rionw9X3UoTKCuU8cHjndhbth AWuSYXb/mCKGTgUjSOr36KWnRTVLTFzGmDZBPcu9E9sm1OH555xBG1EwF9taTGi+L7gh xAuB6XxgzdMxLPQJE86daj3EG2GdaGVJT7eqbzH6TA9ddWLEUyuZu0S0w9M6jwzb4at3 /IVw== 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=C48GAA8S+IcSfL9O3pFMYAcocl3KuQHF61IzCT1Om5w=; b=PnzdUOpQ9wSr/E/InvNy6s6ZKXx4DfqT8EZJdQANkdcVRS2OQv7dUEPdg0+GVNbdyW n6T3NCYfp1dToQqwguvKT8L2rW5B01LhM856sHY/+A55PmaJLMPEkOIKS+3gkzccXYSj tERKKyR+M44iGa2ADW+CXclAaoJTjKWQ5AtMaQJgXwZrx7U3fa2rfETXHml9T4+RFYD5 ZOCCwu1pJrqAaFOub7EodbIb4BfA4leXtekJPvIg8U+jZEzxyKgIRUZEJlVlxVdUxsbs p6HDArlEQSv4OmZPa0E15H9IriBDRsE8UtmfsYx3pkieFYV5rgfFBrF86Fd247EoBSR/ UHdw== X-Gm-Message-State: AOAM530UsyPVk2MlpufBxtaq5fh5nzdaqmwT0HDN8b43DaQTchAn3T78 gs458z9adMV5yoa/4+8Rxxo= X-Google-Smtp-Source: ABdhPJzOvyRfuSt9zl5GP0AFsNRKxwkmmm71WY22Sn/KNRM6r+9ahyi2ibGymUfyGnsrK7/soT/ciw== X-Received: by 2002:a92:7307:: with SMTP id o7mr14817928ilc.5.1619457600061; Mon, 26 Apr 2021 10:20:00 -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 x13sm207297ilq.85.2021.04.26.10.19.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:19:59 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 09/13] sunrpc: add a symlink from rpc-client directory to the xprt_switch Date: Mon, 26 Apr 2021 13:19:43 -0400 Message-Id: <20210426171947.99233-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 --- net/sunrpc/clnt.c | 2 +- net/sunrpc/sysfs.c | 25 +++++++++++++++++++++++-- net/sunrpc/sysfs.h | 6 +++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index dab1abfef5cd..2e195623c10d 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 03ea6d3ace95..871f7c696a93 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -150,14 +150,30 @@ 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); + if (ret) + pr_warn("can't create link to %s in sysfs (%d)\n", + name, ret); } } @@ -188,6 +204,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 52ec472bd4a9..760f0582aee5 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, gfp_t gfp_flags); From patchwork Mon Apr 26 17:19:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224707 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, 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 E86C2C433ED for ; Mon, 26 Apr 2021 17:20:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B94E261075 for ; Mon, 26 Apr 2021 17:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236748AbhDZRUy (ORCPT ); Mon, 26 Apr 2021 13:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235883AbhDZRUn (ORCPT ); Mon, 26 Apr 2021 13:20:43 -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 B89D5C061760 for ; Mon, 26 Apr 2021 10:20:01 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id b10so56765689iot.4 for ; Mon, 26 Apr 2021 10:20:01 -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=peXzpoOc4puVVmUJNSS5qW9OdxmrCfb8OZ3gqV/sQSg=; b=TKH71u3Ej8dcMwLgkpmt/oBK5spdcMCbPQSi8uP0axRK1Cj68zGboW2Up8lVA3DSlX zGjWXsUX7SBsvZl9uUCHMGhQaFUzf8lqDW6qEuR9MBjD0gGehWZiQPNFuILYzpimI2wb mo4yAP8774P8EL2IVpaNfjlhVNNKpTtNqQ5NWX49ZCaHFZD4K5AqPI6LoGe7yMIvl8zx 2kr4/CXTY488808dg4zYiIqlwnp5ekS+iAjaynr0ZdBZoG5Z4IHP5RRJYdgiDZrKK9w+ NWPnxCXo2iWO06vwWJ8r4ayoqj7YW9zWTNZYAbqQfL4An++MvSP2lbX4Hb96U3nD+9VA Spmw== 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=peXzpoOc4puVVmUJNSS5qW9OdxmrCfb8OZ3gqV/sQSg=; b=l5zuaLyXtEEH/tv0kcIp1cSjl6hxQ9WNj9tnZLo+XwjCGe+lU5VzDpvgixPAESUaMj dKBBEkukpuHVNxR/zGidAcRo711kCPZ0MPPb4AQpN8rh8RfFmyJfgmr4xme/nddtEio1 LstgG5hIbIzWbIu74KJq+P6fo7R9t0vp0orGqfddZerlD9f61bK825WSMyvR0RAhEXhL yLX8iiRMNkyTuBI2O/Fu1mXa2mchnOzDgdIRdefyIfeOtlScq8f1YdiHBAbJpkdTRWLD cFnEOYgDSOoquIPyGEbUKsilR7BXSWzmnmrUD29C1SbbmWgMlA52qslRMSM6b0OanbkE LRNQ== X-Gm-Message-State: AOAM532S9GLTqhOBN0M15XGGCv2oU/c30NVTUJ1+sO0wpvpojb9d7oqu QgMEYls6bMXqDlAhi/WC0Qw= X-Google-Smtp-Source: ABdhPJyWZJHvCwlSDu1078QJA5Aqg77IGLSUpWJhBu99WjnwwP3R9eWSlu3A7toNL29eKCYDx5cKvw== X-Received: by 2002:a05:6638:f:: with SMTP id z15mr17270917jao.26.1619457601247; Mon, 26 Apr 2021 10:20:01 -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 x13sm207297ilq.85.2021.04.26.10.20.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:20:00 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 10/13] sunrpc: add add sysfs directory per xprt under each xprt_switch Date: Mon, 26 Apr 2021 13:19:44 -0400 Message-Id: <20210426171947.99233-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 | 86 +++++++++++++++++++++++++++++++++++++ net/sunrpc/sysfs.h | 9 ++++ net/sunrpc/xprtmultipath.c | 10 +++++ 4 files changed, 106 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 871f7c696a93..682def4293f2 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); @@ -150,6 +170,40 @@ 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, + gfp_t gfp_flags) +{ + struct rpc_sysfs_xprt_switch_xprt *p; + + p = kzalloc(sizeof(*p), gfp_flags); + 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) @@ -199,6 +253,25 @@ 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, + gfp_t gfp_flags) +{ + 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, + gfp_flags); + 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; @@ -227,3 +300,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 760f0582aee5..b2ede4a2a82b 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, gfp_t gfp_flags); 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, gfp_t gfp_flags); +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 2d73a35df9ee..839b20e72ffd 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -57,6 +57,11 @@ void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps, if (xps->xps_net == xprt->xprt_net || xps->xps_net == NULL) xprt_switch_add_xprt_locked(xps, xprt); spin_unlock(&xps->xps_lock); + xprt_switch_get(xps); + xprt_get(xprt); + rpc_sysfs_xprt_switch_xprt_setup(xps, xprt, GFP_KERNEL); + xprt_switch_put(xps); + xprt_put(xprt); } static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, @@ -85,6 +90,7 @@ void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, spin_lock(&xps->xps_lock); xprt_switch_remove_xprt_locked(xps, xprt); spin_unlock(&xps->xps_lock); + rpc_sysfs_xprt_switch_xprt_destroy(xprt); xprt_put(xprt); } @@ -137,6 +143,9 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct rpc_xprt *xprt, xps->xps_iter_ops = &rpc_xprt_iter_singular; rpc_sysfs_xprt_switch_setup(xps, xprt, gfp_flags); xprt_switch_add_xprt_locked(xps, xprt); + xprt_get(xprt); + rpc_sysfs_xprt_switch_xprt_setup(xps, xprt, gfp_flags); + xprt_put(xprt); } return xps; @@ -152,6 +161,7 @@ static void xprt_switch_free_entries(struct rpc_xprt_switch *xps) struct rpc_xprt, xprt_switch); xprt_switch_remove_xprt_locked(xps, xprt); spin_unlock(&xps->xps_lock); + rpc_sysfs_xprt_switch_xprt_destroy(xprt); xprt_put(xprt); spin_lock(&xps->xps_lock); } From patchwork Mon Apr 26 17:19:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 B7CE2C43460 for ; Mon, 26 Apr 2021 17:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8706961185 for ; Mon, 26 Apr 2021 17:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237058AbhDZRU4 (ORCPT ); Mon, 26 Apr 2021 13:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237025AbhDZRUp (ORCPT ); Mon, 26 Apr 2021 13:20:45 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4DD5C061343 for ; Mon, 26 Apr 2021 10:20:02 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id b17so47242386ilh.6 for ; Mon, 26 Apr 2021 10:20:02 -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=6jRwlsL6aSk9MpyGV4uCBh4PTylU34tEaFkoBLSTFnQ=; b=pnl1gnvjruDWEDyTSrrs2r4/OQS2vr0EQFjRr/i9cEgEZLfD4BD2jQaLD2z5tYTKTC G20700O4pf16mEq1KOrv4Ho9oL02TcJiM8fcAsPB0fxrZgAf8gOPBkW/7naKCTjYBZFD LUUfsKK/pfvGMNqBsgMSUZBtxrndKl7S1SyeVj1RZNK9unnFh3DIMWp7P+5WWrNwCFG+ wsIAV9ZDgHUjI/EwlSBSXoy5PbgVh1VOUx0HYxugjQBRcxfPi2WkjMQkl98eHFb3sf0/ ywsclaI9eLG0KHTLasNkhsqDCpuSYOMsw6MFZv3HBua7KRue7dNAkUJNvFFHbxSMTrdG 04tw== 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=6jRwlsL6aSk9MpyGV4uCBh4PTylU34tEaFkoBLSTFnQ=; b=ZXVElDy2RR9RGpw/Yc/9dCkRoSSI/QZNCslQtFaDeajDq46BzFizcfQoWVVbGxMhTx /J7zd720/9QCQZCVwvPK8ACKt30WchxTjKqI9o1WMpJONI1zIi6Np+U1lymq1I6wHujo ajL4IK6gSJtPcVOCgfXpAgrhicOkQvDJ45ht42XI9gra899vJEg5baPn5ep7Nv8wB29E 1dtkiMHHaXwjCtJjszOPJ9eiVxKHtL8hUacx0jInQJ/N8tofQAG5xW8n8TnwegumdHYZ 8z6KqFvzW+hZGLrh641CSm85MtCmvX69bvdZKSrFpaTGiVyQ5K+cdW8rcIFTC90idFNz w5DA== X-Gm-Message-State: AOAM533BZ3Ynnx233v0ZWTEViRuw79kQwVo7QTm7ZWm0IkHHaT97YF1M clCc3U/0Y7Sxn0GK3moXhDk= X-Google-Smtp-Source: ABdhPJywApHBv/YVE+SJ/UUuhtCt9OOwNrbsv+ddLA69gyLLQ6S4+aXAvpdqQ/zjEbnZ4aaoBIGTcQ== X-Received: by 2002:a05:6e02:10c6:: with SMTP id s6mr15636274ilj.15.1619457602151; Mon, 26 Apr 2021 10:20:02 -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 x13sm207297ilq.85.2021.04.26.10.20.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:20:01 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 11/13] sunrpc: add dst_attr attributes to the sysfs xprt directory Date: Mon, 26 Apr 2021 13:19:45 -0400 Message-Id: <20210426171947.99233-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 --- net/sunrpc/sysfs.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 682def4293f2..076f777db3cd 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,66 @@ 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); + + return xprt_get(x->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 +168,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 +190,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 Mon Apr 26 17:19:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 24A0EC433B4 for ; Mon, 26 Apr 2021 17:20:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECBED61075 for ; Mon, 26 Apr 2021 17:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237061AbhDZRU4 (ORCPT ); Mon, 26 Apr 2021 13:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236658AbhDZRUp (ORCPT ); Mon, 26 Apr 2021 13:20:45 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DF1C061344 for ; Mon, 26 Apr 2021 10:20:03 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id r5so7031475ilb.2 for ; Mon, 26 Apr 2021 10:20:03 -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=G0zi+heu8E83aReBPxZ9EasqAnPbQehN+00ecDk1Hp8=; b=UlgFH/elLK5IXBICKd9Ubp6cc65wa+gRH01Af6r1Jhyf+ZFDqJe3IXd1F3ndDCg3SR Rqm5nMJ0+3ShKuECW13v0LHZ44gzmFQXDiJCIAosQyo9TPQcIpKesfPz+0xUSZzajT+4 WhbF2oOzNMoOKA3nCufa5IEYD7Sh44QcP6KujIyLbUWeZ0HnFZgjPtBPzg4/Pjffo9VN HUaxtLZ78WUj7+zLD4mRLHdI1+7qWayGR2Q3KCQcpBH/WEAkIQl+teK0X6K89a+4yLM3 rAWWig6M4QCA9sYsWVwjrx6MK8Mr002eaBS1S3hopdkhGb4Ee/I4PCaCE95TsmGdG2Jo yNXw== 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=G0zi+heu8E83aReBPxZ9EasqAnPbQehN+00ecDk1Hp8=; b=LHbcaoxtu3S1fQO7Qe62LprwEJ6d9+BC1xkxWxi0EvSUdeLjSczURZuWgWRUdI5tzM aszxDM2SWnhR4vLcxAmycslvlzcQptpj3QjyJcGudZCcOnKU7QMqL0MqXIqv0YBRQroY UVygbQZBVyORq12cugZgpdJqc7Q0CBenhGGFs2jj9BybSQrOmP1BAxYcx0nRphqdUqkI BJ60tevxQ10V80vLywDR0XB7usrE8oCbwMYU+hRN8/kczGmC9kzLwqBrCGOKP0ILPBOT Fvn+9K5m9BYv6zSFwsHp1T2ny0i1ljyYWZYaJug8f9FdM3qMHbffnrwAvuORSxIGIpFY XtBQ== X-Gm-Message-State: AOAM530ktjD4q7emBSESc9kUwdDUmtgP+WVMYuStLOSnrt4E19lBA/cM zPiZBD45t5FnLutuBC3ScYw= X-Google-Smtp-Source: ABdhPJwPp3CcIny9pLkYmBXA36rdMuW+kSuTb2l/yEa+K2v6t2ESACfnjH/2cnRxmGxLocnuSGGppA== X-Received: by 2002:a92:d383:: with SMTP id o3mr14501636ilo.131.1619457603305; Mon, 26 Apr 2021 10:20:03 -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 x13sm207297ilq.85.2021.04.26.10.20.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:20:02 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 12/13] sunrpc: provide transport info in the sysfs directory Date: Mon, 26 Apr 2021 13:19:46 -0400 Message-Id: <20210426171947.99233-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 076f777db3cd..93d4111f6ee3 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -72,6 +72,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) @@ -171,8 +221,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 Mon Apr 26 17:19:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12224717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 38DA9C433ED for ; Mon, 26 Apr 2021 17:20:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 093E861075 for ; Mon, 26 Apr 2021 17:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237050AbhDZRVA (ORCPT ); Mon, 26 Apr 2021 13:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235261AbhDZRUt (ORCPT ); Mon, 26 Apr 2021 13:20:49 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584C3C06138E for ; Mon, 26 Apr 2021 10:20:06 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id c3so1057206ils.5 for ; Mon, 26 Apr 2021 10:20:06 -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=iicQx4bDLuTjkCEVSj6SiyY4lXvt0S/vEsARNB2sm5Y=; b=suFIgpmfy+x2/ICzER3GwqU5GYLiPdHUL8zxweZ+nz+huyB9bG+1INTygPXv2ks8J0 tqSUKD46NKchB8sYg0GZNc57SyR7zRCK9CJtI+IDi1vo7dhU2BJlfvQ9pHtKH5bHllQE uTs0Iy1QI6zXE/TQ08lEHhLNk4W0WaGcQioM8VCXtAce+z5Ua9g12853KMYATBnfQ0hP VQOdeEM8ohRRjMGMdYNYNcOoe5XVxDKRl/ZwyZJVtDa+SvWAY/ahWVsTBWOP0dybxpJt djSydLYXlGYbwC1uX4CZ4gi4GtPLkeE369T0EbIIHCRE4Tu+qt55TZi/oysucaG+VeyM i0KQ== 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=iicQx4bDLuTjkCEVSj6SiyY4lXvt0S/vEsARNB2sm5Y=; b=qn0MR/uVCeJ+1TnutK8ADVGM7m3IidiIlevCRoJlzKjNxPh19HsXfXOOMdz1Z13HNt zcLXKwHMPgLo5J7qjykiAWRdYYT88qLljxV6gFJbaaa6oxaeSkBvnBoVbPm7JbaJYVAW hsbBXM9ySYjajJh73Hi4vftExb/4LWq2FKOQH+2evCuyRF33/Elu8ex2S7I3mFA/wT6h 7v7EuPvWV5FNS+3IGNs273Dcx9wlAnNhKO0atH6Le8UU6c4eXnX8lm/nkZrYijxgguD8 OxFv7EglB2RhuTKgHlt8w80ErvHneNA/e1E22G07f7STxlm6sDsSJMl8Rc7mWTB2eXqH uGUQ== X-Gm-Message-State: AOAM530dU4R2wLCp8tv8s5qXcKJsNw4XiZn2phvNO/vpKXE8gt83+vQ0 AFxh5iLhpEPM5z2IK1ESEZQ= X-Google-Smtp-Source: ABdhPJwo1FVIZrAaTeX3uG5g+sDuEDiT5HmNNzAZ7H9K0zNwf/dDNgFZwGHlb26OOGFM/WZrs+fvYw== X-Received: by 2002:a92:d087:: with SMTP id h7mr8220978ilh.83.1619457604448; Mon, 26 Apr 2021 10:20:04 -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 x13sm207297ilq.85.2021.04.26.10.20.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:20:03 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 13/13] sunrpc: provide multipath info in the sysfs directory Date: Mon, 26 Apr 2021 13:19:47 -0400 Message-Id: <20210426171947.99233-14-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 93d4111f6ee3..eeac19907c43 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -54,6 +54,15 @@ rpc_sysfs_xprt_kobj_get_xprt(struct kobject *kobj) return xprt_get(x->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); + + return xprt_switch_get(x->xprt_switch); +} + static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -122,6 +131,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) @@ -230,6 +257,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, @@ -238,6 +273,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, };