]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nfs: add a refcount tracker for struct net as held by the nfs_client
authorJeff Layton <jlayton@kernel.org>
Tue, 8 Apr 2025 13:43:15 +0000 (09:43 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 19 May 2025 14:14:29 +0000 (10:14 -0400)
These are long-held references to the netns, so make sure the refcount
tracker is aware of them.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/client.c
include/linux/nfs_fs_sb.h

index 6d63b958c4bb1323cd6917412528720468876eac..745f3c42f140f2a3d80192f6255e41bca56889ed 100644 (file)
@@ -180,7 +180,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
        clp->cl_proto = cl_init->proto;
        clp->cl_nconnect = cl_init->nconnect;
        clp->cl_max_connect = cl_init->max_connect ? cl_init->max_connect : 1;
-       clp->cl_net = get_net(cl_init->net);
+       clp->cl_net = get_net_track(cl_init->net, &clp->cl_ns_tracker, GFP_KERNEL);
 
 #if IS_ENABLED(CONFIG_NFS_LOCALIO)
        seqlock_init(&clp->cl_boot_lock);
@@ -250,7 +250,7 @@ void nfs_free_client(struct nfs_client *clp)
        if (!IS_ERR(clp->cl_rpcclient))
                rpc_shutdown_client(clp->cl_rpcclient);
 
-       put_net(clp->cl_net);
+       put_net_track(clp->cl_net, &clp->cl_ns_tracker);
        put_nfs_version(clp->cl_nfs_mod);
        kfree(clp->cl_hostname);
        kfree(clp->cl_acceptor);
index ee03f3cef30ca5fa3295cb5ed7b0970a71b42d33..e02f4c4e9cc494b1d772e81f114dacd1fee3c00f 100644 (file)
@@ -125,6 +125,7 @@ struct nfs_client {
         */
        char                    cl_ipaddr[48];
        struct net              *cl_net;
+       netns_tracker           cl_ns_tracker;
        struct list_head        pending_cb_stateids;
        struct rcu_head         rcu;