From patchwork Wed Apr 28 21:31:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 3BCC7C433ED for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 053CB61441 for ; Wed, 28 Apr 2021 21:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbhD1Vc7 (ORCPT ); Wed, 28 Apr 2021 17:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbhD1Vc4 (ORCPT ); Wed, 28 Apr 2021 17:32:56 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B3A7C06138C for ; Wed, 28 Apr 2021 14:32:08 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id i12so33636143qke.3 for ; Wed, 28 Apr 2021 14:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gf/HTiMOF7lEE7p7o4BD7uDS+joARQgZSioVyNny/f4=; b=HRYVyIIpvFYXtj8a/gTNE30WfgE7DCsl7zigIwde3yvvEbq2sS5bx0tW/S/6s+pbm2 uysuYpvg7kPvvFaEzRDmU6ei0kbOd+/ni6gSXN8aCcFvPDrARwAxd7nxIdHv7gmjQ2ak ATDW0uzdLgUMqCM+t5TIfboWcuwbFq2ynf3EhqrOZqpN3of2ZnPUsHzy7ZJzw52ktZk7 uFnMI852xkbi9Fii2jhWx/h0mQUJx7vvLE37fOge8LwKKRXNrZ5y2D81eY9OtUpH3VFq k8l2kvqoCM1YDEmIti5pWL9KoBKuq0uhTEmxi2R/f3qexRNz4XYtoE+0Uf5vHwgaaOwg 2j1A== 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=ClT02ZMSvMupamLMvwImYIc1KoxSIC0E43ZBhQULxoGpY6GFLXKokjHXGE+qAFpQAt XqhCTuE+VxJ83llY8NRIM5X0QEOeYBqLM2ALvL2OwORQJwGLivLPVnUeSc8H5MGHxx9p EwttWStESg6JbyZyOJJiMMLedj4yIygCqxJ9hMiS4+FpTnVriA8SJfA9RKqEriCxM1Kc CjCLBl0FJkeuR1KLjL0vwkjyz6zV+CzjbSaXl2d8FORmODhE/3sTs4YtpvP9Yqx/OFKF 7F/VwvKb9KfySMwIo/jTrUsO6AAWAZhkII+yRD/ecAqJgQFH4Ct1jX+hTUCN6Ot8XE/R tMKw== X-Gm-Message-State: AOAM530hGHKIhz7Mvr2b/Q6A3qW71PXOeo7ISJx9y1+/grCzJYBigwT0 JUGhPwSebZ7lG2x4FNaRwPA= X-Google-Smtp-Source: ABdhPJwHXA2KhkFDctb9IIXYlx7NRmhH0hmvNszIjF65TRU66ymc4HwAPHMyEtLBzK4BmD8wZFYaQA== X-Received: by 2002:a37:a597:: with SMTP id o145mr19536352qke.265.1619645527815; Wed, 28 Apr 2021 14:32:07 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:07 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 01/13] sunrpc: Create a sunrpc directory under /sys/kernel/ Date: Wed, 28 Apr 2021 17:31:51 -0400 Message-Id: <20210428213203.40059-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 Wed Apr 28 21:31:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 A4BF0C43461 for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62A3861441 for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbhD1Vc7 (ORCPT ); Wed, 28 Apr 2021 17:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbhD1Vc5 (ORCPT ); Wed, 28 Apr 2021 17:32:57 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDED1C06138D for ; Wed, 28 Apr 2021 14:32:09 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id l2so13669158qvb.7 for ; Wed, 28 Apr 2021 14:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ujEDos81NUbHnHXtpykY5JrCoGurJBkkkPFV1HlWdwc=; b=XzzWuFKIaoKfV4JIv/pPthtov6glXCXuCdB28d7RUgoiOgAydvClvE76eZPV543bs8 y2QsWmEsdF8GH3D03RBa4IP7eERM6j4b1DWhtIu3ilTycPLHziNjkxlGmfAu/QaBYUzE oYxaHfkm/q7Ee8SsPPyghoZadhVeqU3n4G4DiPeCmOBCMEHDP7dJJ1gGIaDA9mkTuRFt 1bBf8/kWpopQhhxHTUa3ozj4PGPDKAVOVlx+Q38N6j7iCX1cKvu/jshDX492t4P5GhWz y2fCXkg9FBcpY6w0+FMKv8a64KURovwkW+RDnFNEnXdpLq32NG/Uy5L8tOsuvtC08RvO LnFQ== 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=IM+pJBqPUDUAR+nLQfGRKEus7xYh6w2gOo7N0eGc+FZteZTZ77nPjo9doHcYDhI+q6 K/NJYtwi9WKizPxdAF90xieXyBSUIai2QHTOfdMknk49MC/518RfcT2IuUun58BJZPoO xuK3+6raIc8Hv9pJL0UHAsDUFSlHX76NSJmnov0tCb+73NlxdHEzhJT+Mi1JaqRJNEzs GNe+j9AavRq8NJo1G3TlC1qG79gaMrVsFmK7LcB4LuwI+8/1MwD9f6c18+3A9cxvnPNY y/rXb/k004dH2cqwM90C9Q1f4vqi/gX5e1zjGoVf3YwnXa64MMOuk+S54m+Aig53MOY5 lSLA== X-Gm-Message-State: AOAM53149P5sKllOdKkpOENLx0350wRXw+fhgiETuiNa3WdXf1Nay7aA jROp+VvAEI7qDEmqIce5MOqLQDhm8mZvbg== X-Google-Smtp-Source: ABdhPJyVNZuvB0Hgo4+Xym7mFbhZQRN1XgCLsXVVIOQ+yaXtArzo1nUUSuPceAa+4yRQc0fqFDbdLA== X-Received: by 2002:a0c:cd10:: with SMTP id b16mr3334075qvm.0.1619645529060; Wed, 28 Apr 2021 14:32:09 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:08 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 02/13] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Date: Wed, 28 Apr 2021 17:31:52 -0400 Message-Id: <20210428213203.40059-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 Wed Apr 28 21:31:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 698D4C43460 for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29E90613EF for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbhD1Vc7 (ORCPT ); Wed, 28 Apr 2021 17:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhD1Vc6 (ORCPT ); Wed, 28 Apr 2021 17:32:58 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E7EC06138E for ; Wed, 28 Apr 2021 14:32:11 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id q4so19448790qtn.5 for ; Wed, 28 Apr 2021 14:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xzEOeQ8uxLAvSORSwpAmvrg7YRMau3GKaNMcBzma4aI=; b=edGfVk+KeOHsoIYnaEOw606MPy3a+vhqUsVusrCfOZ3egHGAEPgWEoUm14u9ca8O8c TSohwxBnky1z68fefyCQvuM+Upeh23W7GpfLmlBI8fGhB6SPZKIXvJ3Wm3ZB3+pvN3YK Tpc4wRduRYM/XHVXxPIwWqSXpFt9ZJ2lnO6y+33ZyBln/n8FxzboPf/E3Cl7YQERtv4c z6/10DezLLz/q85L6Z93pNbfaJU9M713ysNGBrE4yv0fXqSEcCEjx8+OzVd87bpvpQkv RaRnIwYwYDNv7BucIufHHfViEASirBKKTJ1FPqaRmSulRZRtozYP7nCzw5ZUSPysuf1l PZdQ== 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=xzEOeQ8uxLAvSORSwpAmvrg7YRMau3GKaNMcBzma4aI=; b=KINZoltKl43j62y6aSan0ClElGaxU9z0YjBVcVKDXVyJ74G96GWy2qMqDkiTJVh+9w pdMfQ8MmKEUeyrWBaazUhjlT8EEYLS0tH10zYeTEvnKpI4uxfKATRwraMUZnFBSAYMnX oHt7k5oZBzMfgxYChGwfKGonwDyGnw5j0bfGoD/mA1xFNhFLLw6SP8VfXZnjlAG3yG71 hrzLWihQQEdznoxdNv5JEdLTiu3cCaJgfRKo9jbSvRzIJc84hXY3oltn8TFNaAX534rf O2U36bYaFNSU7YQBl7+zJdEAkPUpA2D4swlELto1R1Z97BCD715+EP85DN2IOll4vrPz glcQ== X-Gm-Message-State: AOAM531TGsyJfWbgTWoabhpLrwPMOJewaiKcydJvoitx8vKraOE3Cy8h A5Bp2WEr6vL23suSLkqZ1roKRA0szYz41Q== X-Google-Smtp-Source: ABdhPJwLEYWWH1sD3B5I2NVLUbPOlmrGpIp/Is3I/ZwPrMLwYrmDyAPiG0p+IwjIz5jDg0TYtcl3Fg== X-Received: by 2002:ac8:479a:: with SMTP id k26mr28958819qtq.188.1619645530403; Wed, 28 Apr 2021 14:32:10 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:09 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 03/13] sunrpc: Create per-rpc_clnt sysfs kobjects Date: Wed, 28 Apr 2021 17:31:53 -0400 Message-Id: <20210428213203.40059-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 c2a01125be1a..dab1abfef5cd 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -41,6 +41,7 @@ #include #include "sunrpc.h" +#include "sysfs.h" #include "netns.h" #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) @@ -300,6 +301,7 @@ static int rpc_client_register(struct rpc_clnt *clnt, int err; rpc_clnt_debugfs_register(clnt); + rpc_sysfs_client_setup(clnt, net); pipefs_sb = rpc_get_sb_net(net); if (pipefs_sb) { @@ -327,6 +329,7 @@ static int rpc_client_register(struct rpc_clnt *clnt, out: if (pipefs_sb) rpc_put_sb_net(net); + rpc_sysfs_client_destroy(clnt); rpc_clnt_debugfs_unregister(clnt); return err; } @@ -733,6 +736,7 @@ int rpc_switch_client_transport(struct rpc_clnt *clnt, rpc_unregister_client(clnt); __rpc_clnt_remove_pipedir(clnt); + rpc_sysfs_client_destroy(clnt); rpc_clnt_debugfs_unregister(clnt); /* @@ -879,6 +883,7 @@ static void rpc_free_client_work(struct work_struct *work) * so they cannot be called in rpciod, so they are handled separately * here. */ + rpc_sysfs_client_destroy(clnt); rpc_clnt_debugfs_unregister(clnt); rpc_free_clid(clnt); rpc_clnt_remove_pipedir(clnt); diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 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 Wed Apr 28 21:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 F2706C43462 for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B561C613EF for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbhD1VdA (ORCPT ); Wed, 28 Apr 2021 17:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbhD1Vc6 (ORCPT ); Wed, 28 Apr 2021 17:32:58 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58681C06138B for ; Wed, 28 Apr 2021 14:32:12 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id d12so9732017qtr.4 for ; Wed, 28 Apr 2021 14:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x4DaaU9yOVKZrRAH+MhLqkl5WKTJPjX+1LKTHN+yRCk=; b=E+5PFuATJjSEb/vCbBLge8pIklofmRdlu4cXcOqP//n6DCuGpOBn1TLPnNYyYpgsPM vjplPmbxQPI41OsZkW3x4LlyKtv5FwEcuJKAGL34HN+PBeV4USrqhQIo8Zz0NZnlEIAW YAoVMcxjKm10uMmiVr7dQdku3PW+m9j3CThN3QSDbRFiSWf6nV8+mEJG50eG5T5mxBkO 5Huj8apzoNcrEG1OOns5eYsblAa82dU7xK5hV/dLg5DASsXZ1ymvruixIrgzt9gXmUbo Jx14K3R3INjNihKmt2jtSHgT//pRbbR1vv72FYnW4pUX5aFeq8BD96EBsx2SVGuFS1mr v/oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x4DaaU9yOVKZrRAH+MhLqkl5WKTJPjX+1LKTHN+yRCk=; b=fN/RKWjivc3HsJcHzYah+jA3c0na+V1Z1hJhy6XeGewb/SbOfKZcy5H82ZP4Z3TPQM pbq+0MXdEKb2tu8QvKMk7SGJ+gt3Kc1/y+yeB4t8JVKmSGGsaUkKC9Wlnb9OVkW9sBYz CbuKEkkWDh9kYQ7pvaYW2s59iQQM2SasKQYWUPoc+y11wzzfl7oUvWsYxuJ5JcB54RJp BfJ4h7YHYE01FpCD8J/A3kPpp9Vj/D46V+VY01HXp4X5sAXuqJCPHLOLLJ9Bjr656YIf 6ridCjBfj1lO/kdL3zx6xBQuN95AjqzghS0BFd/5WA9I6KzGq9Mzh7ur1xHIljfx/aRs rhrw== X-Gm-Message-State: AOAM532rclschSOTZT5x2TF5aG0PBpzmya5bVwVE/Vc8L+6SGVVoxEr8 ZUoUXaMcLSKPNWlMCh1AfpU= X-Google-Smtp-Source: ABdhPJwLF2gDuySxFoouKsh/hExFhCHDI/IbvaWouKvoMUARk+ZAmTgZA0f3gw91pdCBeZYOLUaz5Q== X-Received: by 2002:a05:622a:3cf:: with SMTP id k15mr27568448qtx.282.1619645531630; Wed, 28 Apr 2021 14:32:11 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:11 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 04/13] sunrpc: Prepare xs_connect() for taking NULL tasks Date: Wed, 28 Apr 2021 17:31:54 -0400 Message-Id: <20210428213203.40059-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker We won't have a task structure when we go to change IP addresses, so check for one before calling the WARN_ON() to avoid crashing. Signed-off-by: Anna Schumaker --- net/sunrpc/xprtsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 47aa47a2b07c..2bcb80c19339 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2317,7 +2317,7 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task) struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); unsigned long delay = 0; - WARN_ON_ONCE(!xprt_lock_connect(xprt, task, transport)); + WARN_ON_ONCE(task && !xprt_lock_connect(xprt, task, transport)); if (transport->sock != NULL) { dprintk("RPC: xs_connect delayed xprt %p for %lu " From patchwork Wed Apr 28 21:31:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 D2C1BC43600 for ; Wed, 28 Apr 2021 21:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C95B613EF for ; Wed, 28 Apr 2021 21:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbhD1VdB (ORCPT ); Wed, 28 Apr 2021 17:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbhD1VdA (ORCPT ); Wed, 28 Apr 2021 17:33:00 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D30C06138F for ; Wed, 28 Apr 2021 14:32:13 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id o5so65212943qkb.0 for ; Wed, 28 Apr 2021 14:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rHzBpwJvTvHqQjiOwfvuYiOBLOQx3SSYI4e3E1a/UCY=; b=ND2moWvSvAWWsGoZouNPmy1LPx+UILvry52kHLq3RJlFEIjZrQES/k0Cd0OQtdb6Rp syfhelC7KxhJ+qWfp9VmU2FCaJmBL3562riJGXV66Jc1+TYvvvcy9ZhkfI0oJSZ5Q9Dl KzPR/12c2kN1WQocAH40OXtkk3UxgnrhlTLV1luofM1qcbxMBLxgwRc+hdN2FvOcDFj5 B00/txrYMKXlQXPHY2XgSdMel/6mG1dHl/QvNqdCSH79+PS9NtvrK0HyxOx5k5lP3rvq vMKX2Yrg09arV9Jaf+5QW2O+0FIFSMn5lJpAezcK2VOaHmY5qxfQGrR+T0/hWOm++vX0 Nnng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rHzBpwJvTvHqQjiOwfvuYiOBLOQx3SSYI4e3E1a/UCY=; b=B+zvSBF4usDJ53PR9SdGFKgEkE9iTjqDiNIx2C8EmCfvT2u/zDK4hsO/CLtLuURBIp NaDxKxMW4/V5Ghd/Uw2RsU4SYaX/Ex64vnphH+vz2UWFlwFsCm5S+IKlRn1AcqGIAvrY Tk0Zbd1KtKVSUFhlCFGtToTKwmDraYrJ18ImOok1IyVpXUeJtQcUx8493MGNV41L/gVG HD858YmbqZ9vpMqJNcja9rHzEBdV1EfvKtML89m9b4hg8XUZab3AvBno4R+FLmrZnXFM zQJ/q95nw33MRigVpqoFU0Pyt8glfH79JdiE27i0T7D9lfgQmiKruHQ7GvNVKtsSIeBG n+LA== X-Gm-Message-State: AOAM532QpRrfI1SOFsNFotgH1K4D/fMMqXD4cKcoia1LX8vcDsnZTTh9 lShXM4ApE2GKKiapEKibRDQ= X-Google-Smtp-Source: ABdhPJzjVvbRNXB9dd9yHTA5kB2Q+Rv6kbjFS5ubXmo7iZPpAOiRL8zTC7RtmSoLTP2iF95pr5XpEg== X-Received: by 2002:a37:7d83:: with SMTP id y125mr31850841qkc.263.1619645532725; Wed, 28 Apr 2021 14:32:12 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:12 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 05/13] sunrpc: add xprt id Date: Wed, 28 Apr 2021 17:31:55 -0400 Message-Id: <20210428213203.40059-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Dan Aloni This adds a unique identifier for a sunrpc transport in sysfs, which is similarly managed to the unique IDs of clients. Signed-off-by: Dan Aloni Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprt.h | 2 ++ net/sunrpc/sunrpc_syms.c | 1 + net/sunrpc/xprt.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index d81fe8b364d0..82294d06075c 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -185,6 +185,7 @@ enum xprt_transports { struct rpc_xprt { struct kref kref; /* Reference count */ const struct rpc_xprt_ops *ops; /* transport methods */ + unsigned int id; /* transport id */ const struct rpc_timeout *timeout; /* timeout parms */ struct sockaddr_storage addr; /* server address */ @@ -368,6 +369,7 @@ struct rpc_xprt * xprt_alloc(struct net *net, size_t size, unsigned int num_prealloc, unsigned int max_req); void xprt_free(struct rpc_xprt *); +void xprt_cleanup_ids(void); static inline int xprt_enable_swap(struct rpc_xprt *xprt) diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 3b57efc692ec..b61b74c00483 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -133,6 +133,7 @@ cleanup_sunrpc(void) { rpc_sysfs_exit(); rpc_cleanup_clids(); + xprt_cleanup_ids(); rpcauth_remove_module(); cleanup_socket_xprt(); svc_cleanup_xprt_sock(); diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index e5b5a960a69b..fd58a3a16add 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1722,6 +1722,30 @@ static void xprt_free_all_slots(struct rpc_xprt *xprt) } } +static DEFINE_IDA(rpc_xprt_ids); + +void xprt_cleanup_ids(void) +{ + ida_destroy(&rpc_xprt_ids); +} + +static int xprt_alloc_id(struct rpc_xprt *xprt) +{ + int id; + + id = ida_simple_get(&rpc_xprt_ids, 0, 0, GFP_KERNEL); + if (id < 0) + return id; + + xprt->id = id; + return 0; +} + +static void xprt_free_id(struct rpc_xprt *xprt) +{ + ida_simple_remove(&rpc_xprt_ids, xprt->id); +} + struct rpc_xprt *xprt_alloc(struct net *net, size_t size, unsigned int num_prealloc, unsigned int max_alloc) @@ -1734,6 +1758,7 @@ struct rpc_xprt *xprt_alloc(struct net *net, size_t size, if (xprt == NULL) goto out; + xprt_alloc_id(xprt); xprt_init(xprt, net); for (i = 0; i < num_prealloc; i++) { @@ -1762,6 +1787,7 @@ void xprt_free(struct rpc_xprt *xprt) { put_net(xprt->xprt_net); xprt_free_all_slots(xprt); + xprt_free_id(xprt); kfree_rcu(xprt, rcu); } EXPORT_SYMBOL_GPL(xprt_free); From patchwork Wed Apr 28 21:31:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 1F32DC43470 for ; Wed, 28 Apr 2021 21:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D67F66143F for ; Wed, 28 Apr 2021 21:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbhD1VdA (ORCPT ); Wed, 28 Apr 2021 17:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhD1VdA (ORCPT ); Wed, 28 Apr 2021 17:33:00 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875CCC06138B for ; Wed, 28 Apr 2021 14:32:14 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id o12so131167qtx.8 for ; Wed, 28 Apr 2021 14:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Fg1CTEpqXVj95kKutPWoBVqcxEtRPxgNEonrsSkYnU=; b=W96XYXineoAxsVOcke2j3JY8q/G75BfJ6/wfubgRE3W/3NlRmrTy8wzneAZ2U6h7wy REyPearNSxCk4zUoWwqPbqJP1zWhqWM8jrSD2PgnXTMXehUPziISXRixa3IejOzpsooL y4+0a6ZVbDLRvvNdz9Qr52wwaLckrkYVi3P7nZwpzdS0liNpeDNlQzX3+X9g2SkDMQNU xsNHemMyUhxLRQFYBYl266Y2qyCKISj8XT4xXj/w9INi7gGys1qKlxPlDWxgHqXGQb/I rjuYPmcRjUjzsiRPQp7+Gl/VO3xP+NJSh7oCkWjRteTb3MaLduOnVGqt9y4S0OQYLY7t D17w== 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=KRNhgbhtk72s0mQ1cCURGeIFlJZHMbouS90zeN40ZFaZ4gYjtQkep18vIL2eOMgaC1 8A6lyk1N0vbGDVXmqpe5FBl1b1WzDYBvYemoivRcpPyrIicu2y5u4uZAL6jhS8dA25BH l9ofl1YuAN1Tlxz8au7hBp44M6/4wU18UE/N1Uuyo2j8yquvunVBXobhrvteVRVidtmV r7pTKKPNlXB0igvMwSdjatLHRKKpyoPYr0+c1ogFLpVqA/wgti2mobXnaUawijxKw0sC mSj/UTSplPUmRdQgpEYYwTNruIq1oaIcVrl9FumllIPHa+x3Yj2Q/I6g46vqZkdyyqAR +riA== X-Gm-Message-State: AOAM532ZTAGH3Sw7iQxz66ST/DmjfzN+4JbLv0HO06GKY+XPlJoqKFM1 2zouL/Pu+2QEzb/oFeKaTkwii8vLNexqqw== X-Google-Smtp-Source: ABdhPJzgjuNHYth0rLRT3m68jqtHgRXUmZzaLgPu8iGiJrie88iXx4oRCYPO37cqZMiCPB3xn3u7cQ== X-Received: by 2002:ac8:7774:: with SMTP id h20mr28993290qtu.79.1619645533818; Wed, 28 Apr 2021 14:32:13 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:13 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 06/13] sunrpc: add IDs to multipath Date: Wed, 28 Apr 2021 17:31:56 -0400 Message-Id: <20210428213203.40059-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 Wed Apr 28 21:31:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 35CCFC43603 for ; Wed, 28 Apr 2021 21:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F17BA613EF for ; Wed, 28 Apr 2021 21:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbhD1VdB (ORCPT ); Wed, 28 Apr 2021 17:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbhD1VdB (ORCPT ); Wed, 28 Apr 2021 17:33:01 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B05E0C06138B for ; Wed, 28 Apr 2021 14:32:15 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id t17so36732078qkg.4 for ; Wed, 28 Apr 2021 14:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OEB3fsVvOc0l4sGUbovZ3sxmkNfiwInhgmEzkRx418Q=; b=RZlCW+BraUgW32E5WsooTE/OR///ykn94qwbhQST2OqMmHoZAfwtV4WP1gdPybnnxQ 9siM8cYfwYl0B9UEpj2datu99Y1Ca4YegLyqHNDpnIJJCwJKeYtO6hEhGxLPvN7MhIsr uq1BO699kj0PLiI/rmguQfKn/gYHaWHjWPw9UcAxd+fQXxI9CyZ6GYCevzz9Mzpe7ClG 8TBWhtaWROzT12AxrzHGfC3y01GAK5co6TYCscDQRLsc6CIDk8mZtcGH2/jcZ0zdHZll RgNQUjc3ZjP4OY9QHufKXnZ59Dd0kZwXk2PHMKznSGBx5VgrncAs2MzIhfRa3b2p4IDF Ye6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OEB3fsVvOc0l4sGUbovZ3sxmkNfiwInhgmEzkRx418Q=; b=T9GW4dTy+FX5YJBuQI2NYMmUgTTd6B2WhNc8r3ma8ZFU7m4ZjxI1qhms4p5QoGa6ZO l+Gg9pfUiee4y5YlB8fvKsW9D9NuKd4qrCr1WUos3j0s45Q2uUbkYsXIIOEC5POxR7yL iiRX97kLZ1qsLvOdktlHijBc0OrosmavFHK9EE6OuouT1xmq3lrV3xbr9uoq0oCJe6Qr 8rf6gQwMfhEDxcI4ZrdZjaj8SkQW3hi9b+tjycAUTgnMU50/0Qkr7QcqyW7psGGXLgEl WVLNco8ZE+0XW7MJm0KevJFp7VErW3vhvCPOFtnrp4vbhD4hMEWGorzze8ENgt98yUM+ 2ZEA== X-Gm-Message-State: AOAM532bcKKy/Pc/SaaSDBCFtVwxZUXLUZ73heRzKBg9ge2lufVLoV1i QfsDNFaKrY/d/Lx25EOLAKg= X-Google-Smtp-Source: ABdhPJyKJnZaDg1NK4EEM8TyJw2KwxRsbcxP1JmERcuRNUWAEDrbf5pKj3Ii7dBPcppX889o4/UAIA== X-Received: by 2002:a37:6606:: with SMTP id a6mr30696616qkc.165.1619645534958; Wed, 28 Apr 2021 14:32:14 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:14 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 07/13] sunrpc: keep track of the xprt_class in rpc_xprt structure Date: Wed, 28 Apr 2021 17:31:57 -0400 Message-Id: <20210428213203.40059-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia We need to keep track of the type for a given transport. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprt.h | 2 ++ net/sunrpc/xprtrdma/transport.c | 2 ++ net/sunrpc/xprtsock.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 82294d06075c..a2edcc42e6c4 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -53,6 +53,7 @@ enum rpc_display_format_t { struct rpc_task; struct rpc_xprt; +struct xprt_class; struct seq_file; struct svc_serv; struct net; @@ -289,6 +290,7 @@ struct rpc_xprt { atomic_t inject_disconnect; #endif struct rcu_head rcu; + const struct xprt_class *xprt_class; }; #if defined(CONFIG_SUNRPC_BACKCHANNEL) diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index 09953597d055..71500eb89bff 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -73,6 +73,7 @@ unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE; unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE; unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRWR; int xprt_rdma_pad_optimize; +static struct xprt_class xprt_rdma; #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) @@ -349,6 +350,7 @@ xprt_setup_rdma(struct xprt_create *args) /* Ensure xprt->addr holds valid server TCP (not RDMA) * address, for any side protocols which peek at it */ xprt->prot = IPPROTO_TCP; + xprt->xprt_class = &xprt_rdma; xprt->addrlen = args->addrlen; memcpy(&xprt->addr, sap, xprt->addrlen); diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 2bcb80c19339..5ff37badd335 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -91,6 +91,11 @@ static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT; static struct ctl_table_header *sunrpc_table_header; +static struct xprt_class xs_local_transport; +static struct xprt_class xs_udp_transport; +static struct xprt_class xs_tcp_transport; +static struct xprt_class xs_bc_tcp_transport; + /* * FIXME: changing the UDP slot table size should also resize the UDP * socket buffers for existing UDP transports @@ -2777,6 +2782,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = 0; + xprt->xprt_class = &xs_local_transport; xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; xprt->bind_timeout = XS_BIND_TO; @@ -2846,6 +2852,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = IPPROTO_UDP; + xprt->xprt_class = &xs_udp_transport; /* XXX: header size can vary due to auth type, IPv6, etc. */ xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); @@ -2926,6 +2933,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = IPPROTO_TCP; + xprt->xprt_class = &xs_tcp_transport; xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; xprt->bind_timeout = XS_BIND_TO; @@ -2999,6 +3007,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) transport = container_of(xprt, struct sock_xprt, xprt); xprt->prot = IPPROTO_TCP; + xprt->xprt_class = &xs_bc_tcp_transport; xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; xprt->timeout = &xs_tcp_default_timeout; From patchwork Wed Apr 28 21:31:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 1648CC433ED for ; Wed, 28 Apr 2021 21:32:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4CC2613EF for ; Wed, 28 Apr 2021 21:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbhD1VdE (ORCPT ); Wed, 28 Apr 2021 17:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbhD1VdD (ORCPT ); Wed, 28 Apr 2021 17:33:03 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E80D8C06138B for ; Wed, 28 Apr 2021 14:32:16 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id 1so47802692qtb.0 for ; Wed, 28 Apr 2021 14:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wGOpSsX0RI8U/ko+9V6YHdVM++uPnR7REoldeJWyPrQ=; b=otjLOv3hmOjQ2DsXqAFwlE2tU5a8JqITlfHytzAglLqhtmtvwa4HikXngWP3Mc2qm2 yy/rW3TkNKXs96Icgf4/gzcCiyyNqEIga8Q6bomvn4mv5rqos2sMQMtEqAc/ZoHdA6sN Qg8ahYjr+0lzShKG3p3INACNH+oYXjkbbtROfTGck1gCq8AZ0+Th6N/GZQrFkhYgwTkI XYd5oH8trbZWnBtVcOY8FKGrI9227udkD2kZdaqhgiTYrmA52PFnm6M5mTs7LGKZ2HGe FjABRejLCE/Uxf2UXAbHIEOIkYYAhzyu7NO+c5cWO5N6yYLdRbncVOIQwg6Cfq421Kh+ sxXA== 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=iTtlJMo1ErkTvkbWlSwwSD1E6N1EBIoYws6qZEHg01WG1GUSrqNQn8HGiDe14wADhV GEEimKhtI4pQl65IsKT4biTA8/CRrHdpmw1dfizMOQy1b2vyqneMkHR/Xep3RCHCZ8xg WUxHhwzJjm807ltrtcnYmzkr88ejivNBZLIj9P652gfVWtYuv1WeyI2Jbf8ZRLgYif0D YaC7Pa+l8BxPPavORSqFvJ82X60DRqVvlYBlWKls91NtGLIzapkwZWXI8bgAFCebxPBp Dc7mggE3my4jWsYr8iHuS10y9hkezwPdBzaTEcB9VsTsFxYO6BprzmK0xV/Cy0+2oStO KCTw== X-Gm-Message-State: AOAM532P4ooYxHVEBhoalelM2cKeBoLJ+w25BKElOvBj54GJa+VCu16D 7mKS4+702DOYbcLgY88VhyU= X-Google-Smtp-Source: ABdhPJzfGG/01XQRPpRTtnSQZI/QfQ9rdi+Y07mGy0YDG3/wvWTvDgzbJHJK/FJCOVgS5A0+Rk3dHQ== X-Received: by 2002:ac8:4747:: with SMTP id k7mr90647qtp.323.1619645536173; Wed, 28 Apr 2021 14:32:16 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:15 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 08/13] sunrpc: add xprt_switch direcotry to sunrpc's sysfs Date: Wed, 28 Apr 2021 17:31:58 -0400 Message-Id: <20210428213203.40059-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 Wed Apr 28 21:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 B6ED4C433B4 for ; Wed, 28 Apr 2021 21:32:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E1D6613EF for ; Wed, 28 Apr 2021 21:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbhD1VdE (ORCPT ); Wed, 28 Apr 2021 17:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbhD1VdD (ORCPT ); Wed, 28 Apr 2021 17:33:03 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1837DC06138C for ; Wed, 28 Apr 2021 14:32:18 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id o1so6177985qta.1 for ; Wed, 28 Apr 2021 14:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x/K6BjIw2y1W0AbLQSD0bBfb29FdYAs/XqpwUc9kuvk=; b=kkc9D+riYcf9Iks52lDoHCPKdLHFGclSBSx2ERtfXCf5sT5j3z0bIJk6vpiUiDv5D3 UBZc9o4o0zF7jPG3EEbIs+3Um2hxEdjgRKAiGXOA8q5/v7DPaMs0Wd5NujbjjlQ58aCg Rx0kj2YB2EUHgXIclj04Q5VXTOxIty8JnChm8GKmfGUEW3l3aMkyjgbsGcP+KtKlUlqw iHGToZLyPS6Olze9gsmlW6gQuMCCfoxYgJLRKxuecsfhxkAd09yXKiKTCStUnqx9Sdo/ QYOf++JF0XBc2nk9EBGnJNbhOBCrauvCV7XYeRZBgQqjibKW5wR24UcBIiwpLJ4ggIEz IOCg== 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=x/K6BjIw2y1W0AbLQSD0bBfb29FdYAs/XqpwUc9kuvk=; b=bh4Bf76rMdGpFRLOrgisktrfyeGbROG7URK09KRgRmKkqeq0q5OxGerFifZwWnUKKH 5v9BvjFwBkqwV9hZUvp0a6utfWK5TZDUND5GkaeGQ8ZmHiEJRcnBtZc2zMWcVk7BcLFH 22SN12+ffJcEm66ACJxCtezh66M6gflD5OGiYkaEexL8y/WtECfTVrSt1KXQeWYv+Tr8 /SY/6J4o5MiyZIFISa3XHk/F4D7V+jjFMKwqsOvb8Jf+PSzuvtLy2IuVg/n/scFt1sZP GMg/joawIJByQWHqXSJfUB6lOEzL/k2xdj4mCEnExZkklilXeMO0/DaX5VPjMguIIIoZ yz1w== X-Gm-Message-State: AOAM5309KM1HZvmvx5Ctd66PwO87X2s3dgVwGCgvFc2WdNVMlxQRb692 lUZbF8uL28/9LTJ65XaI6h4= X-Google-Smtp-Source: ABdhPJwfHDQTv8+MsCUoic9SWGGpVY33pC7iOTmIBj8delet9QEK8nnyro1+020z+CtVpbyV4gOJvQ== X-Received: by 2002:ac8:4701:: with SMTP id f1mr26550326qtp.117.1619645537358; Wed, 28 Apr 2021 14:32:17 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:16 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 09/13] sunrpc: add a symlink from rpc-client directory to the xprt_switch Date: Wed, 28 Apr 2021 17:31:59 -0400 Message-Id: <20210428213203.40059-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia An rpc client uses a transport switch and one ore more transports associated with that switch. Since transports are shared among rpc clients, create a symlink into the xprt_switch directory instead of duplicating entries under each rpc client. Signed-off-by: Olga Kornievskaia --- net/sunrpc/clnt.c | 2 +- net/sunrpc/sysfs.c | 25 +++++++++++++++++++++++-- net/sunrpc/sysfs.h | 6 +++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index dab1abfef5cd..2e195623c10d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -301,7 +301,6 @@ static int rpc_client_register(struct rpc_clnt *clnt, int err; rpc_clnt_debugfs_register(clnt); - rpc_sysfs_client_setup(clnt, net); pipefs_sb = rpc_get_sb_net(net); if (pipefs_sb) { @@ -426,6 +425,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, /* save the nodename */ rpc_clnt_set_nodename(clnt, nodename); + rpc_sysfs_client_setup(clnt, xps, rpc_net_ns(clnt)); err = rpc_client_register(clnt, args->authflavor, args->client_name); if (err) goto out_no_path; diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index ed9f7131543f..98d27273d988 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -151,14 +151,30 @@ rpc_sysfs_xprt_switch_alloc(struct kobject *parent, return NULL; } -void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net) +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, + struct rpc_xprt_switch *xprt_switch, + struct net *net) { struct rpc_sysfs_client *rpc_client; - rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, net, clnt->cl_clid); + rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, + net, clnt->cl_clid); if (rpc_client) { + char name[23]; + struct rpc_sysfs_xprt_switch *xswitch = + (struct rpc_sysfs_xprt_switch *)xprt_switch->xps_sysfs; + int ret; + clnt->cl_sysfs = rpc_client; + rpc_client->clnt = clnt; + rpc_client->xprt_switch = xprt_switch; kobject_uevent(&rpc_client->kobject, KOBJ_ADD); + snprintf(name, sizeof(name), "switch-%d", xprt_switch->xps_id); + ret = sysfs_create_link_nowarn(&rpc_client->kobject, + &xswitch->kobject, name); + if (ret) + pr_warn("can't create link to %s in sysfs (%d)\n", + name, ret); } } @@ -189,6 +205,11 @@ void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; if (rpc_client) { + char name[23]; + + snprintf(name, sizeof(name), "switch-%d", + rpc_client->xprt_switch->xps_id); + sysfs_remove_link(&rpc_client->kobject, name); kobject_uevent(&rpc_client->kobject, KOBJ_REMOVE); kobject_del(&rpc_client->kobject); kobject_put(&rpc_client->kobject); diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index 52ec472bd4a9..760f0582aee5 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -8,6 +8,8 @@ struct rpc_sysfs_client { struct kobject kobject; struct net *net; + struct rpc_clnt *clnt; + struct rpc_xprt_switch *xprt_switch; }; struct rpc_sysfs_xprt_switch { @@ -20,7 +22,9 @@ struct rpc_sysfs_xprt_switch { int rpc_sysfs_init(void); void rpc_sysfs_exit(void); -void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net); +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, + struct rpc_xprt_switch *xprt_switch, + struct net *net); void rpc_sysfs_client_destroy(struct rpc_clnt *clnt); void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, struct rpc_xprt *xprt, gfp_t gfp_flags); From patchwork Wed Apr 28 21:32:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70D11C433ED for ; Wed, 28 Apr 2021 21:32:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 338EE613EF for ; Wed, 28 Apr 2021 21:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbhD1VdG (ORCPT ); Wed, 28 Apr 2021 17:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbhD1VdG (ORCPT ); Wed, 28 Apr 2021 17:33:06 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A3CC06138B for ; Wed, 28 Apr 2021 14:32:19 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id 1so47802771qtb.0 for ; Wed, 28 Apr 2021 14:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k6d+RHRSIcX7EZrW2bq1HzYMTI+e194TMkV99p30FO4=; b=eBRExJHz5jQGexPQCgQ8+XND1jflJl4QfbHDWKozVDWExFi1HbZPYv5yFmF92iIqz4 CDaxJarSTwoYgABM2VWk0b65kGTzBRXmqbuV743iqyHGwp36LXDL8B6xLdboy71G17Wc 6NiAj3YmAmt1oTmrmPQJuwolupw+6rw3GvOZNeq/YIBLWgG8lm6g6Y4ZT0Gzuva0Gi0b dngoQllKzvEsobE6SrjRhxKVgIg50hMR0Kibyamon/qEe4yzAWo1B2jb6xXXwDYdeMx8 MaW+FgOHjMUmd3RxTrBsOUguyDx4WM/lfozeVE2gkOKSeihMTlUYCEuv55xwcANOAjyr tLdQ== 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=k6d+RHRSIcX7EZrW2bq1HzYMTI+e194TMkV99p30FO4=; b=k7YXyya24NlCar8ZNi++W+54ocpJpSQ4oTJp5VfZE6uodgYEbDzO40S9a3X3Z0E2OF o+lTax3ZVq/2lOaj/CFuP8CIfBlBHIQUAFiAZebmim8Gu48jGDy/tWcbv/CeXw6f61G4 VDNI9Y4XPbNjC/FadoAXNaVhZrAj6HflypJooLja7raqpBI8yX6ofsMtYH8XgLkS6q3t kDJoz0LewgbZjANDpswThQN4LFp7spChkZH+L3nBaLkA4/haGfa3WiprTZaHOekkiCSI dlzchdiYSvOaDt27cemjO6TU0MYcp5+x+SDQml8D8nonE7sAQqEa7D9MOZ+wRWwPQeYw pdOw== X-Gm-Message-State: AOAM532mOzAXfWsk2WXqIsIMvY89Yy7FXJ5jqUFg773KryQu0LtY+AMI wjNbG5z+jC9KIZu9fpGaV4E= X-Google-Smtp-Source: ABdhPJzEO8XXM87+hAZWShuq1++xpXe1127N7fJwKjLeNeS2tV2djPyMWNmao/wJsemIN4E7luvvyw== X-Received: by 2002:ac8:7f53:: with SMTP id g19mr29151763qtk.249.1619645538636; Wed, 28 Apr 2021 14:32:18 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:18 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 10/13] sunrpc: add add sysfs directory per xprt under each xprt_switch Date: Wed, 28 Apr 2021 17:32:00 -0400 Message-Id: <20210428213203.40059-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 a2edcc42e6c4..823663c6380a 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 98d27273d988..78c0ff879424 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) @@ -200,6 +239,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; @@ -228,3 +283,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 Wed Apr 28 21:32:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 EE346C433B4 for ; Wed, 28 Apr 2021 21:32:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0D256143F for ; Wed, 28 Apr 2021 21:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbhD1VdI (ORCPT ); Wed, 28 Apr 2021 17:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbhD1VdH (ORCPT ); Wed, 28 Apr 2021 17:33:07 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7F4EC06138C for ; Wed, 28 Apr 2021 14:32:20 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id z2so28212133qkb.9 for ; Wed, 28 Apr 2021 14:32:20 -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=zLekTvxobSQ6+oTt34AkXgwZSXUp+mWS4nVt6ovQ0yI=; b=KQCZ+oGG4pOyXVB55zvlk9TIOWJvcHwdox1aCnhRLuPQqvVPI+L0GzORTGuzhPyqqX YBF9+Yv5fgIj63ZBJidah9YLXwqD0P4jtY8lZ3Ch4qkwm2Df+y1FPdQdO946RBfqcMFi srr1cPocMEDvbRVWCiEefxstm03Q5PXttJzM9XN3qvk6QNCXhtzOgHxw3ruc+lh+6Att 1mTJfftmrfo1sxymLVqQxusBJ1VExf4txmmdq9M6/JMysRfpbmLyhU1pUPQdZjioIj1e AFNcv0GSqfI/uSCYduGlVa+JRIp/8vgh9d3pwSrpKvZ72xwE2GQu+OVjyKQwggQfFBe4 inog== 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=zLekTvxobSQ6+oTt34AkXgwZSXUp+mWS4nVt6ovQ0yI=; b=P0X8OqVdjy0ooK4LuuJRWsONNVMxrFUJTbRpeD06nM30sixDh00MuIFLN5rzTQKG+L P479KPMc1t2bzh8LHjLja48FZ32KLsgR0ovZQdMBgpoOHnVWxtosn6nTlNvfqu3OFP8p JMYY63nmpwPXlmRGtnTutGIMPjTudRn+lwncbYEgGRKgfngZ2Mdk7PtUDCv1FSxTbqTS CW2LHUKrT2y1Zq50+yoEh/PNBLeQwTBPypGkzaDkOVH6VGYgVhgpis7YDWu2j2BW5EFf Avfj6Uu0xx3ye5ao1RiwqNFQx6TirWjLjYGt0VelJ/kpcMdTaEXSLeH3Lkosf2a8hERA h0QA== X-Gm-Message-State: AOAM53189LhRz4R7moYbBsXr2gtL52/t6wXP0i/pRMGiEiLdtpOfpt8N /sewijF5tZKCuwkj7KZ901w= X-Google-Smtp-Source: ABdhPJwjG6Y5Bybo3hJXK2pZNfCTpFv5g/5nQloJy9KAetWeglTissy2Y+45Mxa8A93joMjVTrU4OA== X-Received: by 2002:a37:42c3:: with SMTP id p186mr31409504qka.352.1619645539937; Wed, 28 Apr 2021 14:32:19 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:19 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 11/13] sunrpc: add dst_attr attributes to the sysfs xprt directory Date: Wed, 28 Apr 2021 17:32:01 -0400 Message-Id: <20210428213203.40059-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Allow to query and set the destination's address of a transport. Setting of the destination address is allowed only for TCP or RDMA based connections. Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 78c0ff879424..234e545a7a40 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -4,8 +4,24 @@ */ #include #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 +59,69 @@ 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; + + if (!xprt) + return 0; + if (!(xprt->xprt_class->ident == XPRT_TRANSPORT_TCP || + xprt->xprt_class->ident == XPRT_TRANSPORT_RDMA)) { + xprt_put(xprt); + return -EOPNOTSUPP; + } + + wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE); + saddr = (struct sockaddr *)&xprt->addr; + port = rpc_get_port(saddr); + + dst_addr = kstrndup(buf, count - 1, GFP_KERNEL); + saved_addr = kzalloc(sizeof(*saved_addr), GFP_KERNEL); + if (!saved_addr) + goto out; + saved_addr->addr = 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, count - 1, saddr, + sizeof(*saddr)); + rpc_set_port(saddr, port); + + xprt->ops->connect(xprt, NULL); +out: + clear_bit(XPRT_LOCKED, &xprt->state); + xprt_put(xprt); + return count; +} + int rpc_sysfs_init(void) { rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); @@ -106,6 +185,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 +207,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, }; From patchwork Wed Apr 28 21:32:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 CC9D4C433B4 for ; Wed, 28 Apr 2021 21:32:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 993D16143F for ; Wed, 28 Apr 2021 21:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbhD1VdI (ORCPT ); Wed, 28 Apr 2021 17:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbhD1VdH (ORCPT ); Wed, 28 Apr 2021 17:33:07 -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 E5D61C06138B for ; Wed, 28 Apr 2021 14:32:21 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id i12so33636744qke.3 for ; Wed, 28 Apr 2021 14:32:21 -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=w0SMbaDJ8a0kqyaBonauxqdv5qcnDIjixu1ZO1KpXNc=; b=nXld/Sv2NpX4W4882PWk6sgk/tQy3dfGCKO36qTxXp2M4CRxJ4izWm08/ZmVMESNwy idSTxRUmlFOdWbpb1Lq98hVOg3MCzNqSpB+Pk4+9RLcQNdTqjqpVBFJ/bxx29WGivaBa Pa/5yg9i36xxUa1byEuR9fP2a8ioK6Y3Z2FPcJBQVDY2jphNsNJfrmTg0/nYI5T+RsaD 2hnFvd8jebGQeXa/PU7XDV4uiTKThvb7xVDjstfR6cVYmki2+1Rb127uKB8M6lGv8CUm 7df8//tXTgsXK2r8t+dnyjTRpSRwOQwvmAxN61lKND2lOg6vTTsVTuVH0E7vw7yDfe2k DLvw== 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=w0SMbaDJ8a0kqyaBonauxqdv5qcnDIjixu1ZO1KpXNc=; b=XGxAFb5avYGxlEaXlU5BQRfcEZ2XIHfwISYOjYl7Neud4dKFGgQ+boToDQEhMJ7Chn MxWrOtkJ6twJnHk99/RE2DPBsaLuA8C0OBhBgQCDIJz+wE2sRYQFWiJOKOzL0ND03YhK 4rdaHSnBdvfnUGrlG7Tnbnfl+F30iFhU6iMYHToLzet2DUULW6Mqhr94UaY1nh5AO5NO 7tllOUcYXvfGJiS/ucU3tRh9ywQUxmvTqiy1WVuNHKtH4NET8vgPmfgu1efhlYkL5ehJ QDCBXeW8um27PqjN0edZl5ReuYTuTNXrqIMPjpkacojImBRF2WLfR/wtcWQLzX6d1r9f 7lAQ== X-Gm-Message-State: AOAM531vgMSJlfijAnZqjOvASScysY1lLGgXzhCIQ5fMvUhCC4xYXGQ+ bZzblUfIZ+0VTr7U22dI9Eo= X-Google-Smtp-Source: ABdhPJyblJPPJDQZZaIiNHqZ7gL2teuKDhjPCjSiSWTE1uPY79dD8l8ZHBLzztT28cKj7AjDNABzLQ== X-Received: by 2002:a37:a597:: with SMTP id o145mr19537356qke.265.1619645541131; Wed, 28 Apr 2021 14:32:21 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:20 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 12/13] sunrpc: provide transport info in the sysfs directory Date: Wed, 28 Apr 2021 17:32:02 -0400 Message-Id: <20210428213203.40059-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 234e545a7a40..4febc7008dc0 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -82,6 +82,55 @@ static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, return ret + 1; } +static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); + ssize_t ret; + int locked, connected, connecting, close_wait, bound, binding, + closing, congested, cwnd_wait, write_space; + + if (!xprt) + return 0; + + if (!xprt->state) { + ret = sprintf(buf, "state=CLOSED\n"); + } else { + locked = test_bit(XPRT_LOCKED, &xprt->state); + connected = test_bit(XPRT_CONNECTED, &xprt->state); + connecting = test_bit(XPRT_CONNECTING, &xprt->state); + close_wait = test_bit(XPRT_CLOSE_WAIT, &xprt->state); + bound = test_bit(XPRT_BOUND, &xprt->state); + binding = test_bit(XPRT_BINDING, &xprt->state); + closing = test_bit(XPRT_CLOSING, &xprt->state); + congested = test_bit(XPRT_CONGESTED, &xprt->state); + cwnd_wait = test_bit(XPRT_CWND_WAIT, &xprt->state); + write_space = test_bit(XPRT_WRITE_SPACE, &xprt->state); + + ret = sprintf(buf, "state=%s %s %s %s %s %s %s %s %s %s\n", + locked ? "LOCKED" : "", + connected ? "CONNECTED" : "", + connecting ? "CONNECTING" : "", + close_wait ? "CLOSE_WAIT" : "", + bound ? "BOUND" : "", + binding ? "BOUNDING" : "", + closing ? "CLOSING" : "", + congested ? "CONGESTED" : "", + cwnd_wait ? "CWND_WAIT" : "", + write_space ? "WRITE_SPACE" : ""); + } + ret += sprintf(buf + ret, "last_used=%lu\ncur_cong=%lu\ncong_win=%lu\n" + "max_num_slots=%u\nmin_num_slots=%u\nnum_reqs=%u\n" + "binding_q_len=%u\nsending_q_len=%u\npending_q_len=%u\n" + "backlog_q_len=%u\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) @@ -188,8 +237,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 Wed Apr 28 21:32:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12230071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 16BD6C433ED for ; Wed, 28 Apr 2021 21:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBF0761441 for ; Wed, 28 Apr 2021 21:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231347AbhD1VdK (ORCPT ); Wed, 28 Apr 2021 17:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbhD1VdJ (ORCPT ); Wed, 28 Apr 2021 17:33:09 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF68C06138B for ; Wed, 28 Apr 2021 14:32:23 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id z2so28212231qkb.9 for ; Wed, 28 Apr 2021 14:32:23 -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=AxvYse25p7mVDdXqMW4p7/vI14ekoXGgbKFLyeBgpMg=; b=UZI3Is3OSmFpiGlN2dBjAehltS+tJZinARLNSHuBkPnuJjrOOs7F1L1koneGvP9yB/ bOHj4MX5gm6nxfRMVQMS/CSZ028cEVWg5k4sEmWWNSnOkTXM3PheCJ8Qobsny7hX3Jsh azVf7fAn6AUPIpbJOZxfCHb27OwS4DwUL4uMYAivUQh4c+ifb9TU5VHe8RbFPBEJDEnr uqDpmOKxdi4Lo7Mnpl219/bnyEjUX2pvQfpUGpwR8mV3gRE/2RWDZwPbEZjWbhPrYb/X ePG7sQ7/3PjvTSh0u3oqeQtNDa8GEwGz0E1akf5VNgfCcA8uAfry8CD5vzVxyuUQDkMg iHNw== 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=AxvYse25p7mVDdXqMW4p7/vI14ekoXGgbKFLyeBgpMg=; b=p5FXEsdzCvW/uZkpBFBk/LJWn0/v8mjK/5MkhlJS8HGxSmObcF3Ab5ol0EJI9eoXvv HQsHmhTd5RbFcba8j7iC63EMh9eycSQiZHP0pgsDwF7r8ZzAQ626JfGbB4X3Xfiu5K3v bYaOqW3XbQBDhYRNuLOgVdtIKIejOYFvkqDWc/LUj5GphDPSeqwjB6GRCBA5sUmKZ0PS uLO/CVbCZLwFfQGDSlvLECYcLzCvmFF8GDnVWy4O6pjrk357y22foTDRfyl5oudxZk7t ZOGMMFUrm69ijN7p2ZE8HMXqWsBemVvhlP4GhFJpkZ8gHLaAvB4MwQsXDYrWah5mrfLG pBVA== X-Gm-Message-State: AOAM5307YwigtkPIBB1/SGRUBkDDFevzNrVx6IH+/hiJwy49LHNWOAFX jD/NkGUiruFi9ojf1XFHyc0xL/h7LYbTQA== X-Google-Smtp-Source: ABdhPJwnEbCY+2Ws+pNug9wpHVzDVe/gugJDEBqA6N4ore3VXugvwnfFkHmDe/DLrluAIe3ohXXBrw== X-Received: by 2002:ae9:ec0b:: with SMTP id h11mr30545682qkg.224.1619645542310; Wed, 28 Apr 2021 14:32:22 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-11.netapp.com. [216.240.30.11]) by smtp.gmail.com with ESMTPSA id v3sm710269qkb.124.2021.04.28.14.32.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Apr 2021 14:32:21 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 13/13] sunrpc: provide multipath info in the sysfs directory Date: Wed, 28 Apr 2021 17:32:03 -0400 Message-Id: <20210428213203.40059-14-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210428213203.40059-1-olga.kornievskaia@gmail.com> References: <20210428213203.40059-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 4febc7008dc0..d452c6b3fba0 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -68,6 +68,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) @@ -131,6 +140,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) @@ -246,6 +272,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, @@ -254,6 +288,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, };