Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jeff Layton and committed by
J. Bruce Fields
7ea34ac1 b3537c35

+48 -1
+34
fs/nfsd/netns.h
··· 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 + 27 + struct cld_net; 28 + 29 + struct nfsd_net { 30 + struct cld_net *cld_net; 31 + }; 32 + 33 + extern int nfsd_net_id; 34 + #endif /* __NFSD_NETNS_H__ */
+14 -1
fs/nfsd/nfsctl.c
··· 19 19 #include "nfsd.h" 20 20 #include "cache.h" 21 21 #include "fault_inject.h" 22 + #include "netns.h" 22 23 23 24 /* 24 25 * We have a single directory with several nodes in it. ··· 1125 1124 } 1126 1125 #endif 1127 1126 1127 + int nfsd_net_id; 1128 + static struct pernet_operations nfsd_net_ops = { 1129 + .id = &nfsd_net_id, 1130 + .size = sizeof(struct nfsd_net), 1131 + }; 1132 + 1128 1133 static int __init init_nfsd(void) 1129 1134 { 1130 1135 int retval; 1131 1136 printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); 1132 1137 1138 + retval = register_pernet_subsys(&nfsd_net_ops); 1139 + if (retval < 0) 1140 + return retval; 1133 1141 retval = nfsd4_init_slabs(); 1134 1142 if (retval) 1135 - return retval; 1143 + goto out_unregister_pernet; 1136 1144 nfs4_state_init(); 1137 1145 retval = nfsd_fault_inject_init(); /* nfsd fault injection controls */ 1138 1146 if (retval) ··· 1179 1169 nfsd_fault_inject_cleanup(); 1180 1170 out_free_slabs: 1181 1171 nfsd4_free_slabs(); 1172 + out_unregister_pernet: 1173 + unregister_pernet_subsys(&nfsd_net_ops); 1182 1174 return retval; 1183 1175 } 1184 1176 ··· 1196 1184 nfsd4_free_slabs(); 1197 1185 nfsd_fault_inject_cleanup(); 1198 1186 unregister_filesystem(&nfsd_fs_type); 1187 + unregister_pernet_subsys(&nfsd_net_ops); 1199 1188 } 1200 1189 1201 1190 MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");