From patchwork Tue Jun 8 19:59:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A576EC47082 for ; Tue, 8 Jun 2021 20:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F61561375 for ; Tue, 8 Jun 2021 20:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234339AbhFHUCg (ORCPT ); Tue, 8 Jun 2021 16:02:36 -0400 Received: from mail-qt1-f176.google.com ([209.85.160.176]:39508 "EHLO mail-qt1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234510AbhFHUCe (ORCPT ); Tue, 8 Jun 2021 16:02:34 -0400 Received: by mail-qt1-f176.google.com with SMTP id p21so4500704qtw.6 for ; Tue, 08 Jun 2021 13:00:27 -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=DIAHWVj45dREIVdkhLKJO3c8T8LLmmcu49AWaKPb/wKliKe0tRkA2tAMMZY3nQOXok ikCZ9Mr/f6oUwHQFY0p/nUXR5AgKBZNklmZ0cvb1od5TKgJgSp57SenGKt4ursuGS9TI pgLlUX//QwwN6bjsLdhjgGtjGRYz59FflwPz8R19whAUNMSBJo4DnhO/1gKD+rgOUb3t 70Cu0vA7pjC2Hsj97JkSSYXKRHL13UXdnpV+PUTO7pPI/TihNJZyGDPEdOm8OGCxdFuq lXq2i+6xYOfgyEb1hc+ieTZqYws50RUnPAbX1Q9UOxvzMFOqyCwMvMysd1gigH0cmp+H NmKg== 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=ftsr6ASZ9JksHf0k13V0q3Mc1abS8cb8x3onq4Fx47BSXAp6AsZcO1akcfuTeXIdiY sopE+AOboBDodb3hzELTemIUj3azfGjkk5ibeI7ZAVzYg6BzMjgwiI+l8ap2fF4BZQX/ mTvXVme1+Fm04sr5R+PmIDwwyA1+Zw/3du4Ci9YfG1/Rv1xZ+2hSTbmrP1dRPbZOWFpJ M/Qd0i6MCYZLwrfjnBwbdtstdUlYztWpkyU3UNgkHNSowVVaxnrIxRINippxf/7jNGhI A+AyUV3EQNmvV/Ga6LRHvSpR1GqV6Q6nizvVH77JrUyGcjIxWHpRj6nEFYGjmKcBpLjm bqWg== X-Gm-Message-State: AOAM531XgzjCLPMV5LvFF07DWD79+IIHWceBtxS6nHVIzgn0KucV5ylM QqyVvslZ6BtoygafM+U3Z48PPSAMyvg= X-Google-Smtp-Source: ABdhPJzl1nhtzfJzR3ZTzimW0nTaT1K0Jf1voCbhDbJ+SX5kZlZqGYU9r/x1eYBSM2Mw/h/kGKirSw== X-Received: by 2002:a05:622a:356:: with SMTP id r22mr22656437qtw.363.1623182366695; Tue, 08 Jun 2021 12:59:26 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:26 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 01/13] sunrpc: Create a sunrpc directory under /sys/kernel/ Date: Tue, 8 Jun 2021 15:59:10 -0400 Message-Id: <20210608195922.88655-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 Tue Jun 8 19:59:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7AE2C47082 for ; Tue, 8 Jun 2021 19:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CED86024A for ; Tue, 8 Jun 2021 19:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234498AbhFHUBk (ORCPT ); Tue, 8 Jun 2021 16:01:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbhFHUBk (ORCPT ); Tue, 8 Jun 2021 16:01:40 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43A75C061789 for ; Tue, 8 Jun 2021 12:59:30 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id l7so16264397qtk.5 for ; Tue, 08 Jun 2021 12:59:30 -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=ujEDos81NUbHnHXtpykY5JrCoGurJBkkkPFV1HlWdwc=; b=nOgpzEGh6U3+xuM89PoENzYnpNXGq2wJEbAv5Ylk1xFaVGhZBn4mblhoQL2lFgN4n9 XOfQckW766jcwEbfJuZIQr5RkUHDMxoMb1DalmuJZD8fi9V5VRfs9a9JXgqX4JU3T+o+ stjX4uLWRXaZDhwS1Yc9WCzSj5uJRG4HxaeCHR/6JCa36aOg+UiCkwB3tpMmRhQThNZg fnXCOCfe44+zmxrEysHucl8Jwp6Fdx7n1qErpx57frrI1HwqvsI24yrQpw/lHis2K5Tn AQ4MSsEBVOr6NyX0IvKlhanwPbZ/mN/EDthDHJMYZdSVBZeHlTJUapbhBNF2HuZ4sCT0 AMvA== 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=ujEDos81NUbHnHXtpykY5JrCoGurJBkkkPFV1HlWdwc=; b=bRRy6ybLHAxp5/Z+YEwlG7bzRKiKjiw4jJ+18wxOAwEaotJ/EWN0161JKvHVegcMmm +woWAu2Q1wJRt6WLl4Jv/sPRUn81IVQe057WON+Vtzl2qD10JyHcqIn+CzuY8yLRlR1T h0ZhjFVgpw4H+fcolFn+i+UOYRgViMSKEUkKhAnyVkXRbCKBl5voxj4JVSUfqgrZyErC DaDoEjTnKo2UTG877QP90wTmE+xps03yA5mOyVi6/PRIakVjqYtC7bffneZLYVccexOd Zg++qgM4Wnb+tpNIKIJk9TyrK8FzYNQHAevGw3PEZnCH+fxJxUxONB8WeFH6EtlGj/uZ rniA== X-Gm-Message-State: AOAM532DuaeCS0KBxOGM/de3jnc3dj7ShZTRp3lyIAT6qgF7O+q0C7P5 kO/delE1/7IaKDC16mOTlc8= X-Google-Smtp-Source: ABdhPJwXQgYxhf86Mv+60OW0LZKKNL5lMLj6QQZ5QP0IGEHVaO9cKMo7WJX4E6du8fg9l3NJFexulA== X-Received: by 2002:ac8:12c6:: with SMTP id b6mr22824258qtj.352.1623182369461; Tue, 08 Jun 2021 12:59:29 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:27 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 02/13] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Date: Tue, 8 Jun 2021 15:59:11 -0400 Message-Id: <20210608195922.88655-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 27eda180ac5e..fa03e2ef836a 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -2,19 +2,62 @@ /* * 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 Tue Jun 8 19:59:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBD2AC4743D for ; Tue, 8 Jun 2021 20:00:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D08176024A for ; Tue, 8 Jun 2021 20:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbhFHUCi (ORCPT ); Tue, 8 Jun 2021 16:02:38 -0400 Received: from mail-qt1-f170.google.com ([209.85.160.170]:34646 "EHLO mail-qt1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234216AbhFHUCf (ORCPT ); Tue, 8 Jun 2021 16:02:35 -0400 Received: by mail-qt1-f170.google.com with SMTP id u20so7996480qtx.1 for ; Tue, 08 Jun 2021 13:00:31 -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=Xh8YD1h4jEJTMPL/eZU+PJKfx8xJoHmKgCA8iRzN8/k=; b=npCErfHeF3JWFBlsgL2e60IuYjU/5DuNMCfxi7tZ8n3U7T/9Z0HEbJmFs3OkcIVWGA Dq24Gdc+jNVutjJ8mobcab2EvUrIToyMNZi1TjYRGZoW7gYjJM6Ae251+genqJrOCK4/ HPHyi2Yp0gnxGN4ZxMMzKWW35mUGxe2JYfm0cRmtbHogTEzJEQV2LYBqIICkEHn/02OW jl+WuETVYUexthyHQ8UGZC5bdf/85+TYsZJf5ydA42ryJkOe/S4ZndhxKhFu1E2sj/Dg bFMhQbUWHyLR3WDmEM0IcmqIRA46Dhw2C5CaPttpiUa4eZ2v2l6fX5/h1JPV+R14J29h GAIw== 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=Xh8YD1h4jEJTMPL/eZU+PJKfx8xJoHmKgCA8iRzN8/k=; b=HYk2YEmtfjZWXLsH8+BaTuiQN610wJXzl7JDGXTvPXnIX53Uja8bwoxRjLKzgoHUTF gYlju0Ucb6Mf6gRtPHhX1rGY4WUxortQPpaa31REnIa+ERb4qIsmhDIAYO4FF2m8CveW MqtGxpZJgzFwyudpXaMvc6ZwSjFYbOTTBaetDn6kpq6mLzoTIlhcyf0HRwe9N+/CWGfW y9Lovfxz9alQLKW5neQwfWzHD1TF98asxfDHTTPYBFdwKSn7SjnKHg+TzMdF9LxP3X3w QNLBK5B7fJyQU1hei+tPh0LUDfj6e1QGlkHOyWQ2M7QCRz0LhXv+x43/QbdYYS3PeuoO ezOw== X-Gm-Message-State: AOAM531YgIiT2uBOMFZjxvFgLWW644odGCqGWFvpkBRwILd6Z2rbGvRU PJBNOe76jhM7lOAVVICbQHKnhv84Pqk= X-Google-Smtp-Source: ABdhPJzhqS7x3C4OhSc7Kh/42qasqb6IRdMcONMlwgUuchn9ykUQT75MJCkWHFo7iq0+y9SYp4N2og== X-Received: by 2002:a05:622a:4a:: with SMTP id y10mr5771219qtw.294.1623182370614; Tue, 08 Jun 2021 12:59:30 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:30 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 03/13] sunrpc: Create per-rpc_clnt sysfs kobjects Date: Tue, 8 Jun 2021 15:59:12 -0400 Message-Id: <20210608195922.88655-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 2 ++ net/sunrpc/clnt.c | 5 +++ net/sunrpc/sysfs.c | 61 +++++++++++++++++++++++++++++++++++++ net/sunrpc/sysfs.h | 8 +++++ 4 files changed, 76 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 02e7a5863d28..8b5d5c97553e 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -29,6 +29,7 @@ #include struct rpc_inode; +struct rpc_sysfs_client; /* * The high-level client handle @@ -71,6 +72,7 @@ struct rpc_clnt { #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) struct dentry *cl_debugfs; /* debugfs directory */ #endif + struct rpc_sysfs_client *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 42623d6b8f0e..6f3f840a2ea3 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 fa03e2ef836a..f3b7547ee218 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; @@ -56,8 +57,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 Tue Jun 8 19:59:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB251C47082 for ; Tue, 8 Jun 2021 19:59:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86BE461375 for ; Tue, 8 Jun 2021 19:59:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbhFHUB0 (ORCPT ); Tue, 8 Jun 2021 16:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234309AbhFHUB0 (ORCPT ); Tue, 8 Jun 2021 16:01:26 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A4D0C061574 for ; Tue, 8 Jun 2021 12:59:32 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id d196so16338052qkg.12 for ; Tue, 08 Jun 2021 12:59:32 -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=9LDwEwPQbhwjs1lrw0RcLVlG/gcKNLc/Zyhh3epgGAM=; b=mvY/PMb3Zjny6Bm1fZP8CJRsQ9lAazaeOTnyJbMpMvxNWb2EtT47OHCsj0qA7T/B37 ZfRloPejFYpK54Fxf/0hhggkyssCT8Su9ZCaGimVO8IX2H2/Vlegs+04wgcIUF5v++h0 lUR/ssQw510fz2ns/b/KnIYDv0ccQrKazaJxytDFZ1O2Po23McWbD3nULWhZM3EmDuNl Rgz78SyKoso4dFbIaZhcZOZjQ/dSE4LdpJsf1ZV3qhjbYtTzLTbM86yIlMwu9Z/9fpBI 5L1gXS/8m8CgAXUUVDlwU3HjiGUKNrd52zz5u4Y/9RTARDE/DJJQ8gDygdwFh4F089OF /HXA== 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=9LDwEwPQbhwjs1lrw0RcLVlG/gcKNLc/Zyhh3epgGAM=; b=KLYZf7oAJDb/rHNSJbYamKRiVHeXRpfumU5WaBieVLArjoQeWF7REXQ9FhaRsuT6Gr IBtnWvw8KmjGh0hsyVXHFXKLL/TLbdcXXJ7WImcW3Fcm/hhRizrG1ML2xiBSqopHdWKO 4+Lmf/kqdJu+4wuo2oszp7b8FRJI8HyziWocskdOVyf8L4/ZAl2aNktsasxMmlWxUlkY fFcWCFIbyX8bulLKvzpTxNx49opeFeB8kx/O1xfB5gI154A66dukNQK0DMlo/5h1LmtQ WlQHelcy5ewIPVrMl30n082Kc1/Q3N13qVTwlLeiub2YpX4JEeZ4sIg/h7eWnLDerQY4 lZUg== X-Gm-Message-State: AOAM531LmvLikt1SySPOhCWm5lisvMKEnMQKycqQrD2xGHoHeEdpz6a4 x9EO1e63hRG+2F2EgfY0ZOE= X-Google-Smtp-Source: ABdhPJzUETEttIRWw/XF4hvv/FhtvrY5cNS5ja3JJbq7Av5hqwRc8mwBy0YpoWXgkaITd8lEX+V3VQ== X-Received: by 2002:a05:620a:290b:: with SMTP id m11mr15765475qkp.455.1623182371832; Tue, 08 Jun 2021 12:59:31 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:31 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 04/13] sunrpc: add xprt id Date: Tue, 8 Jun 2021 15:59:13 -0400 Message-Id: <20210608195922.88655-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 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 61b622e334ee..1fbc470ce205 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 */ @@ -370,6 +371,7 @@ struct rpc_xprt * xprt_alloc(struct net *net, size_t size, void xprt_free(struct rpc_xprt *); void xprt_add_backlog(struct rpc_xprt *xprt, struct rpc_task *task); bool xprt_wake_up_backlog(struct rpc_xprt *xprt, struct rpc_rqst *req); +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 3509a7f139b9..20b9bd705014 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1746,6 +1746,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) @@ -1758,6 +1782,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++) { @@ -1786,6 +1811,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 Tue Jun 8 19:59:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB546C47082 for ; Tue, 8 Jun 2021 20:00:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B70066024A for ; Tue, 8 Jun 2021 20:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234553AbhFHUCk (ORCPT ); Tue, 8 Jun 2021 16:02:40 -0400 Received: from mail-qt1-f172.google.com ([209.85.160.172]:40590 "EHLO mail-qt1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234494AbhFHUCh (ORCPT ); Tue, 8 Jun 2021 16:02:37 -0400 Received: by mail-qt1-f172.google.com with SMTP id t9so9773205qtw.7 for ; Tue, 08 Jun 2021 13:00:33 -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=pwZjDtLSm9GkvizQzX+4ZFhuzEFRjTZGQEHv/Spe/yxwEA3y5Gkxzp81V7G+xAlOxk Pn0yv6IdUBzXcxCbDjIMKxak7GNgkGBludBICqTyGeWBMJBPaQPWapBeto01CnnXncOb 7BX5eat5uRClWjtnHI2mML0JfCgMoJYUvasuy19iyov8PBshm5R/p3qhYw5YY1Eu23sE IQbmHUGXpVNw+GsKePuWVcuhrPj9KFjFICD7uPBhxc0MVkJXjrnuKomBZHBPZ6oxx+MD 8fYXVxkhZZiPsq+l+mpatzkXtowslJSx1uHoQxQ5YVeCxdh7f3FYdCVHmwhXnn9/sb/e 9tVg== 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=IiYe4YXwKqpqYBL4ee34o+pvUIEgjdABWmHnjkZTggYcxUshgLtcaxVYFuGlfDR7Q2 riyX4P3PlfLrAmMp6h+vr49K+Khab9MnDY9TqC00PIjBOWXs4sl55q9ZJL60776AYrWW 7iiDhq85BfxRhtnEekHa+iXreTX2gTwEW8Pg+BC3+ejlYWd0e93bpnpuDyfCKYn0FKqp AY7SsPUbHMF7QB5TunTvdnXIJ9ArmPFt9b6GUVHyn/TScg0+1qNRUu7MbkooyUxu2QmJ KgAJOBltsEULpoiKkb//cMI4dmc4EilAPbabIBrj5H8MiUajsrmnFeV4FBHw05TXirgR 00hA== X-Gm-Message-State: AOAM533m0P5xmP50tiIPucmD3ZZ5NyuF3e5KpizgehzvWwcBhnwDgCJH 9nhsKIR3lTu5MmaJz9fDefE= X-Google-Smtp-Source: ABdhPJxGxtVn6BmafLWJDS9qketg5KBUpwfj+cbXWXghwkGiaHkyQyF2po7Qi7c5lWLgEPOam/XNHg== X-Received: by 2002:aed:30c1:: with SMTP id 59mr22552695qtf.16.1623182372938; Tue, 08 Jun 2021 12:59:32 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:32 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 05/13] sunrpc: add IDs to multipath Date: Tue, 8 Jun 2021 15:59:14 -0400 Message-Id: <20210608195922.88655-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 Tue Jun 8 19:59:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D6CFC47082 for ; Tue, 8 Jun 2021 20:00:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 836726024A for ; Tue, 8 Jun 2021 20:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234380AbhFHUC3 (ORCPT ); Tue, 8 Jun 2021 16:02:29 -0400 Received: from mail-qv1-f47.google.com ([209.85.219.47]:45031 "EHLO mail-qv1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbhFHUC1 (ORCPT ); Tue, 8 Jun 2021 16:02:27 -0400 Received: by mail-qv1-f47.google.com with SMTP id w4so4080685qvr.11 for ; Tue, 08 Jun 2021 13:00:34 -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=1eLaAiQvGuNoMxbAdj78LO7Lm9Pb6c7fvLRSowTJkC0=; b=Lsf2d11SjiVFkj6bM2AM7AFqC6TXaLA9DrdTmUw3tX+sA+nlLpw1b1jGIeA7iPS5Qh s1fSXuy6gs/Ji8l8EhyZTKE7Wyepunea5GvPfsmxnHMG+y3P2U90mJ59x7Qg+hUx/Sw2 0VImQD5y9HbxGyOblZachsi9E688FJz2V+k5XvFLodJRQECTy5YPEcCQFybzkO/bZWDZ j5/q+YQLw0U3BhUmlLVGGeeqdEQ08bzve9INGA/Gb3bB/TsSxTksbTRroda2tEW12r6S 8gyTelH1poZFHK1Bb/Y3QTGm4VY2mzbmR5dubcSm6g+lZYfEK0aKaFbaitSI+Per47JK +qFw== 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=1eLaAiQvGuNoMxbAdj78LO7Lm9Pb6c7fvLRSowTJkC0=; b=aSmYbu6rHaiOxbzx6dM4qfDqN2+NNm/jyCY2eWzZvXPzq8Er4vLpcyhLJd0bKIfoWg dqbJLB17WLLOmwAUgv98uFtbRG/CtxXeFHeR0N7n6pJQ6xPeXSKvzioiSNPKPSZSGuZJ P0KoDPCpl1itwT5ncv9M8IMn+g8fUJqarlZoqpzJtdvIZEasXfZhYlGV4326agsPljLw ES1heNBYRSI0ueq/ingVFIccok1oW9U8Ar29NIQjp2Fu5uXIHcXSeiypwsGooNPKBMX8 7Gka6KNHMENWadP66e6HooEAdgc5zc09k57CGEy6sjPaz5RlQ6CmRFCgXHST/a9Tqqef JWlg== X-Gm-Message-State: AOAM533geDkMKcINUsePbuQe8Jr636u6QELcHOX5tNFazVtPCtasSBwE 4jdleMRCKfnhTr0yl6/VDX7AIQZkrD0= X-Google-Smtp-Source: ABdhPJw+Dj0I4iH9pHHN98jnXUreo8If+bJPK378HqCs1dP2YZp9nE3qylCl24efgRzhs6aP8q9Tgw== X-Received: by 2002:ad4:45a6:: with SMTP id y6mr1668163qvu.54.1623182374027; Tue, 08 Jun 2021 12:59:34 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:33 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 06/13] sunrpc: keep track of the xprt_class in rpc_xprt structure Date: Tue, 8 Jun 2021 15:59:15 -0400 Message-Id: <20210608195922.88655-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 1fbc470ce205..7efc6c0a5455 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 19a49d26b1e4..9c2ffc67c0fd 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 316d04945587..2ad4d0df45fe 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 @@ -2779,6 +2784,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; @@ -2848,6 +2854,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); @@ -2928,6 +2935,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; @@ -3001,6 +3009,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 Tue Jun 8 19:59:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9696AC48BCD for ; Tue, 8 Jun 2021 20:00:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FED26024A for ; Tue, 8 Jun 2021 20:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234530AbhFHUCk (ORCPT ); Tue, 8 Jun 2021 16:02:40 -0400 Received: from mail-qk1-f177.google.com ([209.85.222.177]:33688 "EHLO mail-qk1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234216AbhFHUCk (ORCPT ); Tue, 8 Jun 2021 16:02:40 -0400 Received: by mail-qk1-f177.google.com with SMTP id k4so21530531qkd.0 for ; Tue, 08 Jun 2021 13:00:35 -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=wGOpSsX0RI8U/ko+9V6YHdVM++uPnR7REoldeJWyPrQ=; b=tp9P3Wy1M0zIdRYglndtqqzJes/70FCxhtztDW29bPbRxsIPoPxW79E7s//qBSZKDn 85jtV10N71/T2z3eIj/OzwVXw6mAogztkTiBKmsvI1RjmNJ1JGkh9HlTICyG2gv9xHuC 8qnv9O4wwYadBe6IwdZKz8XY0QMy1sstjUSZUUt+7rNykuJWihwSck1w3/97EnBAOKQR X4S3Qmjo/s9Y8Lvw1X2WFHVtgdQYw5VzK48eiz1QT8tLY2nAnY6Tcptp/ErfvOU2iLpP k2jHsc/HwA9tLFsEpz3c5U/USgqAS3ThiHZodMfx+r6QAJbtHGXvyOR3ziYwUlNGsyRl OrzA== 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=wGOpSsX0RI8U/ko+9V6YHdVM++uPnR7REoldeJWyPrQ=; b=NRlbFUBnypSjrnmhAauBAvY7xuHn/H9/XkGo7LlaAyuW2pDe93ipRBM1jS5lPFf++m rRfGcPzsd2hPPV7irrbcrRez3Sqjv1lok3/kzbAFi+Us4mZHG31lBph7dz0ac2FdEo/p kyPOIooqjPSbElpbZtGSp2W1gYc8GQjvgNF4JHh74CEKNXswv7xp1TRhgNmDCFySOeqC r5bLElACz9ROQW2KegxAoY/a5vD5078HTP+ZkYtR3uBoHmtWpR078gazBQ/UUIy3BkCf 2GDYTV+/BbyElSKHkLvUZqpTdCW9Ncc+Vnweaw/wPrxF6UoeMkyBvIT0tt44yMxAHIHy zMUw== X-Gm-Message-State: AOAM531S00qjwWMcMHtJbowivcXD7Iv4EwOQ0MCXQuNx/JCYDOUyvYct nh3b8e2RJL0dCdBAvyJJglb9eE4w16A= X-Google-Smtp-Source: ABdhPJw3PKKg7tcLM52N3QkUDjpBblQ851WtLILv+0jeA4BZ+pzA1lkXTIE96n9AHLu6X5YrqV5CTQ== X-Received: by 2002:a37:5b46:: with SMTP id p67mr22350769qkb.358.1623182375137; Tue, 08 Jun 2021 12:59:35 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:34 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 07/13] sunrpc: add xprt_switch direcotry to sunrpc's sysfs Date: Tue, 8 Jun 2021 15:59:16 -0400 Message-Id: <20210608195922.88655-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 2 + net/sunrpc/sysfs.c | 99 ++++++++++++++++++++++++++-- net/sunrpc/sysfs.h | 10 +++ net/sunrpc/xprtmultipath.c | 4 ++ 4 files changed, 108 insertions(+), 7 deletions(-) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index ef95a6f18ccf..b19addc8b715 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -10,6 +10,7 @@ #define _NET_SUNRPC_XPRTMULTIPATH_H struct rpc_xprt_iter_ops; +struct rpc_sysfs_xprt_switch; struct rpc_xprt_switch { spinlock_t xps_lock; struct kref xps_kref; @@ -24,6 +25,7 @@ struct rpc_xprt_switch { const struct rpc_xprt_iter_ops *xps_iter_ops; + struct rpc_sysfs_xprt_switch *xps_sysfs; struct rcu_head xps_rcu; }; diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index f3b7547ee218..ed9f7131543f 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) { @@ -48,13 +48,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) @@ -65,20 +74,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); } @@ -100,6 +129,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; @@ -111,6 +162,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; @@ -122,3 +195,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 Tue Jun 8 19:59:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25A88C4743F for ; Tue, 8 Jun 2021 20:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08AE96024A for ; Tue, 8 Jun 2021 20:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234078AbhFHUCb (ORCPT ); Tue, 8 Jun 2021 16:02:31 -0400 Received: from mail-qk1-f181.google.com ([209.85.222.181]:33695 "EHLO mail-qk1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbhFHUCa (ORCPT ); Tue, 8 Jun 2021 16:02:30 -0400 Received: by mail-qk1-f181.google.com with SMTP id k4so21530613qkd.0 for ; Tue, 08 Jun 2021 13:00:36 -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=94soqXL6YeuBIGDbnyeIBNAXPOYxIGr0JRdKAVfQ/L8=; b=i62AFISOAOTzU2tXaztfcfkxRKVl+nq3jH8+pF4iXYqIq3kGYvQfXIt1YxzwUrHR50 dPdYp9urqkJapYVChJ6VlGUvtPciCRx9C9a5ZtQd+K0pqaymt7+u6ULgNbFMIGOHMJpO PXIczCLn/mU1cELdlAD7EWd5eN4eoeIhPwrq34vufiiNG7CYD9+UOT4KWpvRQ+YIxSoo ZG852jnesKG0ruB0xrWbB51ol47ZwHFKtfspAIRgQUAVfLFP/oB7IFQjhuv1evi1P5Cf N2hY1E7uw6YdCcxFqFFAElQJ9C96w4FXgTRq2+H8gmGG6LljmFwzPzVXEW+Y3bg5NuPN xLxQ== 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=94soqXL6YeuBIGDbnyeIBNAXPOYxIGr0JRdKAVfQ/L8=; b=dtBk1hwNNwxxhS2AhP+ocMAx80JSxuVpXzO15zvEZypjvzdl6HHm3EUnZXf07rkCbO yVVgFC+INfqc25izOt7wmxJRhM7SLZZ4c4pKfNUtP032xrWLauOqg7O0XA111Z4V4DBz lEVYAYo+h8R4EZMlb/uSbOe94UqN++6CC+I2q7ly877eSOA0GAll+FAc1PKeh7C46nOV 3BMSpNyycDP/c0nDvY0yQybLhRgzkqGhhaRXFbusD8BbBbKnzXagZ8sub9GhBlKJCDV2 pC0T7S1deRTrOVflb8R/LnQUraCoXVL4N8davrNj6ibBgEFY9Bf04TRcO+jQ6oSisxMl +YNQ== X-Gm-Message-State: AOAM5317XqibkGiryeHYSmHcdXILhVwXJVDAzSKypDU/rogwSpBsRzoH qdP9k72ky6HbzkIM/4e5z38Dm5qERow= X-Google-Smtp-Source: ABdhPJxC+HYA2RfP+twxn5AXPzJTtq5copJJkIB4CreAnAjAvKvGtK68tXEzgVjbdrZ15CX3AcSPhg== X-Received: by 2002:a37:a548:: with SMTP id o69mr17517430qke.376.1623182376345; Tue, 08 Jun 2021 12:59:36 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:35 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 08/13] sunrpc: add a symlink from rpc-client directory to the xprt_switch Date: Tue, 8 Jun 2021 15:59:17 -0400 Message-Id: <20210608195922.88655-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 22 ++++++++++++++++++++-- net/sunrpc/sysfs.h | 6 +++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 6f3f840a2ea3..9bf820bad84c 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 ed9f7131543f..0aa63747f496 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -151,14 +151,29 @@ 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[] = "switch"; + 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); + 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); } } @@ -189,6 +204,9 @@ void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; if (rpc_client) { + char name[] = "switch"; + + 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 Tue Jun 8 19:59:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90763C4743D for ; Tue, 8 Jun 2021 20:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F91C61375 for ; Tue, 8 Jun 2021 20:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234264AbhFHUCb (ORCPT ); Tue, 8 Jun 2021 16:02:31 -0400 Received: from mail-qk1-f171.google.com ([209.85.222.171]:38633 "EHLO mail-qk1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234511AbhFHUCb (ORCPT ); Tue, 8 Jun 2021 16:02:31 -0400 Received: by mail-qk1-f171.google.com with SMTP id c138so8599332qkg.5 for ; Tue, 08 Jun 2021 13:00:37 -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=QdMdH1UktKMge22xTBEvqaZAkiiiSExhGbNUVUAcoMg=; b=TOvYgZZaQWRfSOR9WXX7WRhr46GBsWjZ1nEwjRlxS1iL6ZBE1SwP/yd6u1jQ/3SPRh rGU8pSxqEgTARFvkG4zTyNXtdU6zp4uJcRX33yOM02RUu3EFg/k7GlEvli8Jq8HWXE+D JUrhzPQOR/wTPrYQWc2bHCuVX5o02d1JEGwYznScTzv6EM66gdf/BFqdpAmhh3ZjEKdw TyET21Yp78sfapD0AwgxJPxx+FDMoWY7l5J8bbLNe47Do0DNgPJvLCBJgBhCSIza6n7x J/EV3Kk1gyHLmY+d6ttKLbizXQsHIhWvQzeQcq5Uz8ZJyIQU8nHsNhqJ6xahinDm26tI rGMg== 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=QdMdH1UktKMge22xTBEvqaZAkiiiSExhGbNUVUAcoMg=; b=GzlEM53I2h8kH3qftvbVyy8VjG3Xx3B1E+4e3Wb5qcW3M4ZLq0qpBkMnZjU1StaEVF tMkM9olc8EpAe3dpkPSK2cGgZyHgGPCYQ0B5kDvNRpDAfZywD1fT4vIKzuTubP5Dspjp /ZPp4x4hbkwreSX2yVe6RGDbeoj8XpAwWJJinM66NhLYUzGAvkCK296LQ0wBCWXEpbkv JsUKjMWs6cly1K1QorMJrqLgYtLP1GB0ueIlMvb94EWSM9nB2nY51QNbJJ8keUHzV6BJ ipKWX2CTstRGFMzpocof+6iVJe20FVmNujMG+fjlSCO+HNhUOLy2WzcKaXfkMIhk8uF9 PPRA== X-Gm-Message-State: AOAM530qkvCK+3z5v2wlXMXYIegk97piYFsKWnIygBXqDWA3DfJXzKpZ XTsca+I89Cncxy8argZqetw= X-Google-Smtp-Source: ABdhPJyWQApqArL9Ucvb9/P75M0WVfBZTJLimBzzQrGr7YIdwxvAYOldHPGERB0yoqLNX1LsdebUGA== X-Received: by 2002:a05:620a:4090:: with SMTP id f16mr23473188qko.225.1623182377527; Tue, 08 Jun 2021 12:59:37 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:37 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 09/13] sunrpc: add add sysfs directory per xprt under each xprt_switch Date: Tue, 8 Jun 2021 15:59:18 -0400 Message-Id: <20210608195922.88655-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 2 ++ net/sunrpc/sysfs.c | 67 +++++++++++++++++++++++++++++++++++++ net/sunrpc/sysfs.h | 8 +++++ net/sunrpc/xprtmultipath.c | 4 +++ 4 files changed, 81 insertions(+) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 7efc6c0a5455..8360db664e5f 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -183,6 +183,7 @@ enum xprt_transports { XPRT_TRANSPORT_LOCAL = 257, }; +struct rpc_sysfs_xprt; struct rpc_xprt { struct kref kref; /* Reference count */ const struct rpc_xprt_ops *ops; /* transport methods */ @@ -291,6 +292,7 @@ struct rpc_xprt { #endif struct rcu_head rcu; const struct xprt_class *xprt_class; + struct rpc_sysfs_xprt *xprt_sysfs; }; #if defined(CONFIG_SUNRPC_BACKCHANNEL) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 0aa63747f496..20f75708594f 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -82,6 +82,14 @@ static void rpc_sysfs_xprt_switch_release(struct kobject *kobj) kfree(xprt_switch); } +static void rpc_sysfs_xprt_release(struct kobject *kobj) +{ + struct rpc_sysfs_xprt *xprt; + + xprt = container_of(kobj, struct rpc_sysfs_xprt, kobject); + kfree(xprt); +} + static const void *rpc_sysfs_client_namespace(struct kobject *kobj) { return container_of(kobj, struct rpc_sysfs_client, kobject)->net; @@ -92,6 +100,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_namespace(struct kobject *kobj) +{ + return container_of(kobj, struct rpc_sysfs_xprt, + kobject)->xprt->xprt_net; +} + static struct kobj_type rpc_sysfs_client_type = { .release = rpc_sysfs_client_release, .sysfs_ops = &kobj_sysfs_ops, @@ -104,6 +118,12 @@ static struct kobj_type rpc_sysfs_xprt_switch_type = { .namespace = rpc_sysfs_xprt_switch_namespace, }; +static struct kobj_type rpc_sysfs_xprt_type = { + .release = rpc_sysfs_xprt_release, + .sysfs_ops = &kobj_sysfs_ops, + .namespace = rpc_sysfs_xprt_namespace, +}; + void rpc_sysfs_exit(void) { kobject_put(rpc_sunrpc_client_kobj); @@ -151,6 +171,25 @@ rpc_sysfs_xprt_switch_alloc(struct kobject *parent, return NULL; } +static struct rpc_sysfs_xprt *rpc_sysfs_xprt_alloc(struct kobject *parent, + struct rpc_xprt *xprt, + gfp_t gfp_flags) +{ + struct rpc_sysfs_xprt *p; + + p = kzalloc(sizeof(*p), gfp_flags); + if (!p) + goto out; + p->kobject.kset = rpc_sunrpc_kset; + if (kobject_init_and_add(&p->kobject, &rpc_sysfs_xprt_type, + parent, "xprt-%d-%s", xprt->id, + xprt->address_strings[RPC_DISPLAY_PROTO]) == 0) + return p; + kobject_put(&p->kobject); +out: + return NULL; +} + void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct rpc_xprt_switch *xprt_switch, struct net *net) @@ -199,6 +238,22 @@ void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, } } +void rpc_sysfs_xprt_setup(struct rpc_xprt_switch *xprt_switch, + struct rpc_xprt *xprt, + gfp_t gfp_flags) +{ + struct rpc_sysfs_xprt *rpc_xprt; + struct rpc_sysfs_xprt_switch *switch_obj = + (struct rpc_sysfs_xprt_switch *)xprt_switch->xps_sysfs; + + rpc_xprt = rpc_sysfs_xprt_alloc(&switch_obj->kobject, xprt, gfp_flags); + if (rpc_xprt) { + xprt->xprt_sysfs = rpc_xprt; + rpc_xprt->xprt = xprt; + kobject_uevent(&rpc_xprt->kobject, KOBJ_ADD); + } +} + void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) { struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; @@ -225,3 +280,15 @@ void rpc_sysfs_xprt_switch_destroy(struct rpc_xprt_switch *xprt_switch) xprt_switch->xps_sysfs = NULL; } } + +void rpc_sysfs_xprt_destroy(struct rpc_xprt *xprt) +{ + struct rpc_sysfs_xprt *rpc_xprt = xprt->xprt_sysfs; + + if (rpc_xprt) { + kobject_uevent(&rpc_xprt->kobject, KOBJ_REMOVE); + kobject_del(&rpc_xprt->kobject); + kobject_put(&rpc_xprt->kobject); + xprt->xprt_sysfs = NULL; + } +} diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index 760f0582aee5..ff10451de6fa 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -19,6 +19,11 @@ struct rpc_sysfs_xprt_switch { struct rpc_xprt *xprt; }; +struct rpc_sysfs_xprt { + struct kobject kobject; + struct rpc_xprt *xprt; +}; + int rpc_sysfs_init(void); void rpc_sysfs_exit(void); @@ -29,5 +34,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_setup(struct rpc_xprt_switch *xprt_switch, + struct rpc_xprt *xprt, gfp_t gfp_flags); +void rpc_sysfs_xprt_destroy(struct rpc_xprt *xprt); #endif diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 2d73a35df9ee..e7973c1ff70c 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -57,6 +57,7 @@ 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); + rpc_sysfs_xprt_setup(xps, xprt, GFP_KERNEL); } static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, @@ -85,6 +86,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_destroy(xprt); xprt_put(xprt); } @@ -137,6 +139,7 @@ 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); + rpc_sysfs_xprt_setup(xps, xprt, gfp_flags); } return xps; @@ -152,6 +155,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_destroy(xprt); xprt_put(xprt); spin_lock(&xps->xps_lock); } From patchwork Tue Jun 8 19:59:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9061CC47082 for ; Tue, 8 Jun 2021 19:59:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E7FC6024A for ; Tue, 8 Jun 2021 19:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233695AbhFHUBd (ORCPT ); Tue, 8 Jun 2021 16:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbhFHUBc (ORCPT ); Tue, 8 Jun 2021 16:01:32 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B216C061574 for ; Tue, 8 Jun 2021 12:59:39 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id k11so19848019qkk.1 for ; Tue, 08 Jun 2021 12:59:39 -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=M75J5gxIYaLCC3K7GTU61NltQHpX1UepCv+SiagOXio=; b=X/aZ5uVcuLG7++5Yt6o10Xb2AhBmduQO/0m6iDUZkzUAGt5lgmZtu7T8KK9ShYIIMz tTi1bh/D8OQGie1tKPoYcLBe4K6w1bNSUPDnxMOQAieO68rCLCYR8mlpiaxHX0uiuogx /XZNMklzajbdcwVypZ5tMh/3jY4L8K5q1MrAtZkP00gMx9c3k+uyeFUmmQAuB8GreWUN NqT9fURqmtSHAaGWiksI5bIghUewIWxnTq+9LMIl86tVwWrMKvSLwnjmwhUWMROQC8yz ZBwF63m1tNwne7fGQEgpKFe3XnGZ587SAQo717ck7CM3Z4ua7PrqSdznt3wDNPJfZZWv xtyw== 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=M75J5gxIYaLCC3K7GTU61NltQHpX1UepCv+SiagOXio=; b=o+83YlgC35Qcu04WzbDaSAenvTMezWLU/oJ8khSKY/eI+MeFEA81/GQC+jQcySN10W br0sqMF9u4MZFTlzRowe1q+rzmly0ctxfMoQdVJAZtyXfe4jsFF33CpFjAO8DDxpCCkt B6tlCGBXl0s81Ta0ipCBDZQ1AuVHFHe6XElQ7mYEUiJ/P0fNYQ/lrX5NJr2Q0Ntfp42A Nt3W/xtASgmxp/jLAIa4ut2Ut/NHazOkxsU9PXO6r9tFp14VQ7ZWdgOGIDr5LKaM+LsQ 7uF5PPmViBIy7KAzMAFbgj2Ld7wqDVBOyjTj1EyFBuZYSiVCIxiY8Yl7KPmLUIVFRvUj 0lzQ== X-Gm-Message-State: AOAM531tWUSoIAQ6ua3e/Ifz1HemZ/8TKC2m1iv6skIjvjQ+Hr0G1j6m J83RxEGa8oEnA7vh3RUuk/cjqI2qX9Q= X-Google-Smtp-Source: ABdhPJxd8YjUkUnY8EMnBM7LXJ1PGjNG6Iis7ewlj3oaEYIg3bIHhqADByxRIll8b2MprxmirhvEAw== X-Received: by 2002:a37:6c03:: with SMTP id h3mr23069361qkc.474.1623182378684; Tue, 08 Jun 2021 12:59:38 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:38 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 10/13] sunrpc: add dst_attr attributes to the sysfs xprt directory Date: Tue, 8 Jun 2021 15:59:19 -0400 Message-Id: <20210608195922.88655-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 --- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/sysfs.c | 105 ++++++++++++++++++++++++++++++++++++ net/sunrpc/xprt.c | 4 +- net/sunrpc/xprtmultipath.c | 2 - 4 files changed, 109 insertions(+), 3 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 8360db664e5f..13a4eaf385cf 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -414,6 +414,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie); bool xprt_lock_connect(struct rpc_xprt *, struct rpc_task *, void *); void xprt_unlock_connect(struct rpc_xprt *, void *); +void xprt_release_write(struct rpc_xprt *, struct rpc_task *); /* * Reserved bit positions in xprt->state diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 20f75708594f..402924bbd743 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -4,8 +4,23 @@ */ #include #include +#include + #include "sysfs.h" +struct xprt_addr { + const char *addr; + struct rcu_head rcu; +}; + +static void free_xprt_addr(struct rcu_head *head) +{ + struct xprt_addr *addr = container_of(head, struct xprt_addr, rcu); + + kfree(addr->addr); + kfree(addr); +} + static struct kset *rpc_sunrpc_kset; static struct kobject *rpc_sunrpc_client_kobj, *rpc_sunrpc_xprt_switch_kobj; @@ -43,6 +58,87 @@ 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 *x = container_of(kobj, + struct rpc_sysfs_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; + ret = sprintf(buf, "%s\n", xprt->address_strings[RPC_DISPLAY_ADDR]); + 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; + char *dst_addr; + int port; + struct xprt_addr *saved_addr; + size_t buf_len; + + if (!xprt) + return 0; + if (!(xprt->xprt_class->ident == XPRT_TRANSPORT_TCP || + xprt->xprt_class->ident == XPRT_TRANSPORT_RDMA)) { + xprt_put(xprt); + return -EOPNOTSUPP; + } + + if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) { + count = -EINTR; + goto out_put; + } + saddr = (struct sockaddr *)&xprt->addr; + port = rpc_get_port(saddr); + + /* buf_len is the len until the first occurence of either + * '\n' or '\0' + */ + buf_len = strcspn(buf, "\n"); + + dst_addr = kstrndup(buf, buf_len, GFP_KERNEL); + if (!dst_addr) + goto out_err; + saved_addr = kzalloc(sizeof(*saved_addr), GFP_KERNEL); + if (!saved_addr) + goto out_err_free; + saved_addr->addr = + rcu_dereference_raw(xprt->address_strings[RPC_DISPLAY_ADDR]); + rcu_assign_pointer(xprt->address_strings[RPC_DISPLAY_ADDR], dst_addr); + call_rcu(&saved_addr->rcu, free_xprt_addr); + xprt->addrlen = rpc_pton(xprt->xprt_net, buf, buf_len, saddr, + sizeof(*saddr)); + rpc_set_port(saddr, port); + + xprt_force_disconnect(xprt); +out: + xprt_release_write(xprt, NULL); +out_put: + xprt_put(xprt); + return count; +out_err_free: + kfree(dst_addr); +out_err: + count = -ENOMEM; + goto out; +} + int rpc_sysfs_init(void) { rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); @@ -106,6 +202,14 @@ static const void *rpc_sysfs_xprt_namespace(struct kobject *kobj) kobject)->xprt->xprt_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, @@ -120,6 +224,7 @@ static struct kobj_type rpc_sysfs_xprt_switch_type = { static struct kobj_type rpc_sysfs_xprt_type = { .release = rpc_sysfs_xprt_release, + .default_attrs = rpc_sysfs_xprt_attrs, .sysfs_ops = &kobj_sysfs_ops, .namespace = rpc_sysfs_xprt_namespace, }; diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 20b9bd705014..fb6db09725c7 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -55,6 +55,7 @@ #include #include "sunrpc.h" +#include "sysfs.h" /* * Local variables @@ -443,7 +444,7 @@ void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task) } EXPORT_SYMBOL_GPL(xprt_release_xprt_cong); -static inline void xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task) +void xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task) { if (xprt->snd_task != task) return; @@ -1812,6 +1813,7 @@ void xprt_free(struct rpc_xprt *xprt) put_net(xprt->xprt_net); xprt_free_all_slots(xprt); xprt_free_id(xprt); + rpc_sysfs_xprt_destroy(xprt); kfree_rcu(xprt, rcu); } EXPORT_SYMBOL_GPL(xprt_free); diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index e7973c1ff70c..07e76ae1028a 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -86,7 +86,6 @@ 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_destroy(xprt); xprt_put(xprt); } @@ -155,7 +154,6 @@ 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_destroy(xprt); xprt_put(xprt); spin_lock(&xps->xps_lock); } From patchwork Tue Jun 8 19:59:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBCA6C4743F for ; Tue, 8 Jun 2021 19:59:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B282461375 for ; Tue, 8 Jun 2021 19:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234071AbhFHUBe (ORCPT ); Tue, 8 Jun 2021 16:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbhFHUBd (ORCPT ); Tue, 8 Jun 2021 16:01:33 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F7AC061574 for ; Tue, 8 Jun 2021 12:59:40 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id z4so13223657qts.4 for ; Tue, 08 Jun 2021 12:59:40 -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=ijSZ1d7ATjjrKIOSInSDm6o0/HsEQun9JpMaNABtse0=; b=OcpJc+mFqeZDfS17LVKJNmMXVFKuMKD9vm031uUDAGEU1+ZmMmbwtWGSWWCEnHPbno DRpgFtOUCawpgEVsUyVHAYb0PgQ81CA1Nc0Not0SPiYL9QzUM5z7KHAbc0SiGlgilJeA xsyjIJF8XgLYoNrMb6pQCDf4HNAz9MSth92xAy82VSem5n2K8YWOeA/ARjotyf0di0lG vCyZSIg54+Me+PZXKNbwD9tK7znb+rRMepirWnyYIm8iLCwz7jE/18KA0iiEXjV61zZA Qm1aZXpE+17Mx37QJvqJB1I3F/bI5nvNVx8EB3pDL3qaiyw/Nyta92WIKA9Kpl4RlPqd LXog== 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=ijSZ1d7ATjjrKIOSInSDm6o0/HsEQun9JpMaNABtse0=; b=La7OuigHGww//ZXkob+Hl9T5LLf7IicBw404cggFpfJbadZ83GsbsnVjogbvy6Oyol CzHjw6h3eKAIhpfZ1E/L2IZmJ4THZ5BFzcQ0e5/VzWxQRHEbiUi4cwQVVw3Wm0Q2OzpT dGm45M61Cw/jvdgzbvuqcgK4Og/SGbWZafGWfIPEqiJymIoDaQrl7n/hBErekKt7rPgt yUgAZk9qMBgaaQAXnJGPg4bxmq1jhsyE2XEfg61xF3Y1DXO6Y3dhqM2WJRo2wv1RJsTq LJVLGkF6BmanxM4Q+pq3ezixt+yWOykR2EYhXYRc049Ta/0YqAnLGWb+1Bn9cAGKYp0a UwJg== X-Gm-Message-State: AOAM533UYniRU5lPR9m9MGbDhdL8pn48WpFyajGo6Ypq4KF5msOAwJQm r2MS7QOtOR23JhKkfsUXWKVR4At+q40= X-Google-Smtp-Source: ABdhPJx3vY+tzsd+1mgA6VlOB9fwQXB6OQ3zjmeTN0ptw36yUj4BLhWDPuyXsAs5VpwKSmHnd8ThMg== X-Received: by 2002:a05:622a:1046:: with SMTP id f6mr5721084qte.237.1623182379870; Tue, 08 Jun 2021 12:59:39 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:39 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 11/13] sunrpc: provide transport info in the sysfs directory Date: Tue, 8 Jun 2021 15:59:20 -0400 Message-Id: <20210608195922.88655-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 402924bbd743..f770eb7301b5 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -81,6 +81,27 @@ 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; + + if (!xprt) + return 0; + + ret = sprintf(buf, "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\n", 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); + 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) @@ -205,8 +226,12 @@ static const void *rpc_sysfs_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 Tue Jun 8 19:59:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1319C4743D for ; Tue, 8 Jun 2021 19:59:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF4E76024A for ; Tue, 8 Jun 2021 19:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234445AbhFHUBf (ORCPT ); Tue, 8 Jun 2021 16:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbhFHUBf (ORCPT ); Tue, 8 Jun 2021 16:01:35 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4144C061574 for ; Tue, 8 Jun 2021 12:59:41 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id l17so12099196qtq.12 for ; Tue, 08 Jun 2021 12:59:41 -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=Pbi7uOuzeEl+VgFXrG3Aana1E02g2MQcsvlTjQXriG4=; b=n/XPFComesxQfpoygdV+MxbihlUYsSaUE+qfxp1kOKeIyiYlu3TpO0sF4qT3lg0XAC UM7Lh+62wnRWje3JcXhoZIYwXcAZiaeUd2pO+FrMBIjf66cAY8Ci6tJ+Ya5jwGKaN9qB OaD2k36q+Sw4H2NLpZfar7mXGL+DQhQPbwicJtRrSdyE200gi0xHA3LFFbDd6mmHVlAC ZncPBD6wKP6jafEbmKBGfCZ1TPHucJJ3qWUrJosu5R3pXsxr28SKRP51c+r6OgtQN3GJ hAMWy+W6GNVDrtU+TbG67R938afZ8dW04Ws3X9DT3HnU5Wces23BJD04H1lr1bQTMU14 ro+w== 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=Pbi7uOuzeEl+VgFXrG3Aana1E02g2MQcsvlTjQXriG4=; b=FOcI5sfqGgfkwNyQF5Cv3Mj0UgQ5if2F4g726vvlh69lY8pOa5+kwqvV0Eqb7mqT3K Hn8d7UMLqHofElFtCeKyEm/kDAEjIQJmlhnMfxx4NRMew7WlIOwY8xIxvONGMjHYfYYy C4lMlXtu1Tz/2Fo7puxxlJZ0cRR9Q+lnNdwFWdSGih10r8j9IxkiBdKaSvcrL2nsWLZN p9mKHp8X3a2f0Qjfd4iPKvutKHnwNzVg+gclJgCibcHIbvrcp7ezRgiTgoCsFrvVrt45 tIZx2oBvGn205JWkzqTLsnhiE2mMXalNbd5J77KDsmRK0oWx4qMqDeRcCv8J48L6ohWW QOIw== X-Gm-Message-State: AOAM531vuLLvqvdiHWkLKR6BWUEOT5db5Y5ojVgy0yjqOtPJkqChH0uv D/Z0Ib/AMm5P+kEiot3dMamIbr+FIh0= X-Google-Smtp-Source: ABdhPJwyyRZyq1MmyFiXCjP1q6nxj+G/PAG+76b7KFL5ZJAYxC9d+X6/RcRxXTHbnlYgLG4SjQDECw== X-Received: by 2002:ac8:60d4:: with SMTP id i20mr22699815qtm.36.1623182380994; Tue, 08 Jun 2021 12:59:40 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:40 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 12/13] sunrpc: provide multipath info in the sysfs directory Date: Tue, 8 Jun 2021 15:59:21 -0400 Message-Id: <20210608195922.88655-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-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 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index f770eb7301b5..b3bc76bbc2a0 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -67,6 +67,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) @@ -102,6 +111,23 @@ 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\n", + xprt_switch->xps_nxprts, xprt_switch->xps_nactive, + atomic_long_read(&xprt_switch->xps_queuelen)); + 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) @@ -235,6 +261,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, @@ -243,6 +277,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, }; From patchwork Tue Jun 8 19:59:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12308103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E5FFC47082 for ; Tue, 8 Jun 2021 20:00:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8467B6024A for ; Tue, 8 Jun 2021 20:00:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234494AbhFHUCs (ORCPT ); Tue, 8 Jun 2021 16:02:48 -0400 Received: from mail-qv1-f46.google.com ([209.85.219.46]:36538 "EHLO mail-qv1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234216AbhFHUCr (ORCPT ); Tue, 8 Jun 2021 16:02:47 -0400 Received: by mail-qv1-f46.google.com with SMTP id im10so10654295qvb.3 for ; Tue, 08 Jun 2021 13:00:42 -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=8R5h9KiaQ7MVmdjI8tZwnReX9og5Ej1v5uXoHm/LsKk=; b=Rd69FDCmWP4um8UpZq96ddYpEr9mQ/p+4l2yXJhb8v0BNWYpyeholea3B6DQymKHcV FXEae5o/5VfkloAYHRszS3+5FURKGmrHDgILyYabGQ93HbYia/TUzL7VSspRwqM0ShjM 58Oh+eZvOyzsufAsNpeqgEc2kB5sNttTN4l3ZHWPnA1o680iTpqj9rgylBAv++gVKkE1 8fEgeD5JGRU3bYkeO1DeMLgR7Rb3oBWuCKDjYkU54EmzdQrfISj1mL9ee20drXtKH4ip IZGOZ3gFulpxxWQWLB4UXenBd6rVGOZzKVcexYIy7/RaojbM8NCZJVWBopXCnycPCksG SpHA== 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=8R5h9KiaQ7MVmdjI8tZwnReX9og5Ej1v5uXoHm/LsKk=; b=ZTgE37K3H/D+FbIB7sHUpapmk4vaQ9Znom8fVIYnt0KcSJ8JdHslEEZkJ2zb6FvCWr yNXfLBA3fQ/xwZCGMs8MmL80rCJy38d8JFf7IU9hM83Lt7SfEJ2TJKbnHwuYFaKbgjAV IROIzaqAtBVngA1bPyhPrKhN16yhZBoqE+F3mgs99F23o8TDgK+jrxSSXsSyjg8Ej5/K P7JBc1p41OmYequXC9FRBan7lkSzHDWAf6hP4P8ieG7TPTFgk4rc4lHXAjavEdTryqV4 4dDUvvYc69ZxOZgwQFxR+vCUR6puvtdNzHbKsc/UcCW7MJMA0irLAPk/7nHPxa9Gp1OH z+cA== X-Gm-Message-State: AOAM533w7V5V3S4XW6ndMzdaPo4uge51+GfZUzapmH/aMwqsf6AIEvYm lHoNbS7r2S82H48pTKU7UditCjQb/W0= X-Google-Smtp-Source: ABdhPJz9BvEnvoPOMedDMT9X33A/ukArW1twf4/lIP1JsYJQw+/1CS+9I1KWlATmtASZyLV6h+zNEw== X-Received: by 2002:a0c:c3d1:: with SMTP id p17mr1944278qvi.44.1623182382102; Tue, 08 Jun 2021 12:59:42 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:41 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 13/13] sunrpc: provide showing transport's state info in the sysfs directory Date: Tue, 8 Jun 2021 15:59:22 -0400 Message-Id: <20210608195922.88655-14-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia In preparation of being able to change the xprt's state, add a way to show currect state of the transport. Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index b3bc76bbc2a0..2fbaba27d5c6 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -111,6 +111,49 @@ static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, return ret + 1; } +static ssize_t rpc_sysfs_xprt_state_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" : ""); + } + + xprt_put(xprt); + return ret + 1; +} + static ssize_t rpc_sysfs_xprt_switch_info_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -255,9 +298,13 @@ static struct kobj_attribute rpc_sysfs_xprt_dstaddr = __ATTR(dstaddr, static struct kobj_attribute rpc_sysfs_xprt_info = __ATTR(xprt_info, 0444, rpc_sysfs_xprt_info_show, NULL); +static struct kobj_attribute rpc_sysfs_xprt_change_state = __ATTR(xprt_state, + 0644, rpc_sysfs_xprt_state_show, NULL); + static struct attribute *rpc_sysfs_xprt_attrs[] = { &rpc_sysfs_xprt_dstaddr.attr, &rpc_sysfs_xprt_info.attr, + &rpc_sysfs_xprt_change_state.attr, NULL, };