Skip to content

Commit 2c830dd

Browse files
author
J. Bruce Fields
committed
nfsd: persist nfsd filesystem across mounts
Keep around one internal mount of the nfsd filesystem so that we can add stuff to it when clients come and go, regardless of whether anyone has it mounted. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 855c9e7 commit 2c830dd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

fs/nfsd/netns.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ struct nfsd_net {
4242
bool grace_ended;
4343
time_t boot_time;
4444

45+
/* internal mount of the "nfsd" pseudofilesystem: */
46+
struct vfsmount *nfsd_mnt;
47+
4548
/*
4649
* reclaim_str_hashtbl[] holds known client info from previous reset/reboot
4750
* used in reboot/reset lease grace period processing

fs/nfsd/nfsctl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,7 @@ unsigned int nfsd_net_id;
12321232
static __net_init int nfsd_init_net(struct net *net)
12331233
{
12341234
int retval;
1235+
struct vfsmount *mnt;
12351236
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
12361237

12371238
retval = nfsd_export_init(net);
@@ -1255,8 +1256,17 @@ static __net_init int nfsd_init_net(struct net *net)
12551256

12561257
atomic_set(&nn->ntf_refcnt, 0);
12571258
init_waitqueue_head(&nn->ntf_wq);
1259+
1260+
mnt = vfs_kern_mount(&nfsd_fs_type, SB_KERNMOUNT, "nfsd", NULL);
1261+
if (IS_ERR(mnt)) {
1262+
retval = PTR_ERR(mnt);
1263+
goto out_mount_err;
1264+
}
1265+
nn->nfsd_mnt = mnt;
12581266
return 0;
12591267

1268+
out_mount_err:
1269+
nfsd_reply_cache_shutdown(nn);
12601270
out_drc_error:
12611271
nfsd_idmap_shutdown(net);
12621272
out_idmap_error:
@@ -1269,6 +1279,7 @@ static __net_exit void nfsd_exit_net(struct net *net)
12691279
{
12701280
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
12711281

1282+
mntput(nn->nfsd_mnt);
12721283
nfsd_reply_cache_shutdown(nn);
12731284
nfsd_idmap_shutdown(net);
12741285
nfsd_export_shutdown(net);

0 commit comments

Comments
 (0)