]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/gfs2/main.c
GFS2: Remove a __GFP_NOFAIL allocation
[karo-tx-linux.git] / fs / gfs2 / main.c
index a8d9bcd0e19cbbb5c050b89e963b00651d50acb1..754426b1e52c10a5746a1e0f0769cb47c0050eaa 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/rcupdate.h>
 #include <linux/rculist_bl.h>
 #include <linux/atomic.h>
+#include <linux/mempool.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -69,6 +70,16 @@ static void gfs2_init_gl_aspace_once(void *foo)
        address_space_init_once(mapping);
 }
 
+static void *gfs2_bh_alloc(gfp_t mask, void *data)
+{
+       return alloc_buffer_head(mask);
+}
+
+static void gfs2_bh_free(void *ptr, void *data)
+{
+       return free_buffer_head(ptr);
+}
+
 /**
  * init_gfs2_fs - Register GFS2 as a filesystem
  *
@@ -151,6 +162,10 @@ static int __init init_gfs2_fs(void)
        gfs2_control_wq = alloc_workqueue("gfs2_control",
                               WQ_NON_REENTRANT | WQ_UNBOUND | WQ_FREEZABLE, 0);
        if (!gfs2_control_wq)
+               goto fail_recovery;
+
+       gfs2_bh_pool = mempool_create(1024, gfs2_bh_alloc, gfs2_bh_free, NULL);
+       if (!gfs2_bh_pool)
                goto fail_control;
 
        gfs2_register_debugfs();
@@ -160,6 +175,8 @@ static int __init init_gfs2_fs(void)
        return 0;
 
 fail_control:
+       destroy_workqueue(gfs2_control_wq);
+fail_recovery:
        destroy_workqueue(gfs_recovery_wq);
 fail_wq:
        unregister_filesystem(&gfs2meta_fs_type);
@@ -208,6 +225,7 @@ static void __exit exit_gfs2_fs(void)
 
        rcu_barrier();
 
+       mempool_destroy(gfs2_bh_pool);
        kmem_cache_destroy(gfs2_quotad_cachep);
        kmem_cache_destroy(gfs2_rgrpd_cachep);
        kmem_cache_destroy(gfs2_bufdata_cachep);