summaryrefslogtreecommitdiffstats
path: root/src/kernel/core.c
diff options
context:
space:
mode:
authorJohann Latocha2012-01-25 21:30:58 +0100
committerJohann Latocha2012-01-25 21:30:58 +0100
commit94704ea51d3b522f7de88080837e4c1acc820816 (patch)
tree2f7180a1c8fe39817501beedb335326a39ec5107 /src/kernel/core.c
parentServing more than one image. (diff)
downloaddnbd3-94704ea51d3b522f7de88080837e4c1acc820816.tar.gz
dnbd3-94704ea51d3b522f7de88080837e4c1acc820816.tar.xz
dnbd3-94704ea51d3b522f7de88080837e4c1acc820816.zip
[KERNEL] Multi device support
Diffstat (limited to 'src/kernel/core.c')
-rw-r--r--src/kernel/core.c65
1 files changed, 18 insertions, 47 deletions
diff --git a/src/kernel/core.c b/src/kernel/core.c
index 3fe88f3..1483704 100644
--- a/src/kernel/core.c
+++ b/src/kernel/core.c
@@ -21,59 +21,27 @@
#include "dnbd3.h"
#include "blk.h"
-// block
int major;
-struct gendisk *disk;
-struct request_queue *dnbd3_queue;
-spinlock_t dnbd3_lock;
-
-// network
-char* _host = NULL;
-char* _port = NULL;
-char* _image_id = NULL;
-struct socket *_sock;
-
-// process
-wait_queue_head_t _process_queue_send;
-wait_queue_head_t _process_queue_receive;
-struct list_head _request_queue_send;
-struct list_head _request_queue_receive;
+struct dnbd3_device dnbd3_device[MAX_NUMBER_DEVICES];
static int __init dnbd3_init(void)
{
- // initialize queues
- init_waitqueue_head(&_process_queue_send);
- init_waitqueue_head(&_process_queue_receive);
- INIT_LIST_HEAD(&_request_queue_send);
- INIT_LIST_HEAD(&_request_queue_receive);
+ int i;
// initialize block device
- if ((major = register_blkdev(0, "dnbd")) == 0)
+ if ((major = register_blkdev(0, "dnbd3")) == 0)
{
printk("ERROR: dnbd3 register_blkdev failed.\n");
return -EIO;
}
- if (!(disk = alloc_disk(1)))
- {
- printk("ERROR: dnbd3 alloc_disk failed.\n");
- return -EIO;
- }
- disk->major = major;
- disk->first_minor = 0;
- sprintf(disk->disk_name, "dnbd0");
- set_capacity(disk, 0);
- set_disk_ro(disk, 1);
- disk->fops = &dnbd3_blk_ops;
- spin_lock_init(&dnbd3_lock);
- if ((dnbd3_queue = blk_init_queue(&dnbd3_blk_request, &dnbd3_lock)) == NULL)
+ for (i = 0; i < MAX_NUMBER_DEVICES; i++)
{
- printk("ERROR: dnbd3 blk_init_queue failed.\n");
- return -EIO;
+ if (dnbd3_blk_add_device(&dnbd3_device[i], i) != 0)
+ {
+ printk("ERROR: adding device failed.\n");
+ return -EIO;
+ }
}
- blk_queue_logical_block_size(dnbd3_queue, DNBD3_BLOCK_SIZE);
- disk->queue = dnbd3_queue;
-
- add_disk(disk); // must be last
printk("INFO: dnbd3 init successful.\n");
return 0;
@@ -81,15 +49,18 @@ static int __init dnbd3_init(void)
static void __exit dnbd3_exit(void)
{
- if (_sock)
- sock_release(_sock);
- unregister_blkdev(major, "dnbd");
- del_gendisk(disk);
- put_disk(disk);
- blk_cleanup_queue(dnbd3_queue);
+ int i;
+ for (i = 0; i < MAX_NUMBER_DEVICES; i++)
+ {
+ dnbd3_blk_del_device(&dnbd3_device[i]);
+ }
+
+ unregister_blkdev(major, "dnbd3");
printk("INFO: dnbd3 exit.\n");
}
module_init( dnbd3_init);
module_exit( dnbd3_exit);
+
+MODULE_DESCRIPTION("Distributed Network Block Device 3");
MODULE_LICENSE("GPL");