Skip to content

Commit e529663

Browse files
jtlaytonAnna Schumaker
authored andcommitted
nfs: add a refcount tracker for struct net as held by the nfs_client
These are long-held references to the netns, so make sure the refcount tracker is aware of them. Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent fadc0f3 commit e529663

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

fs/nfs/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
180180
clp->cl_proto = cl_init->proto;
181181
clp->cl_nconnect = cl_init->nconnect;
182182
clp->cl_max_connect = cl_init->max_connect ? cl_init->max_connect : 1;
183-
clp->cl_net = get_net(cl_init->net);
183+
clp->cl_net = get_net_track(cl_init->net, &clp->cl_ns_tracker, GFP_KERNEL);
184184

185185
#if IS_ENABLED(CONFIG_NFS_LOCALIO)
186186
seqlock_init(&clp->cl_boot_lock);
@@ -250,7 +250,7 @@ void nfs_free_client(struct nfs_client *clp)
250250
if (!IS_ERR(clp->cl_rpcclient))
251251
rpc_shutdown_client(clp->cl_rpcclient);
252252

253-
put_net(clp->cl_net);
253+
put_net_track(clp->cl_net, &clp->cl_ns_tracker);
254254
put_nfs_version(clp->cl_nfs_mod);
255255
kfree(clp->cl_hostname);
256256
kfree(clp->cl_acceptor);

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct nfs_client {
125125
*/
126126
char cl_ipaddr[48];
127127
struct net *cl_net;
128+
netns_tracker cl_ns_tracker;
128129
struct list_head pending_cb_stateids;
129130
struct rcu_head rcu;
130131

0 commit comments

Comments
 (0)