blob: c8d17b7ba60b264a7ace5ebc98f54a7d7efad92b [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
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>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050017#include <linux/gfs2_ondisk.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000018#include <asm/semaphore.h>
19
20#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050021#include "lm_interface.h"
22#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000023#include "ops_fstype.h"
24#include "sys.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050025#include "util.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000026
27/**
28 * init_gfs2_fs - Register GFS2 as a filesystem
29 *
30 * Returns: 0 on success, error code on failure
31 */
32
33static 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
Steven Whitehouse419c93e02006-03-02 16:33:41 -050067 error = register_filesystem(&gfs2meta_fs_type);
68 if (error)
69 goto fail_unregister;
70
David Teiglandb3b94fa2006-01-16 16:50:04 +000071 printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__);
72
73 return 0;
74
Steven Whitehouse419c93e02006-03-02 16:33:41 -050075fail_unregister:
76 unregister_filesystem(&gfs2_fs_type);
77fail:
David Teiglandb3b94fa2006-01-16 16:50:04 +000078 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
96static void __exit exit_gfs2_fs(void)
97{
98 unregister_filesystem(&gfs2_fs_type);
Steven Whitehouse419c93e02006-03-02 16:33:41 -050099 unregister_filesystem(&gfs2meta_fs_type);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000100
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
108MODULE_DESCRIPTION("Global File System");
109MODULE_AUTHOR("Red Hat, Inc.");
110MODULE_LICENSE("GPL");
111
112module_init(init_gfs2_fs);
113module_exit(exit_gfs2_fs);
114