Merge branch 'master'
[pandora-kernel.git] / fs / gfs2 / main.c
1 /*
2  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
3  * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
4  *
5  * This copyrighted material is made available to anyone wishing to use,
6  * modify, copy, or redistribute it subject to the terms and conditions
7  * of the GNU General Public License v.2.
8  */
9
10 #include <linux/sched.h>
11 #include <linux/slab.h>
12 #include <linux/spinlock.h>
13 #include <linux/completion.h>
14 #include <linux/buffer_head.h>
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/gfs2_ondisk.h>
18 #include <asm/semaphore.h>
19
20 #include "gfs2.h"
21 #include "lm_interface.h"
22 #include "incore.h"
23 #include "ops_fstype.h"
24 #include "sys.h"
25 #include "util.h"
26
27 /**
28  * init_gfs2_fs - Register GFS2 as a filesystem
29  *
30  * Returns: 0 on success, error code on failure
31  */
32
33 static int __init init_gfs2_fs(void)
34 {
35         int error;
36
37         gfs2_init_lmh();
38
39         error = gfs2_sys_init();
40         if (error)
41                 return error;
42
43         error = -ENOMEM;
44
45         gfs2_glock_cachep = kmem_cache_create("gfs2_glock",
46                                               sizeof(struct gfs2_glock),
47                                               0, 0, NULL, NULL);
48         if (!gfs2_glock_cachep)
49                 goto fail;
50
51         gfs2_inode_cachep = kmem_cache_create("gfs2_inode",
52                                               sizeof(struct gfs2_inode),
53                                               0, 0, NULL, NULL);
54         if (!gfs2_inode_cachep)
55                 goto fail;
56
57         gfs2_bufdata_cachep = kmem_cache_create("gfs2_bufdata",
58                                                 sizeof(struct gfs2_bufdata),
59                                                 0, 0, NULL, NULL);
60         if (!gfs2_bufdata_cachep)
61                 goto fail;
62
63         error = register_filesystem(&gfs2_fs_type);
64         if (error)
65                 goto fail;
66
67         error = register_filesystem(&gfs2meta_fs_type);
68         if (error)
69                 goto fail_unregister;
70
71         printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__);
72
73         return 0;
74
75 fail_unregister:
76         unregister_filesystem(&gfs2_fs_type);
77 fail:
78         if (gfs2_bufdata_cachep)
79                 kmem_cache_destroy(gfs2_bufdata_cachep);
80
81         if (gfs2_inode_cachep)
82                 kmem_cache_destroy(gfs2_inode_cachep);
83
84         if (gfs2_glock_cachep)
85                 kmem_cache_destroy(gfs2_glock_cachep);
86
87         gfs2_sys_uninit();
88         return error;
89 }
90
91 /**
92  * exit_gfs2_fs - Unregister the file system
93  *
94  */
95
96 static void __exit exit_gfs2_fs(void)
97 {
98         unregister_filesystem(&gfs2_fs_type);
99         unregister_filesystem(&gfs2meta_fs_type);
100
101         kmem_cache_destroy(gfs2_bufdata_cachep);
102         kmem_cache_destroy(gfs2_inode_cachep);
103         kmem_cache_destroy(gfs2_glock_cachep);
104
105         gfs2_sys_uninit();
106 }
107
108 MODULE_DESCRIPTION("Global File System");
109 MODULE_AUTHOR("Red Hat, Inc.");
110 MODULE_LICENSE("GPL");
111
112 module_init(init_gfs2_fs);
113 module_exit(exit_gfs2_fs);
114