[PATCH net-next 14/17] vfs: add netns refcount tracker to struct fs_context
flat view
STALE1779d
From: Eric Dumazet <hidden>
Date: 2021-12-07 00:52:15
Subsystem:
afs filesystem, filesystems (vfs and infrastructure), nfs, sunrpc, and lockd clients, the rest · Maintainers:
David Howells, Marc Dionne, Alexander Viro, Christian Brauner, Trond Myklebust, Anna Schumaker, Linus Torvalds
From: Eric Dumazet <redacted> Signed-off-by: Eric Dumazet <redacted> --- fs/afs/mntpt.c | 5 +++-- fs/fs_context.c | 7 ++++--- fs/nfs/fs_context.c | 5 +++-- fs/nfs/namespace.c | 5 +++-- include/linux/fs_context.h | 2 ++ 5 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index bbb2c210d139d9033e83e39f0c4778de83afc694..c67474607604cc8096cfe343893994fe4153ffb4 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c@@ -78,8 +78,9 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt) int ret; if (fc->net_ns != src_as->net_ns) { - put_net(fc->net_ns); - fc->net_ns = get_net(src_as->net_ns); + put_net_track(fc->net_ns, &fc->ns_tracker); + fc->net_ns = get_net_track(src_as->net_ns, &fc->ns_tracker, + GFP_KERNEL); } if (src_as->volume && src_as->volume->type == AFSVL_RWVOL) {
diff --git a/fs/fs_context.c b/fs/fs_context.c
index b7e43a780a625bca1b0faeba53e2702463ad0496..06ece7c4b4c295cd1d918378597a23ac3a3cb13e 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c@@ -263,7 +263,8 @@ static struct fs_context *alloc_fs_context(struct file_system_type *fs_type, fc->sb_flags_mask = sb_flags_mask; fc->fs_type = get_filesystem(fs_type); fc->cred = get_current_cred(); - fc->net_ns = get_net(current->nsproxy->net_ns); + fc->net_ns = get_net_track(current->nsproxy->net_ns, + &fc->ns_tracker, GFP_KERNEL); fc->log.prefix = fs_type->name; mutex_init(&fc->uapi_mutex);
@@ -355,7 +356,7 @@ struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc) fc->source = NULL; fc->security = NULL; get_filesystem(fc->fs_type); - get_net(fc->net_ns); + get_net_track(fc->net_ns, &fc->ns_tracker, GFP_KERNEL); get_user_ns(fc->user_ns); get_cred(fc->cred); if (fc->log.log)
@@ -469,7 +470,7 @@ void put_fs_context(struct fs_context *fc) fc->ops->free(fc); security_free_mnt_opts(&fc->security); - put_net(fc->net_ns); + put_net_track(fc->net_ns, &fc->ns_tracker); put_user_ns(fc->user_ns); put_cred(fc->cred); put_fc_log(fc);
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 0d444a90f513a9fa6d2cef1748a7218575a38d84..ea0bd82a29ecb498d995ef74b1a4c0fc1832116d 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c@@ -1531,8 +1531,9 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->nfs_server.addrlen); if (fc->net_ns != net) { - put_net(fc->net_ns); - fc->net_ns = get_net(net); + put_net_track(fc->net_ns, &fc->ns_tracker); + fc->net_ns = get_net_track(net, &fc->ns_tracker, + GFP_KERNEL); } ctx->nfs_mod = nfss->nfs_client->cl_nfs_mod;
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 3295af4110f1b1c5890f110c3d49424a3d19406f..8c630907d1eff2f7199d32d6becee4c10259473d 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c@@ -170,8 +170,9 @@ struct vfsmount *nfs_d_automount(struct path *path) goto out_fc; if (fc->net_ns != client->cl_net) { - put_net(fc->net_ns); - fc->net_ns = get_net(client->cl_net); + put_net_track(fc->net_ns, &fc->ns_tracker); + fc->net_ns = get_net_track(client->cl_net, + &fc->ns_tracker, GFP_KERNEL); } /* for submounts we want the same server; referrals will reassign */
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index 6b54982fc5f378ec704f56def2fdb299e7d8b42d..9099bf7769c6db04b649d319502aec1b17d3d236 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h@@ -13,6 +13,7 @@ #include <linux/errno.h> #include <linux/security.h> #include <linux/mutex.h> +#include <net/net_trackers.h> struct cred; struct dentry;
@@ -96,6 +97,7 @@ struct fs_context { struct dentry *root; /* The root and superblock */ struct user_namespace *user_ns; /* The user namespace for this mount */ struct net *net_ns; /* The network namespace for this mount */ + netns_tracker ns_tracker; /* Tracker for @net_ns reference */ const struct cred *cred; /* The mounter's credentials */ struct p_log log; /* Logging buffer */ const char *source; /* The source name (eg. dev path) */
--
2.34.1.400.ga245620fadb-goog