LINUX: split dentry eviction from osi_TryEvictVCache
[openafs.git] / src / afs / LINUX / osi_module.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * Linux module support routines.
12  *
13  */
14 #include <afsconfig.h>
15 #include "afs/param.h"
16
17
18 #include <linux/module.h> /* early to avoid printf->printk mapping */
19 #include "afs/sysincludes.h"
20 #include "afsincludes.h"
21 #include <linux/unistd.h>               /* For syscall numbers. */
22 #include <linux/mm.h>
23
24 #ifdef AFS_AMD64_LINUX20_ENV
25 #include <asm/ia32_unistd.h>
26 #endif
27
28 #include <linux/proc_fs.h>
29 #include <linux/slab.h>
30 #include <linux/init.h>
31 #include <linux/sched.h>
32 #include <linux/kernel.h>
33
34 #include "osi_pagecopy.h"
35
36 extern struct file_system_type afs_fs_type;
37
38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
39 DEFINE_MUTEX(afs_global_lock);
40 #else
41 DECLARE_MUTEX(afs_global_lock);
42 #endif
43 int afs_global_owner = 0;
44
45 #ifdef HAVE_LINUX_KUID_T
46 struct user_namespace *afs_ns;
47 #endif
48
49 int __init
50 afs_init(void)
51 {
52     int err;
53     AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
54
55 #ifdef HAVE_LINUX_KUID_T
56     afs_ns = afs_current_user_ns();
57 #endif
58
59     osi_Init();
60 #if !defined(AFS_NONFSTRANS)
61     osi_linux_nfssrv_init();
62 #endif
63
64 #ifndef LINUX_KEYRING_SUPPORT
65     err = osi_syscall_init();
66     if (err)
67         return err;
68 #endif
69     err = afs_init_inodecache();
70     if (err) {
71 #ifndef LINUX_KEYRING_SUPPORT
72         osi_syscall_clean();
73 #endif
74         return err;
75     }
76     err = register_filesystem(&afs_fs_type);
77     if (err) {
78         afs_destroy_inodecache();
79 #ifndef LINUX_KEYRING_SUPPORT
80         osi_syscall_clean();
81 #endif
82         return err;
83     }
84
85     osi_sysctl_init();
86 #ifdef LINUX_KEYRING_SUPPORT
87     osi_keyring_init();
88 #endif
89     osi_proc_init();
90     osi_ioctl_init();
91     afs_init_pagecopy();
92
93     return 0;
94 }
95
96 void __exit
97 afs_cleanup(void)
98 {
99     afs_shutdown_pagecopy();
100
101 #ifdef LINUX_KEYRING_SUPPORT
102     osi_keyring_shutdown();
103 #endif
104     osi_sysctl_clean();
105 #ifndef LINUX_KEYRING_SUPPORT
106     osi_syscall_clean();
107 #endif
108     unregister_filesystem(&afs_fs_type);
109
110     afs_destroy_inodecache();
111 #if !defined(AFS_NONFSTRANS)
112     osi_linux_nfssrv_shutdown();
113 #endif
114     shutdown_osisleep();
115     osi_linux_free_afs_memory();
116
117     osi_ioctl_clean();
118     osi_proc_clean();
119
120     return;
121 }
122
123 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
124 module_init(afs_init);
125 module_exit(afs_cleanup);
126