main.c 2.1 KB

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