GFS2: Clean up & move gfs2_quotad
[linux-2.6.git] / fs / gfs2 / main.c
index 9889c1e..e3f6f18 100644 (file)
@@ -7,7 +7,6 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 
 #include "gfs2.h"
 #include "incore.h"
-#include "ops_fstype.h"
+#include "super.h"
 #include "sys.h"
 #include "util.h"
 #include "glock.h"
 
-static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void gfs2_init_inode_once(void *foo)
 {
        struct gfs2_inode *ip = foo;
-       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR) {
-               inode_init_once(&ip->i_inode);
-               spin_lock_init(&ip->i_spin);
-               init_rwsem(&ip->i_rw_mutex);
-               memset(ip->i_cache, 0, sizeof(ip->i_cache));
-       }
+
+       inode_init_once(&ip->i_inode);
+       init_rwsem(&ip->i_rw_mutex);
+       ip->i_alloc = NULL;
 }
 
-static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+static void gfs2_init_glock_once(void *foo)
 {
        struct gfs2_glock *gl = foo;
-       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-           SLAB_CTOR_CONSTRUCTOR) {
-               INIT_HLIST_NODE(&gl->gl_list);
-               spin_lock_init(&gl->gl_spin);
-               INIT_LIST_HEAD(&gl->gl_holders);
-               INIT_LIST_HEAD(&gl->gl_waiters1);
-               INIT_LIST_HEAD(&gl->gl_waiters2);
-               INIT_LIST_HEAD(&gl->gl_waiters3);
-               gl->gl_lvb = NULL;
-               atomic_set(&gl->gl_lvb_count, 0);
-               INIT_LIST_HEAD(&gl->gl_reclaim);
-               INIT_LIST_HEAD(&gl->gl_ail_list);
-               atomic_set(&gl->gl_ail_count, 0);
-       }
+
+       INIT_HLIST_NODE(&gl->gl_list);
+       spin_lock_init(&gl->gl_spin);
+       INIT_LIST_HEAD(&gl->gl_holders);
+       gl->gl_lvb = NULL;
+       atomic_set(&gl->gl_lvb_count, 0);
+       INIT_LIST_HEAD(&gl->gl_reclaim);
+       INIT_LIST_HEAD(&gl->gl_ail_list);
+       atomic_set(&gl->gl_ail_count, 0);
 }
 
 /**
@@ -78,7 +69,7 @@ static int __init init_gfs2_fs(void)
        gfs2_glock_cachep = kmem_cache_create("gfs2_glock",
                                              sizeof(struct gfs2_glock),
                                              0, 0,
-                                             gfs2_init_glock_once, NULL);
+                                             gfs2_init_glock_once);
        if (!gfs2_glock_cachep)
                goto fail;
 
@@ -86,16 +77,28 @@ static int __init init_gfs2_fs(void)
                                              sizeof(struct gfs2_inode),
                                              0,  SLAB_RECLAIM_ACCOUNT|
                                                  SLAB_MEM_SPREAD,
-                                             gfs2_init_inode_once, NULL);
+                                             gfs2_init_inode_once);
        if (!gfs2_inode_cachep)
                goto fail;
 
        gfs2_bufdata_cachep = kmem_cache_create("gfs2_bufdata",
                                                sizeof(struct gfs2_bufdata),
-                                               0, 0, NULL, NULL);
+                                               0, 0, NULL);
        if (!gfs2_bufdata_cachep)
                goto fail;
 
+       gfs2_rgrpd_cachep = kmem_cache_create("gfs2_rgrpd",
+                                             sizeof(struct gfs2_rgrpd),
+                                             0, 0, NULL);
+       if (!gfs2_rgrpd_cachep)
+               goto fail;
+
+       gfs2_quotad_cachep = kmem_cache_create("gfs2_quotad",
+                                              sizeof(struct gfs2_quota_data),
+                                              0, 0, NULL);
+       if (!gfs2_quotad_cachep)
+               goto fail;
+
        error = register_filesystem(&gfs2_fs_type);
        if (error)
                goto fail;
@@ -104,6 +107,8 @@ static int __init init_gfs2_fs(void)
        if (error)
                goto fail_unregister;
 
+       gfs2_register_debugfs();
+
        printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__);
 
        return 0;
@@ -111,6 +116,14 @@ static int __init init_gfs2_fs(void)
 fail_unregister:
        unregister_filesystem(&gfs2_fs_type);
 fail:
+       gfs2_glock_exit();
+
+       if (gfs2_quotad_cachep)
+               kmem_cache_destroy(gfs2_quotad_cachep);
+
+       if (gfs2_rgrpd_cachep)
+               kmem_cache_destroy(gfs2_rgrpd_cachep);
+
        if (gfs2_bufdata_cachep)
                kmem_cache_destroy(gfs2_bufdata_cachep);
 
@@ -131,9 +144,13 @@ fail:
 
 static void __exit exit_gfs2_fs(void)
 {
+       gfs2_glock_exit();
+       gfs2_unregister_debugfs();
        unregister_filesystem(&gfs2_fs_type);
        unregister_filesystem(&gfs2meta_fs_type);
 
+       kmem_cache_destroy(gfs2_quotad_cachep);
+       kmem_cache_destroy(gfs2_rgrpd_cachep);
        kmem_cache_destroy(gfs2_bufdata_cachep);
        kmem_cache_destroy(gfs2_inode_cachep);
        kmem_cache_destroy(gfs2_glock_cachep);