SUNRPC: add some netns refcount trackers
Subsystems (4)
cover SUNRPC: add some netns refcount trackers
From: Eric Dumazet <[email protected]>
Effort started in linux-5.17
Our goal is to replace get_net()/put_net() pairs with get_net_track()/put_net_track() to get instant notifications of imbalance bugs in the future.
Patches were split from a bigger series sent one month ago.
Eric Dumazet (3):
SUNRPC: add netns refcount tracker to struct svc_xprt
SUNRPC: add netns refcount tracker to struct gss_auth
SUNRPC: add netns refcount tracker to struct rpc_xprt
include/linux/sunrpc/svc_xprt.h | 1 + include/linux/sunrpc/xprt.h | 1 + net/sunrpc/auth_gss/auth_gss.c | 10 ++++++---- net/sunrpc/svc_xprt.c | 4 ++-- net/sunrpc/xprt.c | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-)
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 1/3 SUNRPC: add netns refcount tracker to struct svc_xprt
From: Eric Dumazet <[email protected]>
struct svc_xprt holds a long lived reference to a netns, it is worth tracking it.
--- include/linux/sunrpc/svc_xprt.h | 1 + net/sunrpc/svc_xprt.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
include/linux/sunrpc/svc_xprt.h +1 -0
@@ -88,6 +88,7 @@ struct svc_xprt {struct list_head xpt_users;/* callbacks on free */ struct net *xpt_net; +netns_tracker ns_tracker;const struct cred *xpt_cred;struct rpc_xprt *xpt_bc_xprt;/* NFSv4.1 backchannel */ struct rpc_xprt_switch *xpt_bc_xps;/* NFSv4.1 backchannel */
net/sunrpc/svc_xprt.c +2 -2
@@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref)if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags))svcauth_unix_info_release (xprt);put_cred (xprt->xpt_cred); -put_net (xprt->xpt_net); +put_net_track (xprt->xpt_net, &xprt->ns_tracker);/* See comment on corresponding get in xs_setup_bc_tcp(): */ if (xprt->xpt_bc_xprt)xprt_put (xprt->xpt_bc_xprt);
@@ -198,7 +198,7 @@ void svc_xprt_init(struct net *net, struct svc_xprt_class *xcl,mutex_init (&xprt->xpt_mutex);spin_lock_init (&xprt->xpt_lock);set_bit (XPT_BUSY , &xprt->xpt_flags); - xprt->xpt_net =get_net (net); + xprt->xpt_net =get_net_track (net, &xprt->ns_tracker,GFP_ATOMIC );strcpy (xprt->xpt_remotebuf,"uninitialized" ); }EXPORT_SYMBOL_GPL (svc_xprt_init);
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
Re: [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt
Quoted 10 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
struct
svc_xprtholds a long lived reference to a netns, it is worth tracking it.Signed-off-by Eric Dumazet <[email protected]>
I haven't followed the requirements for the extended tracking, but I have no objection to this change.
Quoted 42 lines
---
include/linux/sunrpc/svc_xprt.h| 1 +net/sunrpc/svc_xprt.c| 4 ++--2 files changed, 3 insertions(+), 2 deletions(-)include/linux/sunrpc/svc_xprt.h +1
-0@@ -88,6 +88,7 @@ struct svc_xprt {struct list_head xpt_users;/* callbacks on free */ struct net *xpt_net; +netns_tracker ns_tracker;const struct cred *xpt_cred;struct rpc_xprt *xpt_bc_xprt;/* NFSv4.1 backchannel */ struct rpc_xprt_switch *xpt_bc_xps;/* NFSv4.1 backchannel */ net/sunrpc/svc_xprt.c +2
-2@@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref)if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags))svcauth_unix_info_release (xprt);put_cred (xprt->xpt_cred); -put_net (xprt->xpt_net); +put_net_track (xprt->xpt_net, &xprt->ns_tracker);/* See comment on corresponding get in xs_setup_bc_tcp(): */ if (xprt->xpt_bc_xprt)xprt_put (xprt->xpt_bc_xprt);@@ -198,7 +198,7 @@ void svc_xprt_init(struct net *net, struct svc_xprt_class *xcl,mutex_init (&xprt->xpt_mutex);spin_lock_init (&xprt->xpt_lock);set_bit (XPT_BUSY , &xprt->xpt_flags); - xprt->xpt_net =get_net (net); + xprt->xpt_net =get_net_track (net, &xprt->ns_tracker,GFP_ATOMIC );strcpy (xprt->xpt_remotebuf,"uninitialized" ); }EXPORT_SYMBOL_GPL (svc_xprt_init);Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
--
Chuck Lever
PATCH 2/3 SUNRPC: add netns refcount tracker to struct gss_auth
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- net/sunrpc/auth_gss/auth_gss.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/sunrpc/auth_gss/auth_gss.c +6 -4
@@ -72,7 +72,8 @@ struct gss_auth {struct gss_api_mech *mech;enum rpc_gss_svc service;struct rpc_clnt *client; -struct net *net; +struct net *net; +netns_tracker ns_tracker;/* * There are two upcall pipes; dentry[1], named "gssd", is used * for the new text-based upcall; dentry[0] is named after the
@@ -1013,7 +1014,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) goto err_free; } gss_auth->client = clnt; - gss_auth->net =get_net (rpc_net_ns (clnt)); + gss_auth->net =get_net_track (rpc_net_ns (clnt), &gss_auth->ns_tracker, +GFP_KERNEL ); err = -EINVAL ; gss_auth->mech =gss_mech_get_by_pseudoflavor (flavor);if (!gss_auth->mech)
@@ -1068,7 +1070,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) err_put_mech:gss_mech_put (gss_auth->mech); err_put_net: -put_net (gss_auth->net); +put_net_track (gss_auth->net, &gss_auth->ns_tracker); err_free:kfree (gss_auth->target_name);kfree (gss_auth);
@@ -1084,7 +1086,7 @@ gss_free(struct gss_auth *gss_auth)gss_pipe_free (gss_auth->gss_pipe[0 ]);gss_pipe_free (gss_auth->gss_pipe[1 ]);gss_mech_put (gss_auth->mech); -put_net (gss_auth->net); +put_net_track (gss_auth->net, &gss_auth->ns_tracker);kfree (gss_auth->target_name);kfree (gss_auth);
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 3/3 SUNRPC: add netns refcount tracker to struct rpc_xprt
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
--- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprt.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -284,6 +284,7 @@ struct rpc_xprt { } stat;struct net *xprt_net; +netns_tracker ns_tracker;const char *servername;const char *address_strings[RPC_DISPLAY_MAX ];#if IS_ENABLED (CONFIG_SUNRPC_DEBUG )
net/sunrpc/xprt.c +2 -2
@@ -1835,7 +1835,7 @@ EXPORT_SYMBOL_GPL(xprt_alloc);void xprt_free (struct rpc_xprt *xprt) { -put_net (xprt->xprt_net); +put_net_track (xprt->xprt_net, &xprt->ns_tracker);xprt_free_all_slots (xprt);xprt_free_id (xprt);rpc_sysfs_xprt_destroy (xprt);
@@ -2027,7 +2027,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net)xprt_init_xid (xprt); - xprt->xprt_net =get_net (net); + xprt->xprt_net =get_net_track (net, &xprt->ns_tracker,GFP_KERNEL ); }/**
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 9 lines · On Thu, 27 Jan 2022 12:09:34 -0800 you wrote:
From: Eric Dumazet <[email protected]>
Effort started in linux-5.17
Our goal is to replace get_net()/put_net() pairs with get_net_track()/put_net_track() to get instant notifications of imbalance bugs in the future.
[...]
Here is the summary with links:
- [net-next,1/3] SUNRPC: add netns refcount tracker to struct svc_xprt
https://git.kernel.org/netdev/net-next/c/6cdef8a6ee74 - [net-next,2/3] SUNRPC: add netns refcount tracker to struct gss_auth https://git.kernel.org/netdev/net-next/c/9b1831e56c7f - [net-next,3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt https://git.kernel.org/netdev/net-next/c/b9a0d6d143ec
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html