From: Trond Myklebust <trondmy@hammerspace.com>
To: "anna.schumaker@netapp.com" <anna.schumaker@netapp.com>,
"olga.kornievskaia@gmail.com" <olga.kornievskaia@gmail.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v2 06/13] sunrpc: add IDs to multipath
Date: Fri, 23 Apr 2021 21:16:57 +0000 [thread overview]
Message-ID: <ffecdfb0ce5a488bc770e0535dc66c54cc095f47.camel@hammerspace.com> (raw)
In-Reply-To: <20210416035226.53588-7-olga.kornievskaia@gmail.com>
On Thu, 2021-04-15 at 23:52 -0400, Olga Kornievskaia wrote:
> From: Olga Kornievskaia <kolga@netapp.com>
>
> This is used to uniquely identify sunrpc multipath objects in /sys.
>
> Signed-off-by: Dan Aloni <dan@kernelim.com>
> ---
> include/linux/sunrpc/xprtmultipath.h | 4 ++++
> net/sunrpc/sunrpc_syms.c | 1 +
> net/sunrpc/xprtmultipath.c | 26 ++++++++++++++++++++++++++
> 3 files changed, 31 insertions(+)
>
> diff --git a/include/linux/sunrpc/xprtmultipath.h
> b/include/linux/sunrpc/xprtmultipath.h
> index c6cce3fbf29d..ef95a6f18ccf 100644
> --- a/include/linux/sunrpc/xprtmultipath.h
> +++ b/include/linux/sunrpc/xprtmultipath.h
> @@ -14,6 +14,7 @@ struct rpc_xprt_switch {
> spinlock_t xps_lock;
> struct kref xps_kref;
>
> + unsigned int xps_id;
> unsigned int xps_nxprts;
> unsigned int xps_nactive;
> atomic_long_t xps_queuelen;
> @@ -71,4 +72,7 @@ extern struct rpc_xprt *xprt_iter_get_next(struct
> rpc_xprt_iter *xpi);
>
> extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
> const struct sockaddr *sap);
> +
> +extern void xprt_multipath_cleanup_ids(void);
> +
> #endif
> diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
> index b61b74c00483..691c0000e9ea 100644
> --- a/net/sunrpc/sunrpc_syms.c
> +++ b/net/sunrpc/sunrpc_syms.c
> @@ -134,6 +134,7 @@ cleanup_sunrpc(void)
> rpc_sysfs_exit();
> rpc_cleanup_clids();
> xprt_cleanup_ids();
> + xprt_multipath_cleanup_ids();
> rpcauth_remove_module();
> cleanup_socket_xprt();
> svc_cleanup_xprt_sock();
> diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c
> index 78c075a68c04..b71dd95ad7de 100644
> --- a/net/sunrpc/xprtmultipath.c
> +++ b/net/sunrpc/xprtmultipath.c
> @@ -86,6 +86,30 @@ void rpc_xprt_switch_remove_xprt(struct
> rpc_xprt_switch *xps,
> xprt_put(xprt);
> }
>
> +static DEFINE_IDA(rpc_xprtswitch_ids);
> +
> +void xprt_multipath_cleanup_ids(void)
> +{
> + ida_destroy(&rpc_xprtswitch_ids);
> +}
> +
> +static int xprt_switch_alloc_id(struct rpc_xprt_switch *xps)
> +{
> + int id;
> +
> + id = ida_simple_get(&rpc_xprtswitch_ids, 0, 0, GFP_KERNEL);
This really needs to use the same allocation mode as the caller in
xprt_switch_alloc()
> + if (id < 0)
> + return id;
> +
> + xps->xps_id = id;
> + return 0;
> +}
> +
> +static void xprt_switch_free_id(struct rpc_xprt_switch *xps)
> +{
> + ida_simple_remove(&rpc_xprtswitch_ids, xps->xps_id);
> +}
> +
> /**
> * xprt_switch_alloc - Allocate a new struct rpc_xprt_switch
> * @xprt: pointer to struct rpc_xprt
> @@ -103,6 +127,7 @@ struct rpc_xprt_switch *xprt_switch_alloc(struct
> rpc_xprt *xprt,
> if (xps != NULL) {
> spin_lock_init(&xps->xps_lock);
> kref_init(&xps->xps_kref);
> + xprt_switch_alloc_id(xps);
> xps->xps_nxprts = xps->xps_nactive = 0;
> atomic_long_set(&xps->xps_queuelen, 0);
> xps->xps_net = NULL;
> @@ -136,6 +161,7 @@ static void xprt_switch_free(struct kref *kref)
> struct rpc_xprt_switch, xps_kref);
>
> xprt_switch_free_entries(xps);
> + xprt_switch_free_id(xps);
> kfree_rcu(xps, xps_rcu);
> }
>
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2021-04-23 21:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-16 3:52 [PATCH v2 00/13] create sysfs files for changing IP address Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 01/13] sunrpc: Create a sunrpc directory under /sys/kernel/ Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 02/13] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 03/13] sunrpc: Create per-rpc_clnt sysfs kobjects Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 04/13] sunrpc: Prepare xs_connect() for taking NULL tasks Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 05/13] sunrpc: add xprt id Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 06/13] sunrpc: add IDs to multipath Olga Kornievskaia
2021-04-23 21:16 ` Trond Myklebust [this message]
2021-04-16 3:52 ` [PATCH v2 07/13] sunrpc: keep track of the xprt_class in rpc_xprt structure Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 08/13] sunrpc: add xprt_switch direcotry to sunrpc's sysfs Olga Kornievskaia
2021-04-23 21:20 ` Trond Myklebust
2021-04-26 15:30 ` Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 09/13] sunrpc: add a symlink from rpc-client directory to the xprt_switch Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 10/13] sunrpc: add add sysfs directory per xprt under each xprt_switch Olga Kornievskaia
2021-04-23 21:21 ` Trond Myklebust
2021-04-16 3:52 ` [PATCH v2 11/13] sunrpc: add dst_attr attributes to the sysfs xprt directory Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 12/13] sunrpc: provide transport info in the sysfs directory Olga Kornievskaia
2021-04-16 3:52 ` [PATCH v2 13/13] sunrpc: provide multipath " Olga Kornievskaia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffecdfb0ce5a488bc770e0535dc66c54cc095f47.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=anna.schumaker@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=olga.kornievskaia@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).