Blame view

fs/gfs2/main.c 3.65 KB
b3b94faa5   David Teigland   [GFS2] The core o...
1
2
  /*
   * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
3a8a9a103   Steven Whitehouse   [GFS2] Update cop...
3
   * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
b3b94faa5   David Teigland   [GFS2] The core o...
4
5
6
   *
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
e9fc2aa09   Steven Whitehouse   [GFS2] Update cop...
7
   * of the GNU General Public License version 2.
b3b94faa5   David Teigland   [GFS2] The core o...
8
   */
b3b94faa5   David Teigland   [GFS2] The core o...
9
10
11
12
13
14
  #include <linux/slab.h>
  #include <linux/spinlock.h>
  #include <linux/completion.h>
  #include <linux/buffer_head.h>
  #include <linux/module.h>
  #include <linux/init.h>
5c676f6d3   Steven Whitehouse   [GFS2] Macros rem...
15
  #include <linux/gfs2_ondisk.h>
7d308590a   Fabio Massimo Di Nitto   [GFS2] Export lm_...
16
  #include <linux/lm_interface.h>
ec45d9f58   Steven Whitehouse   [GFS2] Use slab p...
17
  #include <asm/atomic.h>
b3b94faa5   David Teigland   [GFS2] The core o...
18
19
  
  #include "gfs2.h"
5c676f6d3   Steven Whitehouse   [GFS2] Macros rem...
20
  #include "incore.h"
b27605837   Steven Whitehouse   GFS2: Rationalise...
21
  #include "super.h"
b3b94faa5   David Teigland   [GFS2] The core o...
22
  #include "sys.h"
5c676f6d3   Steven Whitehouse   [GFS2] Macros rem...
23
  #include "util.h"
85d1da67f   Steven Whitehouse   [GFS2] Move glock...
24
  #include "glock.h"
b3b94faa5   David Teigland   [GFS2] The core o...
25

51cc50685   Alexey Dobriyan   SL*B: drop kmem c...
26
  static void gfs2_init_inode_once(void *foo)
320dd101e   Steven Whitehouse   [GFS2] glock debu...
27
28
  {
  	struct gfs2_inode *ip = foo;
a35afb830   Christoph Lameter   Remove SLAB_CTOR_...
29
30
  
  	inode_init_once(&ip->i_inode);
a35afb830   Christoph Lameter   Remove SLAB_CTOR_...
31
  	init_rwsem(&ip->i_rw_mutex);
813e0c46c   Steven Whitehouse   GFS2: Fix "trunca...
32
  	INIT_LIST_HEAD(&ip->i_trunc_list);
6dbd82248   Steven Whitehouse   [GFS2] Reduce ino...
33
  	ip->i_alloc = NULL;
320dd101e   Steven Whitehouse   [GFS2] glock debu...
34
  }
51cc50685   Alexey Dobriyan   SL*B: drop kmem c...
35
  static void gfs2_init_glock_once(void *foo)
ec45d9f58   Steven Whitehouse   [GFS2] Use slab p...
36
37
  {
  	struct gfs2_glock *gl = foo;
a35afb830   Christoph Lameter   Remove SLAB_CTOR_...
38
39
40
41
  
  	INIT_HLIST_NODE(&gl->gl_list);
  	spin_lock_init(&gl->gl_spin);
  	INIT_LIST_HEAD(&gl->gl_holders);
a35afb830   Christoph Lameter   Remove SLAB_CTOR_...
42
43
  	gl->gl_lvb = NULL;
  	atomic_set(&gl->gl_lvb_count, 0);
97cc1025b   Steven Whitehouse   GFS2: Kill two da...
44
  	INIT_LIST_HEAD(&gl->gl_lru);
a35afb830   Christoph Lameter   Remove SLAB_CTOR_...
45
46
  	INIT_LIST_HEAD(&gl->gl_ail_list);
  	atomic_set(&gl->gl_ail_count, 0);
ec45d9f58   Steven Whitehouse   [GFS2] Use slab p...
47
  }
