Merge branch 'for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs
[safe/jmp/linux-2.6] / fs / gfs2 / main.c
index 053e2eb..eacd78a 100644 (file)
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/gfs2_ondisk.h>
-#include <linux/lm_interface.h>
 #include <asm/atomic.h>
+#include <linux/slow-work.h>
 
 #include "gfs2.h"
 #include "incore.h"
-#include "ops_fstype.h"
+#include "super.h"
 #include "sys.h"
 #include "util.h"
 #include "glock.h"
+#include "quota.h"
 
-static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo)
+static struct shrinker qd_shrinker = {
+       .shrink = gfs2_shrink_qd_memory,
+       .seeks = DEFAULT_SEEKS,
+};
+
+static void gfs2_init_inode_once(void *foo)
 {
        struct gfs2_inode *ip = foo;
 
        inode_init_once(&ip->i_inode);
        init_rwsem(&ip->i_rw_mutex);
+       INIT_LIST_HEAD(&ip->i_trunc_list);
        ip->i_alloc = NULL;
 }
 
-static void gfs2_init_glock_once(struct kmem_cache *cachep, void *foo)
+static void gfs2_init_glock_once(void *foo)
 {
        struct gfs2_glock *gl = foo;
 
        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_waiters3);
-       gl->gl_lvb = NULL;
-       atomic_set(&gl->gl_lvb_count, 0);
-       INIT_LIST_HEAD(&gl->gl_reclaim);
+       INIT_LIST_HEAD(&gl->gl_lru);
        INIT_LIST_HEAD(&gl->gl_ail_list);
        atomic_set(&gl->gl_ail_count, 0);
 }
@@ -95,6 +98,14 @@ static int __init init_gfs2_fs(void)
        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;
+
+       register_shrinker(&qd_shrinker);
+
        error = register_filesystem(&gfs2_fs_type);
        if (error)
                goto fail;
@@ -103,17 +114,27 @@ static int __init init_gfs2_fs(void)
        if (error)
                goto fail_unregister;
 
+       error = slow_work_register_user();
+       if (error)
+               goto fail_slow;
+
        gfs2_register_debugfs();
 
        printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__);
 
        return 0;
 
+fail_slow:
+       unregister_filesystem(&gfs2meta_fs_type);
 fail_unregister:
        unregister_filesystem(&gfs2_fs_type);
 fail:
+       unregister_shrinker(&qd_shrinker);
        gfs2_glock_exit();
 
+       if (gfs2_quotad_cachep)
+               kmem_cache_destroy(gfs2_quotad_cachep);
+
        if (gfs2_rgrpd_cachep)
                kmem_cache_destroy(gfs2_rgrpd_cachep);
 
@@ -137,11 +158,14 @@ fail:
 
 static void __exit exit_gfs2_fs(void)
 {
+       unregister_shrinker(&qd_shrinker);
        gfs2_glock_exit();
        gfs2_unregister_debugfs();
        unregister_filesystem(&gfs2_fs_type);
        unregister_filesystem(&gfs2meta_fs_type);
+       slow_work_unregister_user();
 
+       kmem_cache_destroy(gfs2_quotad_cachep);
        kmem_cache_destroy(gfs2_rgrpd_cachep);
        kmem_cache_destroy(gfs2_bufdata_cachep);
        kmem_cache_destroy(gfs2_inode_cachep);