main.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  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. #include <linux/sched.h>
  10. #include <linux/slab.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/completion.h>
  13. #include <linux/buffer_head.h>
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/gfs2_ondisk.h>
  17. #include <asm/semaphore.h>
  18. #include "gfs2.h"
  19. #include "lm_interface.h"
  20. #include "incore.h"
  21. #include "ops_fstype.h"
  22. #include "sys.h"
  23. #include "util.h"
  24. /**
  25. * init_gfs2_fs - Register GFS2 as a filesystem
  26. *
  27. * Returns: 0 on success, error code on failure
  28. */
  29. static int __init init_gfs2_fs(void)
  30. {
  31. int error;
  32. gfs2_init_lmh();
  33. error = gfs2_sys_init();
  34. if (error)
  35. return error;
  36. error = -ENOMEM;
  37. gfs2_glock_cachep = kmem_cache_create("gfs2_glock",
  38. sizeof(struct gfs2_glock),
  39. 0, 0, NULL, NULL);
  40. if (!gfs2_glock_cachep)
  41. goto fail;
  42. gfs2_inode_cachep = kmem_cache_create("gfs2_inode",
  43. sizeof(struct gfs2_inode),
  44. 0, 0, NULL, NULL);
  45. if (!gfs2_inode_cachep)
  46. goto fail;
  47. gfs2_bufdata_cachep = kmem_cache_create("gfs2_bufdata",
  48. sizeof(struct gfs2_bufdata),
  49. 0, 0, NULL, NULL);
  50. if (!gfs2_bufdata_cachep)
  51. goto fail;
  52. error = register_filesystem(&gfs2_fs_type);
  53. if (error)
  54. goto fail;
  55. printk("GFS2 (built %s %s) installed\n", __DATE__, __TIME__);
  56. return 0;
  57. fail:
  58. if (gfs2_bufdata_cachep)
  59. kmem_cache_destroy(gfs2_bufdata_cachep);
  60. if (gfs2_inode_cachep)
  61. kmem_cache_destroy(gfs2_inode_cachep);
  62. if (gfs2_glock_cachep)
  63. kmem_cache_destroy(gfs2_glock_cachep);
  64. gfs2_sys_uninit();
  65. return error;
  66. }
  67. /**
  68. * exit_gfs2_fs - Unregister the file system
  69. *
  70. */
  71. static void __exit exit_gfs2_fs(void)
  72. {
  73. unregister_filesystem(&gfs2_fs_type);
  74. kmem_cache_destroy(gfs2_bufdata_cachep);
  75. kmem_cache_destroy(gfs2_inode_cachep);
  76. kmem_cache_destroy(gfs2_glock_cachep);
  77. gfs2_sys_uninit();
  78. }
  79. MODULE_DESCRIPTION("Global File System");
  80. MODULE_AUTHOR("Red Hat, Inc.");
  81. MODULE_LICENSE("GPL");
  82. module_init(init_gfs2_fs);
  83. module_exit(exit_gfs2_fs);