diff mbox series

[net-next,1/3] SUNRPC: add netns refcount tracker to struct svc_xprt

Message ID 20220127200937.2157402-2-eric.dumazet@gmail.com (mailing list archive)
State Accepted
Commit 6cdef8a6ee748ec522aabee049633b16b4115f73
Delegated to: Netdev Maintainers
Headers show
Series SUNRPC: add some netns refcount trackers | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 10 this patch: 10
netdev/cc_maintainers warning 2 maintainers not CCed: trond.myklebust@hammerspace.com anna.schumaker@netapp.com
netdev/build_clang success Errors and warnings before: 3973 this patch: 3
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet Jan. 27, 2022, 8:09 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

struct svc_xprt holds a long lived reference to a netns,
it is worth tracking it.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/sunrpc/svc_xprt.h | 1 +
 net/sunrpc/svc_xprt.c           | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Chuck Lever Jan. 27, 2022, 8:25 p.m. UTC | #1
> On Jan 27, 2022, at 3:09 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 
> From: Eric Dumazet <edumazet@google.com>
> 
> struct svc_xprt holds a long lived reference to a netns,
> it is worth tracking it.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

I haven't followed the requirements for the extended tracking,
but I have no objection to this change.

Acked-by: Chuck Lever <chuck.lever@oracle.com>


> ---
> include/linux/sunrpc/svc_xprt.h | 1 +
> net/sunrpc/svc_xprt.c           | 4 ++--
> 2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
> index 571f605bc91ef8fa190e7fd5504efb76ec3fa89e..382af90320acc3a7b3817bf66f65fbb15447ae7d 100644
> --- a/include/linux/sunrpc/svc_xprt.h
> +++ b/include/linux/sunrpc/svc_xprt.h
> @@ -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 */
> diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> index b21ad79941474685597c9c7c07b862ef7e98ad74..db878e833b672864551bc9ef884a3cd6ca6c2603 100644
> --- a/net/sunrpc/svc_xprt.c
> +++ b/net/sunrpc/svc_xprt.c
> @@ -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);
> -- 
> 2.35.0.rc0.227.g00780c9af4-goog
> 

--
Chuck Lever
diff mbox series

Patch

diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index 571f605bc91ef8fa190e7fd5504efb76ec3fa89e..382af90320acc3a7b3817bf66f65fbb15447ae7d 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -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 */
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index b21ad79941474685597c9c7c07b862ef7e98ad74..db878e833b672864551bc9ef884a3cd6ca6c2603 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -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);