SUNRPC: add netns refcount tracker to struct rpc_xprt
authorEric Dumazet <edumazet@google.com>
Thu, 27 Jan 2022 20:09:37 +0000 (12:09 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Jan 2022 14:47:55 +0000 (14:47 +0000)
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/sunrpc/xprt.h
net/sunrpc/xprt.c

index 955ea4d..3cdc8d8 100644 (file)
@@ -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)
index a02de2b..5af484d 100644 (file)
@@ -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);
 }
 
 /**