summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/devices.c15
-rw-r--r--kernel/dnbd2.h1
-rw-r--r--kernel/servers.c34
3 files changed, 41 insertions, 9 deletions
diff --git a/kernel/devices.c b/kernel/devices.c
index ccc6db1..7c1102b 100644
--- a/kernel/devices.c
+++ b/kernel/devices.c
@@ -106,8 +106,13 @@ int add_device(dnbd2_device_t *dev, int minor)
* Prepare dnbd2_device_t. Please use the
* same order as in dnbd2.h.
*/
- INIT_WORK(&dev->work, NULL); //, NULL);
- /* Change in /<linuxheaders>/include/linux/workqueue.h */
+
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ INIT_WORK(&dev->work, NULL, NULL);
+ #else
+ INIT_WORK(&dev->work, NULL);
+ #endif
+
spin_lock_init(&dev->kmap_lock);
for (i=0 ; i<POOL_SIZE ; i++)
dev->info_pool[i].cnt = -1;
@@ -145,7 +150,11 @@ int add_device(dnbd2_device_t *dev, int minor)
init_completion(&srv_info->rx_start);
init_completion(&srv_info->rx_stop);
init_waitqueue_head(&srv_info->wq);
- INIT_WORK(&srv_info->work, NULL); //, NULL);
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ INIT_WORK(&srv_info->work, NULL, NULL);
+ #else
+ INIT_WORK(&srv_info->work, NULL);
+ #endif
/* Change in /<linuxheaders>/include/linux/workqueue.h */
srv_info->dev = dev;
}
diff --git a/kernel/dnbd2.h b/kernel/dnbd2.h
index cf693d9..c49c9b9 100644
--- a/kernel/dnbd2.h
+++ b/kernel/dnbd2.h
@@ -11,6 +11,7 @@
#include <linux/wait.h>
#include <linux/inet.h>
#include <linux/in.h>
+#include <linux/version.h>
#include <asm/semaphore.h>
#include <net/sock.h>
#include "../include/dnbd2.h"
diff --git a/kernel/servers.c b/kernel/servers.c
index 7d5c229..52d565b 100644
--- a/kernel/servers.c
+++ b/kernel/servers.c
@@ -60,9 +60,17 @@ struct srv_info *fastest_server(uint16_t *srtt, dnbd2_device_t *dev)
* This function can be enqueued in a workqueue. It removes srv_info
* from the list of servers.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+void del_server_work(void *data)
+#else
void del_server_work(struct work_struct *work)
+#endif
{
- struct srv_info *srv_info = container_of(work, struct srv_info, work);
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ struct srv_info *srv_info = data;
+ #else
+ struct srv_info *srv_info = container_of(work, struct srv_info, work);
+ #endif
dnbd2_device_t *dev = srv_info->dev;
down(&dev->servers_mutex);
@@ -80,9 +88,17 @@ void del_server_work(struct work_struct *work)
* This function can be enqueued in a workqueue. Read comment on
* schedule_activate_fastest in servers.h
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+void activate_fastest_work(void *data)
+#else
void activate_fastest_work(struct work_struct *work)
+#endif
{
- dnbd2_device_t *dev = container_of(work, dnbd2_device_t, work);
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ dnbd2_device_t *dev = data;
+ #else
+ dnbd2_device_t *dev = container_of(work, dnbd2_device_t, work);
+ #endif
struct srv_info *alt_srv, *next_srv;
uint16_t min, srtt;
int newsrv = 0;
@@ -341,15 +357,21 @@ void enqueue_hb(struct srv_info *srv_info)
void schedule_del_server(struct srv_info *srv_info)
{
- PREPARE_WORK(&srv_info->work, del_server_work); //, srv_info);
- /* Change in /<linuxheaders>/include/linux/workqueue.h */
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ PREPARE_WORK(&srv_info->work, del_server_work, srv_info);
+ #else
+ PREPARE_WORK(&srv_info->work, del_server_work);
+ #endif
schedule_work(&srv_info->work);
}
void schedule_activate_fastest(dnbd2_device_t *dev)
{
- PREPARE_WORK(&dev->work, activate_fastest_work); //, dev);
- /* Change in /<linuxheaders>/include/linux/workqueue.h */
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ PREPARE_WORK(&dev->work, activate_fastest_work, dev);
+ #else
+ PREPARE_WORK(&dev->work, activate_fastest_work);
+ #endif
schedule_work(&dev->work);
}