From patchwork Fri May 14 14:13:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12257859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11428C43462 for ; Fri, 14 May 2021 14:13:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEEE8613FB for ; Fri, 14 May 2021 14:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233040AbhENOOs (ORCPT ); Fri, 14 May 2021 10:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbhENOOq (ORCPT ); Fri, 14 May 2021 10:14:46 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E4FC06174A for ; Fri, 14 May 2021 07:13:34 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id l21so28238913iob.1 for ; Fri, 14 May 2021 07:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ByxcRK0X7LDOD9Y3obRLp+xASbAfhFDXxLUR/4WR2yU=; b=MWWJvyv9rucQOyMrpWlkZRuMp/fib+Lg7KjH1lwBHG/uYaTk4DKGIqCXWqLu8S3NR3 DSPaiYL7h2gD2q+2Mp1NyErh3xpFUGaVGan39/+dbvmt6dgRg6LOd8WRdhYrb1nXTppv q9b6QxDeao4lj1Jn5aiHP8KtBdF5eUr0LfV473E9Gez0bCP98zsI1E/w8TJ5T0a4Mr2e /jCIQMr78XUK5cUzlpCdGDOxfmifeD4P9oltek2nywGWGUraEbZ8kCsQbblVIK9MeFP/ sNWv9TzBq7fQuLAzqmJsL0gw3BPXeZvOQZPR4ERcaDmzFb6AU1dsmWRRHzUBPFz026kY r2+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ByxcRK0X7LDOD9Y3obRLp+xASbAfhFDXxLUR/4WR2yU=; b=V9+NzSiVOrBcnyHYhSGVVGxvGyl/U3TYL207xjmt3VHAhggFGnci1DBv3JS4fVHe07 0CyOMfQ3M8iNKQke+2iEtyHpyDlUrkF0PzC4ykq1vnRoSANPBH/N3AEx6tcZKkuxwU8+ JYFXQxBG43GMnWHF6164sqer//JCp+Y1Yyf2qGBdOV/vFtCiKPAWfxDnLPdqngIoE0Ob tDpFNQNWcYLYAX4OgKLVynsgpiAgf1B/129w19CV+MPCQbsmWtKze+OPlkOPmUxB+23c 7fUCCs9bFnvq1qoTGVvTTs2FREsO7866T/BFDdnGicoeAiBCCNuDk5fCZLSipHds1P3c m35A== X-Gm-Message-State: AOAM533h6FrbSGWxoVomJG8KxCp36i+WhqAt8gG3ti+cEIm+qZvezHu5 PDyJToE4BwRuyE3mve3IUhM= X-Google-Smtp-Source: ABdhPJzF3qohLKgLs1DTb/ikbAngLKCwsfvFg3Y4PJ3LPXUBZnBR9mdeXRjj9Yp3hHWxRwjkfpf1Zw== X-Received: by 2002:a02:ba08:: with SMTP id z8mr2202203jan.74.1621001614190; Fri, 14 May 2021 07:13:34 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:a4f7:32c8:9c05:11a7]) by smtp.gmail.com with ESMTPSA id b189sm2639263iof.48.2021.05.14.07.13.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 May 2021 07:13:33 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v7 08/12] sunrpc: add a symlink from rpc-client directory to the xprt_switch Date: Fri, 14 May 2021 10:13:19 -0400 Message-Id: <20210514141323.67922-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210514141323.67922-1-olga.kornievskaia@gmail.com> References: <20210514141323.67922-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia An rpc client uses a transport switch and one ore more transports associated with that switch. Since transports are shared among rpc clients, create a symlink into the xprt_switch directory instead of duplicating entries under each rpc client. Signed-off-by: Olga Kornievskaia --- net/sunrpc/clnt.c | 2 +- net/sunrpc/sysfs.c | 22 ++++++++++++++++++++-- net/sunrpc/sysfs.h | 6 +++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index ec9254a11a03..277db7fd0fcd 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -301,7 +301,6 @@ static int rpc_client_register(struct rpc_clnt *clnt, int err; rpc_clnt_debugfs_register(clnt); - rpc_sysfs_client_setup(clnt, net); pipefs_sb = rpc_get_sb_net(net); if (pipefs_sb) { @@ -426,6 +425,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, /* save the nodename */ rpc_clnt_set_nodename(clnt, nodename); + rpc_sysfs_client_setup(clnt, xps, rpc_net_ns(clnt)); err = rpc_client_register(clnt, args->authflavor, args->client_name); if (err) goto out_no_path; diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index ed9f7131543f..0aa63747f496 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -151,14 +151,29 @@ rpc_sysfs_xprt_switch_alloc(struct kobject *parent, return NULL; } -void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net) +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, + struct rpc_xprt_switch *xprt_switch, + struct net *net) { struct rpc_sysfs_client *rpc_client; - rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, net, clnt->cl_clid); + rpc_client = rpc_sysfs_client_alloc(rpc_sunrpc_client_kobj, + net, clnt->cl_clid); if (rpc_client) { + char name[] = "switch"; + struct rpc_sysfs_xprt_switch *xswitch = + (struct rpc_sysfs_xprt_switch *)xprt_switch->xps_sysfs; + int ret; + clnt->cl_sysfs = rpc_client; + rpc_client->clnt = clnt; + rpc_client->xprt_switch = xprt_switch; kobject_uevent(&rpc_client->kobject, KOBJ_ADD); + ret = sysfs_create_link_nowarn(&rpc_client->kobject, + &xswitch->kobject, name); + if (ret) + pr_warn("can't create link to %s in sysfs (%d)\n", + name, ret); } } @@ -189,6 +204,9 @@ void rpc_sysfs_client_destroy(struct rpc_clnt *clnt) struct rpc_sysfs_client *rpc_client = clnt->cl_sysfs; if (rpc_client) { + char name[] = "switch"; + + sysfs_remove_link(&rpc_client->kobject, name); kobject_uevent(&rpc_client->kobject, KOBJ_REMOVE); kobject_del(&rpc_client->kobject); kobject_put(&rpc_client->kobject); diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h index 52ec472bd4a9..760f0582aee5 100644 --- a/net/sunrpc/sysfs.h +++ b/net/sunrpc/sysfs.h @@ -8,6 +8,8 @@ struct rpc_sysfs_client { struct kobject kobject; struct net *net; + struct rpc_clnt *clnt; + struct rpc_xprt_switch *xprt_switch; }; struct rpc_sysfs_xprt_switch { @@ -20,7 +22,9 @@ struct rpc_sysfs_xprt_switch { int rpc_sysfs_init(void); void rpc_sysfs_exit(void); -void rpc_sysfs_client_setup(struct rpc_clnt *clnt, struct net *net); +void rpc_sysfs_client_setup(struct rpc_clnt *clnt, + struct rpc_xprt_switch *xprt_switch, + struct net *net); void rpc_sysfs_client_destroy(struct rpc_clnt *clnt); void rpc_sysfs_xprt_switch_setup(struct rpc_xprt_switch *xprt_switch, struct rpc_xprt *xprt, gfp_t gfp_flags);