summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/core.c16
-rw-r--r--kernel/devices.c11
-rw-r--r--kernel/dnbd2.h8
-rw-r--r--kernel/fops.c10
-rw-r--r--kernel/fops.h4
-rw-r--r--kernel/servers.c15
6 files changed, 37 insertions, 27 deletions
diff --git a/kernel/core.c b/kernel/core.c
index 01ff4b1..5ec7515 100644
--- a/kernel/core.c
+++ b/kernel/core.c
@@ -26,14 +26,14 @@ void dnbd2_request(request_queue_t *q)
struct req_info *info;
dnbd2_device_t *dev;
- while ((req = elv_next_request(q)) != NULL) {
+ while ((req = blk_peek_request(q)) != NULL) {
/* Discard invalid block requests. */
if (!blk_fs_request(req)) {
- end_request(req, 0);
+ __blk_end_request_cur(req, -EIO);
continue;
}
if (rq_data_dir(req) != READ) {
- end_request(req, 0);
+ __blk_end_request_cur(req, -EIO);
continue;
}
@@ -52,7 +52,7 @@ void dnbd2_request(request_queue_t *q)
info->cmd = CMD_GET_BLOCK;
info->dst = dev->active_server;
req->special = info;
- blkdev_dequeue_request(req);
+ req = blk_fetch_request(q);
/* Enqueue the request for sending. */
spin_lock_bh(&dev->send_queue_lock);
@@ -156,7 +156,7 @@ void dnbd2_send_request(struct request *req, dnbd2_device_t *dev) {
dnbd2_req.time = cpu_to_be16(info->time);
dnbd2_req.vid = cpu_to_be16(dev->vid);
dnbd2_req.rid = cpu_to_be16(dev->rid);
- dnbd2_req.num = cpu_to_be64(req->sector * SECTOR_SIZE);
+ dnbd2_req.num = cpu_to_be64(req->__sector * SECTOR_SIZE);
/*
* If sock_xmit fails the request eventually gets requeued.
@@ -275,7 +275,7 @@ struct request *dnbd2_find_request(uint64_t num,
req = blkdev_entry_to_request(cur);
info = req->special;
- if (req->sector == sector && info->cmd == cmd) {
+ if (req->__sector == sector && info->cmd == cmd) {
list_del_init(&req->queuelist);
spin_unlock_bh(&dev->pending_queue_lock);
return req;
@@ -315,9 +315,9 @@ void dnbd2_end_request(struct request *req, int success)
spin_lock_irqsave(&dev->blk_lock, flags);
list_del_init(&req->queuelist);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
- if(!__blk_end_request(req, success, req->nr_sectors)) {
+ if(!__blk_end_request(req, success, blk_rq_sectors(req))) {
#else
- if (!end_that_request_first(req, success, req->nr_sectors)) {
+ if (!end_that_request_first(req, success, blk_rq_sectors(req))) {
end_that_request_last(req, success);
#endif
}
diff --git a/kernel/devices.c b/kernel/devices.c
index cf89851..acf87e1 100644
--- a/kernel/devices.c
+++ b/kernel/devices.c
@@ -45,14 +45,14 @@ int start_device(dnbd2_device_t *dev)
/* Start sending thread. */
dev->tx_signal = 0;
- dev->tx_id = kernel_thread(dnbd2_tx_loop, dev, CLONE_KERNEL);
- if (dev->tx_id < 0) {
+ dev->dnbd_device_thread_task = kthread_run(dnbd2_tx_loop, dev, "DNBD2DEV");
+ if (IS_ERR(dev->dnbd_device_thread_task)){
del_timer(&dev->hb_timer);
del_timer(&dev->to_timer);
del_timer(&dev->requeue_timer);
return -1;
}
- wait_for_completion(&dev->tx_start);
+// wait_for_completion(&dev->tx_start);
return 0;
}
@@ -77,7 +77,8 @@ void stop_device(dnbd2_device_t *dev)
del_timer(&dev->requeue_timer);
dev->tx_signal = 1;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
- kill_proc_info(SIGKILL, 1, dev->tx_id);
+ //kill_proc_info(SIGKILL, 1, dev->tx_id);
+ kthread_stop(dev->dnbd_device_thread_task);
#else
kill_proc(dev->tx_id, SIGKILL, 1);
#endif
@@ -194,7 +195,7 @@ int add_device(dnbd2_device_t *dev, int minor)
*/
blk_queue_max_sectors(queue, DNBD2_BLOCK_SIZE/SECTOR_SIZE);
blk_queue_max_segment_size(queue, DNBD2_BLOCK_SIZE);
- blk_queue_hardsect_size(queue, DNBD2_BLOCK_SIZE);
+ blk_queue_logical_block_size(queue, DNBD2_BLOCK_SIZE);
blk_queue_max_phys_segments(queue, 1);
blk_queue_max_hw_segments(queue, 1);
disk->queue = queue;
diff --git a/kernel/dnbd2.h b/kernel/dnbd2.h
index 2bf0f76..c87080c 100644
--- a/kernel/dnbd2.h
+++ b/kernel/dnbd2.h
@@ -12,6 +12,9 @@
#include <linux/inet.h>
#include <linux/in.h>
#include <linux/version.h>
+
+#include <linux/kthread.h>
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#include <linux/semaphore.h>
#else
@@ -74,6 +77,8 @@ struct srv_info {
struct completion rx_start; /* dnbd2_rx_loop has started */
struct completion rx_stop; /* dnbd2_rx_loop has stopped */
+ struct task_struct *dnbd_thread_task;
+
unsigned long retries; /* number of requests retried */
unsigned long last_reply; /* time of last reply */
};
@@ -99,6 +104,9 @@ struct dnbd2_device {
spinlock_t send_queue_lock;
struct list_head send_queue;
+ struct task_struct *dnbd_device_thread_task;
+
+
unsigned long pending_reqs; /* number of block requests pending */
spinlock_t pending_queue_lock;
struct list_head pending_queue;
diff --git a/kernel/fops.c b/kernel/fops.c
index c098e13..5423987 100644
--- a/kernel/fops.c
+++ b/kernel/fops.c
@@ -14,14 +14,14 @@ struct block_device_operations dnbd2_fops = {
};
-int dnbd2_open(struct inode *inode, struct file *file)
+int dnbd2_open(struct block_device *bdev, fmode_t mode)
{
- dnbd2_device_t *dev = inode->i_bdev->bd_disk->private_data;
+ dnbd2_device_t *dev = bdev->bd_disk->private_data;
if (down_interruptible(&dev->config_mutex))
return -EBUSY;
/* FIXME: How do we put this add/start_device? */
- if (set_blocksize(inode->i_bdev, DNBD2_BLOCK_SIZE)) {
+ if (set_blocksize(bdev, DNBD2_BLOCK_SIZE)) {
up(&dev->config_mutex);
return -EBUSY;
}
@@ -32,9 +32,9 @@ int dnbd2_open(struct inode *inode, struct file *file)
}
-int dnbd2_release(struct inode *inode, struct file *file)
+int dnbd2_release(struct gendisk *disk, fmode_t mode)
{
- dnbd2_device_t *dev = inode->i_bdev->bd_disk->private_data;
+ dnbd2_device_t *dev = disk->private_data;
if (down_interruptible(&dev->config_mutex))
return -EBUSY;
atomic_dec(&dev->refcnt);
diff --git a/kernel/fops.h b/kernel/fops.h
index f5222d4..57bd60f 100644
--- a/kernel/fops.h
+++ b/kernel/fops.h
@@ -5,5 +5,5 @@
extern struct block_device_operations dnbd2_fops;
-int dnbd2_open(struct inode *inode, struct file *file);
-int dnbd2_release(struct inode *inode, struct file *file);
+int dnbd2_open(struct block_device *bdev, fmode_t mode);
+int dnbd2_release(struct gendisk *disk, fmode_t mode);
diff --git a/kernel/servers.c b/kernel/servers.c
index bd7f386..e79bf91 100644
--- a/kernel/servers.c
+++ b/kernel/servers.c
@@ -146,12 +146,12 @@ void activate_fastest_work(struct work_struct *work)
int start_rx_loop(struct srv_info *srv_info)
{
- srv_info->rx_id = kernel_thread(dnbd2_rx_loop, srv_info, CLONE_KERNEL);
- if (srv_info->rx_id < 0) {
+ srv_info->dnbd_thread_task = kthread_run(dnbd2_rx_loop, srv_info, "DNBD2");
+ if (IS_ERR(srv_info->dnbd_thread_task)){
srv_info->rx_id = 0;
return -1;
}
- wait_for_completion(&srv_info->rx_start);
+ //wait_for_completion(&srv_info->rx_start);
return 0;
}
@@ -161,11 +161,12 @@ void stop_rx_loop(struct srv_info *srv_info)
if (!srv_info->rx_id)
return;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
- kill_proc_info(SIGKILL, 1, srv_info->rx_id);
+ //kill_proc_info(SIGKILL, 1, srv_info->rx_id);
+ kthread_stop(srv_info->dnbd_thread_task);
#else
kill_proc(srv_info->rx_id, SIGKILL, 1);
#endif
- wait_for_completion(&srv_info->rx_stop);
+ //wait_for_completion(&srv_info->rx_stop);
srv_info->rx_id = 0;
}
@@ -274,7 +275,7 @@ sector_t srv_get_capacity(struct srv_info *srv_info)
info->dst = srv_info;
info->last_dst = srv_info;
req->special = info;
- req->sector = 0;
+ req->__sector = 0;
INIT_LIST_HEAD(&req->queuelist);
/* Enqueue the request for sending. */
@@ -349,7 +350,7 @@ void enqueue_hb(struct srv_info *srv_info)
info->dst = srv_info;
info->last_dst = srv_info;
req->special = info;
- req->sector = 0;
+ req->__sector = 0;
INIT_LIST_HEAD(&req->queuelist);
/* Enqueue the request for sending. */