Commit c0d68f59 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] PATCH 7/7: knfsd cleanups - module initialisation

Tidyup init/exit for nfsd module

move nfsd_init into an initcall with other module
startup.  This means that "initialized" isn't needed for
any of the files that use it, as the bits are always initialised if
in use.
parent ff820210
......@@ -59,7 +59,6 @@ struct svc_clnthash {
};
static struct svc_clnthash * clnt_hash[CLIENT_HASHMAX];
static svc_client * clients;
static int initialized;
static int hash_lock;
static int want_lock;
......@@ -473,9 +472,6 @@ exp_getclient(struct sockaddr_in *sin)
struct svc_clnthash **hp, **head, *tmp;
unsigned long addr = sin->sin_addr.s_addr;
if (!initialized)
return NULL;
head = &clnt_hash[CLIENT_HASH(addr)];
for (hp = head; (tmp = *hp) != NULL; hp = &(tmp->h_next)) {
......@@ -872,13 +868,11 @@ nfsd_export_init(void)
int i;
dprintk("nfsd: initializing export module.\n");
if (initialized)
return;
for (i = 0; i < CLIENT_HASHMAX; i++)
clnt_hash[i] = NULL;
clients = NULL;
initialized = 1;
}
/*
......@@ -890,8 +884,7 @@ nfsd_export_shutdown(void)
int i;
dprintk("nfsd: shutting down export module.\n");
if (!initialized)
return;
if (exp_writelock() < 0) {
printk(KERN_WARNING "Weird: hashtable locked in exp_shutdown");
return;
......
......@@ -44,8 +44,6 @@ static int nfsctl_getfs(struct nfsctl_fsparm *, struct knfsd_fh *);
static int nfsctl_ugidupdate(struct nfsctl_ugidmap *data);
#endif
static int initialized;
extern struct seq_operations nfs_exports_op;
static int exports_open(struct inode *inode, struct file *file)
{
......@@ -68,20 +66,6 @@ void proc_export_init(void)
entry->proc_fops = &exports_operations;
}
/*
* Initialize nfsd
*/
static void
nfsd_init(void)
{
nfsd_stat_init(); /* Statistics */
nfsd_cache_init(); /* RPC reply cache */
nfsd_export_init(); /* Exports table */
nfsd_lockd_init(); /* lockd->nfsd callbacks */
proc_export_init();
initialized = 1;
}
static inline int
nfsctl_svc(struct nfsctl_svc *data)
{
......@@ -204,8 +188,7 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp)
int argsize, respsize;
lock_kernel ();
if (!initialized)
nfsd_init();
err = -EPERM;
if (!capable(CAP_SYS_ADMIN)) {
goto done;
......@@ -278,35 +261,44 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp)
return err;
}
#ifdef MODULE
/* New-style module support since 2.1.18 */
EXPORT_NO_SYMBOLS;
MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
MODULE_LICENSE("GPL");
#ifdef MODULE
struct nfsd_linkage nfsd_linkage_s = {
do_nfsservctl: handle_sys_nfsservctl,
owner: THIS_MODULE,
};
#endif
/*
* Initialize the module
*/
int
init_module(void)
static int __init
nfsd_init(void)
{
printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
#ifdef MODULE
nfsd_linkage = &nfsd_linkage_s;
#endif
nfsd_stat_init(); /* Statistics */
nfsd_cache_init(); /* RPC reply cache */
nfsd_export_init(); /* Exports table */
nfsd_lockd_init(); /* lockd->nfsd callbacks */
proc_export_init();
return 0;
}
/*
* Clean up the mess before unloading the module
*/
void
cleanup_module(void)
static void __exit
nfsd_exit(void)
{
#ifdef MODULE
nfsd_linkage = NULL;
#endif
nfsd_export_shutdown();
nfsd_cache_shutdown();
remove_proc_entry("fs/nfs/exports", NULL);
......@@ -314,4 +306,6 @@ cleanup_module(void)
nfsd_stat_shutdown();
nfsd_lockd_shutdown();
}
#endif
module_init(nfsd_init);
module_exit(nfsd_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment