aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-03-21 09:52:05 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-03-26 11:49:47 -0400
commit7ea34ac15e45b790f2faa7d5f69c560a43f2de70 (patch)
tree1f44c11731e76f25036042d8b41231e42348e958 /fs/nfsd
parentb3537c35c21f0e6750aa8bd786949b55509c6d0d (diff)
nfsd: add a per-net-namespace struct for nfsd
Eventually, we'll need this when nfsd gets containerized fully. For now, create a struct on a per-net-namespace basis that will just hold a pointer to the cld_net structure. That struct will hold all of the per-net data that we need for the cld tracker. Eventually we can add other pernet objects to struct nfsd_net. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/netns.h34
-rw-r--r--fs/nfsd/nfsctl.c15
2 files changed, 48 insertions, 1 deletions
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
new file mode 100644
index 000000000000..12e0cff435b4
--- /dev/null
+++ b/fs/nfsd/netns.h
@@ -0,0 +1,34 @@
1/*
2 * per net namespace data structures for nfsd
3 *
4 * Copyright (C) 2012, Jeff Layton <jlayton@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __NFSD_NETNS_H__
22#define __NFSD_NETNS_H__
23
24#include <net/net_namespace.h>
25#include <net/netns/generic.h>
26
27struct cld_net;
28
29struct nfsd_net {
30 struct cld_net *cld_net;
31};
32
33extern int nfsd_net_id;
34#endif /* __NFSD_NETNS_H__ */
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 64c24af8d7ea..141197e04703 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -19,6 +19,7 @@
19#include "nfsd.h" 19#include "nfsd.h"
20#include "cache.h" 20#include "cache.h"
21#include "fault_inject.h" 21#include "fault_inject.h"
22#include "netns.h"
22 23
23/* 24/*
24 * We have a single directory with several nodes in it. 25 * We have a single directory with several nodes in it.
@@ -1124,14 +1125,23 @@ static int create_proc_exports_entry(void)
1124} 1125}
1125#endif 1126#endif
1126 1127
1128int nfsd_net_id;
1129static struct pernet_operations nfsd_net_ops = {
1130 .id = &nfsd_net_id,
1131 .size = sizeof(struct nfsd_net),
1132};
1133
1127static int __init init_nfsd(void) 1134static int __init init_nfsd(void)
1128{ 1135{
1129 int retval; 1136 int retval;
1130 printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); 1137 printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
1131 1138
1139 retval = register_pernet_subsys(&nfsd_net_ops);
1140 if (retval < 0)
1141 return retval;
1132 retval = nfsd4_init_slabs(); 1142 retval = nfsd4_init_slabs();
1133 if (retval) 1143 if (retval)
1134 return retval; 1144 goto out_unregister_pernet;
1135 nfs4_state_init(); 1145 nfs4_state_init();
1136 retval = nfsd_fault_inject_init(); /* nfsd fault injection controls */ 1146 retval = nfsd_fault_inject_init(); /* nfsd fault injection controls */
1137 if (retval) 1147 if (retval)
@@ -1169,6 +1179,8 @@ out_free_stat:
1169 nfsd_fault_inject_cleanup(); 1179 nfsd_fault_inject_cleanup();
1170out_free_slabs: 1180out_free_slabs:
1171 nfsd4_free_slabs(); 1181 nfsd4_free_slabs();
1182out_unregister_pernet:
1183 unregister_pernet_subsys(&nfsd_net_ops);
1172 return retval; 1184 return retval;
1173} 1185}
1174 1186
@@ -1184,6 +1196,7 @@ static void __exit exit_nfsd(void)
1184 nfsd4_free_slabs(); 1196 nfsd4_free_slabs();
1185 nfsd_fault_inject_cleanup(); 1197 nfsd_fault_inject_cleanup();
1186 unregister_filesystem(&nfsd_fs_type); 1198 unregister_filesystem(&nfsd_fs_type);
1199 unregister_pernet_subsys(&nfsd_net_ops);
1187} 1200}
1188 1201
1189MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>"); 1202MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");