b3b94faa5   David Teigland   [GFS2] The core o...
48
49
50
51
52
53
54
55
56
  /**
   * init_gfs2_fs - Register GFS2 as a filesystem
   *
   * Returns: 0 on success, error code on failure
   */
  
  static int __init init_gfs2_fs(void)
  {
  	int error;
b3b94faa5   David Teigland   [GFS2] The core o...
57
58
59
  	error = gfs2_sys_init();
  	if (error)
  		return error;
85d1da67f   Steven Whitehouse   [GFS2] Move glock...
60
61
62
  	error = gfs2_glock_init();
  	if (error)
  		goto fail;
b3b94faa5   David Teigland   [GFS2] The core o...
63

85d1da67f   Steven Whitehouse   [GFS2] Move glock...
64
  	error = -ENOMEM;
b3b94faa5   David Teigland   [GFS2] The core o...
65
66
  	gfs2_glock_cachep = kmem_cache_create("gfs2_glock",
  					      sizeof(struct gfs2_glock),
907b9bceb   Steven Whitehouse   [GFS2/DLM] Fix tr...
67
  					      0, 0,
20c2df83d   Paul Mundt   mm: Remove slab d...
68
  					      gfs2_init_glock_once);
b3b94faa5   David Teigland   [GFS2] The core o...
69
70
71
72
73
  	if (!gfs2_glock_cachep)
  		goto fail;
  
  	gfs2_inode_cachep = kmem_cache_create("gfs2_inode",
  					      sizeof(struct gfs2_inode),
eb1dc33aa   Alexey Dobriyan   [GFS2] don't pani...
74
75
  					      0,  SLAB_RECLAIM_ACCOUNT|
  					          SLAB_MEM_SPREAD,
20c2df83d   Paul Mundt   mm: Remove slab d...
76
  					      gfs2_init_inode_once);
b3b94faa5   David Teigland   [GFS2] The core o...
77
78
79
80
81
  	if (!gfs2_inode_cachep)
  		goto fail;
  
  	gfs2_bufdata_cachep = kmem_cache_create("gfs2_bufdata",
  						sizeof(struct gfs2_bufdata),
20c2df83d   Paul Mundt   mm: Remove slab d...
82
  					        0, 0, NULL);
b3b94faa5   David Teigland   [GFS2] The core o...
83
84
  	if (!gfs2_bufdata_cachep)
  		goto fail;
6bdd9be62   Bob Peterson   [GFS2] Allocate g...
85
86
87
88
89
  	gfs2_rgrpd_cachep = kmem_cache_create("gfs2_rgrpd",
  					      sizeof(struct gfs2_rgrpd),
  					      0, 0, NULL);
  	if (!gfs2_rgrpd_cachep)
  		goto fail;
37b2c8377   Steven Whitehouse   GFS2: Clean up & ...
90
91
92
93
94
  	gfs2_quotad_cachep = kmem_cache_create("gfs2_quotad",
  					       sizeof(struct gfs2_quota_data),
  					       0, 0, NULL);
  	if (!gfs2_quotad_cachep)
  		goto fail;
b3b94faa5   David Teigland   [GFS2] The core o...
95
96
97
  	error = register_filesystem(&gfs2_fs_type);
  	if (error)
  		goto fail;
419c93e0b   Steven Whitehouse   [GFS2] Add gfs2me...
98
99
100
  	error = register_filesystem(&gfs2meta_fs_type);
  	if (error)
  		goto fail_unregister;
7c52b166c   Robert Peterson   [GFS2] Add gfs2_t...
101
  	gfs2_register_debugfs();
b3b94faa5   David Teigland   [GFS2] The core o...
102
103
104
105
  	printk("GFS2 (built %s %s) installed
  ", __DATE__, __TIME__);
  
  	return 0;
419c93e0b   Steven Whitehouse   [GFS2] Add gfs2me...
106
107
108
  fail_unregister:
  	unregister_filesystem(&gfs2_fs_type);
  fail:
8fbbfd214   Steven Whitehouse   [GFS2] Reduce num...
109
  	gfs2_glock_exit();
37b2c8377   Steven Whitehouse   GFS2: Clean up & ...
110
111
  	if (gfs2_quotad_cachep)
  		kmem_cache_destroy(gfs2_quotad_cachep);
6bdd9be62   Bob Peterson   [GFS2] Allocate g...
112
113
  	if (gfs2_rgrpd_cachep)
  		kmem_cache_destroy(gfs2_rgrpd_cachep);
b3b94faa5   David Teigland   [GFS2] The core o...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  	if (gfs2_bufdata_cachep)
  		kmem_cache_destroy(gfs2_bufdata_cachep);
  
  	if (gfs2_inode_cachep)
  		kmem_cache_destroy(gfs2_inode_cachep);
  
  	if (gfs2_glock_cachep)
  		kmem_cache_destroy(gfs2_glock_cachep);
  
  	gfs2_sys_uninit();
  	return error;
  }
  
  /**
   * exit_gfs2_fs - Unregister the file system
   *
   */
  
  static void __exit exit_gfs2_fs(void)
  {
8fbbfd214   Steven Whitehouse   [GFS2] Reduce num...
134
  	gfs2_glock_exit();
7c52b166c   Robert Peterson   [GFS2] Add gfs2_t...
135
  	gfs2_unregister_debugfs();
b3b94faa5   David Teigland   [GFS2] The core o...
136
  	unregister_filesystem(&gfs2_fs_type);
419c93e0b   Steven Whitehouse   [GFS2] Add gfs2me...
137
  	unregister_filesystem(&gfs2meta_fs_type);
b3b94faa5   David Teigland   [GFS2] The core o...
138

37b2c8377   Steven Whitehouse   GFS2: Clean up & ...
139
  	kmem_cache_destroy(gfs2_quotad_cachep);
6bdd9be62   Bob Peterson   [GFS2] Allocate g...
140
  	kmem_cache_destroy(gfs2_rgrpd_cachep);
b3b94faa5   David Teigland   [GFS2] The core o...
141
142
143
144
145
146
147
148
149
150
151
152
153
  	kmem_cache_destroy(gfs2_bufdata_cachep);
  	kmem_cache_destroy(gfs2_inode_cachep);
  	kmem_cache_destroy(gfs2_glock_cachep);
  
  	gfs2_sys_uninit();
  }
  
  MODULE_DESCRIPTION("Global File System");
  MODULE_AUTHOR("Red Hat, Inc.");
  MODULE_LICENSE("GPL");
  
  module_init(init_gfs2_fs);
  module_exit(exit_gfs2_fs);