Commit 4f499742 authored by David S. Miller's avatar David S. Miller

Merge branch 'sunrpc-netns-refcnt-tracking'

Eric Dumazet says:

====================
SUNRPC: add some netns refcount trackers

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.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 960b0033 b9a0d6d1
...@@ -88,6 +88,7 @@ struct svc_xprt { ...@@ -88,6 +88,7 @@ struct svc_xprt {
struct list_head xpt_users; /* callbacks on free */ struct list_head xpt_users; /* callbacks on free */
struct net *xpt_net; struct net *xpt_net;
netns_tracker ns_tracker;
const struct cred *xpt_cred; const struct cred *xpt_cred;
struct rpc_xprt *xpt_bc_xprt; /* NFSv4.1 backchannel */ struct rpc_xprt *xpt_bc_xprt; /* NFSv4.1 backchannel */
struct rpc_xprt_switch *xpt_bc_xps; /* NFSv4.1 backchannel */ struct rpc_xprt_switch *xpt_bc_xps; /* NFSv4.1 backchannel */
......
...@@ -284,6 +284,7 @@ struct rpc_xprt { ...@@ -284,6 +284,7 @@ struct rpc_xprt {
} stat; } stat;
struct net *xprt_net; struct net *xprt_net;
netns_tracker ns_tracker;
const char *servername; const char *servername;
const char *address_strings[RPC_DISPLAY_MAX]; const char *address_strings[RPC_DISPLAY_MAX];
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
......
...@@ -73,6 +73,7 @@ struct gss_auth { ...@@ -73,6 +73,7 @@ struct gss_auth {
enum rpc_gss_svc service; enum rpc_gss_svc service;
struct rpc_clnt *client; 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 * There are two upcall pipes; dentry[1], named "gssd", is used
* for the new text-based upcall; dentry[0] is named after the * 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) ...@@ -1013,7 +1014,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
goto err_free; goto err_free;
} }
gss_auth->client = clnt; 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; err = -EINVAL;
gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor); gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor);
if (!gss_auth->mech) if (!gss_auth->mech)
...@@ -1068,7 +1070,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) ...@@ -1068,7 +1070,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
err_put_mech: err_put_mech:
gss_mech_put(gss_auth->mech); gss_mech_put(gss_auth->mech);
err_put_net: err_put_net:
put_net(gss_auth->net); put_net_track(gss_auth->net, &gss_auth->ns_tracker);
err_free: err_free:
kfree(gss_auth->target_name); kfree(gss_auth->target_name);
kfree(gss_auth); kfree(gss_auth);
...@@ -1084,7 +1086,7 @@ gss_free(struct gss_auth *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[0]);
gss_pipe_free(gss_auth->gss_pipe[1]); gss_pipe_free(gss_auth->gss_pipe[1]);
gss_mech_put(gss_auth->mech); 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->target_name);
kfree(gss_auth); kfree(gss_auth);
......
...@@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref) ...@@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref)
if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags)) if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags))
svcauth_unix_info_release(xprt); svcauth_unix_info_release(xprt);
put_cred(xprt->xpt_cred); 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(): */ /* See comment on corresponding get in xs_setup_bc_tcp(): */
if (xprt->xpt_bc_xprt) if (xprt->xpt_bc_xprt)
xprt_put(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, ...@@ -198,7 +198,7 @@ void svc_xprt_init(struct net *net, struct svc_xprt_class *xcl,
mutex_init(&xprt->xpt_mutex); mutex_init(&xprt->xpt_mutex);
spin_lock_init(&xprt->xpt_lock); spin_lock_init(&xprt->xpt_lock);
set_bit(XPT_BUSY, &xprt->xpt_flags); 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"); strcpy(xprt->xpt_remotebuf, "uninitialized");
} }
EXPORT_SYMBOL_GPL(svc_xprt_init); EXPORT_SYMBOL_GPL(svc_xprt_init);
......
...@@ -1835,7 +1835,7 @@ EXPORT_SYMBOL_GPL(xprt_alloc); ...@@ -1835,7 +1835,7 @@ EXPORT_SYMBOL_GPL(xprt_alloc);
void xprt_free(struct rpc_xprt *xprt) 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_all_slots(xprt);
xprt_free_id(xprt); xprt_free_id(xprt);
rpc_sysfs_xprt_destroy(xprt); rpc_sysfs_xprt_destroy(xprt);
...@@ -2027,7 +2027,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net) ...@@ -2027,7 +2027,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net)
xprt_init_xid(xprt); xprt_init_xid(xprt);
xprt->xprt_net = get_net(net); xprt->xprt_net = get_net_track(net, &xprt->ns_tracker, GFP_KERNEL);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment