0001
0002
0003
0004
0005
0006
0007 #include <linux/hdreg.h>
0008 #include <linux/blkdev.h>
0009 #include <linux/module.h>
0010 #include <linux/skbuff.h>
0011 #include "aoe.h"
0012
0013 MODULE_LICENSE("GPL");
0014 MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>");
0015 MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels");
0016 MODULE_VERSION(VERSION);
0017
0018 static struct timer_list timer;
0019 struct workqueue_struct *aoe_wq;
0020
0021 static void discover_timer(struct timer_list *t)
0022 {
0023 mod_timer(t, jiffies + HZ * 60);
0024
0025 aoecmd_cfg(0xffff, 0xff);
0026 }
0027
0028 static void __exit
0029 aoe_exit(void)
0030 {
0031 del_timer_sync(&timer);
0032
0033 aoenet_exit();
0034 unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
0035 aoecmd_exit();
0036 aoechr_exit();
0037 aoedev_exit();
0038 aoeblk_exit();
0039 destroy_workqueue(aoe_wq);
0040 }
0041
0042 static int __init
0043 aoe_init(void)
0044 {
0045 int ret;
0046
0047 aoe_wq = alloc_workqueue("aoe_wq", 0, 0);
0048 if (!aoe_wq)
0049 return -ENOMEM;
0050
0051 ret = aoedev_init();
0052 if (ret)
0053 goto dev_fail;
0054 ret = aoechr_init();
0055 if (ret)
0056 goto chr_fail;
0057 ret = aoeblk_init();
0058 if (ret)
0059 goto blk_fail;
0060 ret = aoenet_init();
0061 if (ret)
0062 goto net_fail;
0063 ret = aoecmd_init();
0064 if (ret)
0065 goto cmd_fail;
0066 ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
0067 if (ret < 0) {
0068 printk(KERN_ERR "aoe: can't register major\n");
0069 goto blkreg_fail;
0070 }
0071 printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
0072
0073 timer_setup(&timer, discover_timer, 0);
0074 discover_timer(&timer);
0075 return 0;
0076 blkreg_fail:
0077 aoecmd_exit();
0078 cmd_fail:
0079 aoenet_exit();
0080 net_fail:
0081 aoeblk_exit();
0082 blk_fail:
0083 aoechr_exit();
0084 chr_fail:
0085 aoedev_exit();
0086 dev_fail:
0087 destroy_workqueue(aoe_wq);
0088
0089 printk(KERN_INFO "aoe: initialisation failure.\n");
0090 return ret;
0091 }
0092
0093 module_init(aoe_init);
0094 module_exit(aoe_exit);
0095