]> git.hungrycats.org Git - linux/commitdiff
[PATCH] PATCH 7/7: knfsd cleanups - module initialisation
authorNeil Brown <neilb@cse.unsw.edu.au>
Mon, 18 Feb 2002 00:41:08 +0000 (16:41 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Mon, 18 Feb 2002 00:41:08 +0000 (16:41 -0800)
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.

fs/nfsd/export.c
fs/nfsd/nfsctl.c

index 6eea785a309860edd69dbd5517f780c8be7de652..346d961bb297e417774cf1618a032ac7181151bd 100644 (file)
@@ -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;
index d9af7874113d67176a9307927aae3314ed7deff1..3a6f89c3bf55b84634bf1db0a14d8fdabc64e410 100644 (file)
@@ -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 @@ done:
        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);