summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Schmelzer2009-01-26 17:46:19 +0100
committerSebastian Schmelzer2009-01-26 17:46:19 +0100
commit626522ddfe2c3ff00c0f464c7619ef8cee7ccfe0 (patch)
treeefefe5f63aa21337003cc3673a2fa8f022a4d750
parent* added dnbd-client to svn:ignore (diff)
downloaddnbd-626522ddfe2c3ff00c0f464c7619ef8cee7ccfe0.tar.gz
dnbd-626522ddfe2c3ff00c0f464c7619ef8cee7ccfe0.tar.xz
dnbd-626522ddfe2c3ff00c0f464c7619ef8cee7ccfe0.zip
* switched from asm/semaphore.h includes to linux/semaphore.h
* fixed request_queue type * changed/removed end_that_request_* calls due to blockdev api changes TESTING REQUIRED ... git-svn-id: http://svn.openslx.org/svn/openslx/contrib/dnbd/trunk@2526 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r--kernel/dnbd.h10
-rw-r--r--kernel/main.c54
-rw-r--r--kernel/net.h10
-rw-r--r--kernel/queue.h2
4 files changed, 48 insertions, 28 deletions
diff --git a/kernel/dnbd.h b/kernel/dnbd.h
index 8d232b0..a744038 100644
--- a/kernel/dnbd.h
+++ b/kernel/dnbd.h
@@ -3,7 +3,7 @@
#include <linux/completion.h>
#include <linux/in.h>
-#include <asm/semaphore.h>
+#include <linux/semaphore.h>
#include <linux/blkdev.h>
#include <linux/rbtree.h>
#include <linux/jiffies.h>
@@ -30,16 +30,16 @@ struct dnbd_device {
int state;
struct socket *sock; /* network socket */
struct sockaddr_in mcast;
- struct file *file;
+ struct file *file;
spinlock_t thread_lock; /* locks */
spinlock_t queue_lock;
- spinlock_t timer_lock;
+ spinlock_t timer_lock;
struct semaphore semalock;
struct gendisk *disk; /* general disk interface */
int blksize;
u64 bytesize;
atomic_t refcnt; /* reference counter for module */
- dnbd_thread_t rx_thread;
+ dnbd_thread_t rx_thread;
dnbd_thread_t tx_thread;
dnbd_thread_t ss_thread;
atomic_t num_io_threads;
@@ -52,6 +52,6 @@ struct dnbd_device {
};
typedef struct dnbd_device dnbd_device_t;
-
+
#endif /* LINUX_DNBD_H */
diff --git a/kernel/main.c b/kernel/main.c
index f0eea1c..7cec644 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -67,16 +67,26 @@ static int dnbd_end_request(dnbd_device_t * dnbd, struct request *req,
int success, int size)
{
unsigned long flags;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+ struct request_queue *q = req->q;
+#else
request_queue_t *q = req->q;
+#endif
int result = 0;
spin_lock_irqsave(q->queue_lock, flags);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+ if (!(result = __blk_end_request(req, success, size))) {
+#else
if (!(result = end_that_request_first(req, success, size))) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
end_that_request_last(req,success);
-#else
+ #else
end_that_request_last(req);
+ #endif
#endif
}
@@ -239,9 +249,9 @@ static int inline dnbd_recv_reply(dnbd_device_t * dnbd)
if (!skb)
goto out_nofree;
- /*
- some NICs can verify checksums themselves and then is
- unnecessary for us
+ /*
+ some NICs can verify checksums themselves and then is
+ unnecessary for us
*/
offset = sizeof(struct udphdr);
if (skb->ip_summed != CHECKSUM_UNNECESSARY && (unsigned short)
@@ -529,11 +539,17 @@ static int dnbd_tx_loop(void *data)
cached = dnbd->cache.search(&dnbd->cache, req);
if (cached) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+ if (!__blk_end_request(req, 1, cached)) {
+#else
if (!end_that_request_first(req, 1, cached)) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
end_that_request_last(req,1);
-#else
+ #else
end_that_request_last(req);
+ #endif
#endif
} else {
dnbd_enq_request(&dnbd->tx_queue, req, 1);
@@ -748,7 +764,11 @@ static int dnbd_stop(dnbd_device_t * dnbd)
}
/* function called by the kernel to make DNBD process a request */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+static void dnbd_do_request(struct request_queue * q)
+#else
static void dnbd_do_request(request_queue_t * q)
+#endif
{
dnbd_device_t *dnbd = NULL;
int minor;
@@ -779,9 +799,9 @@ static void dnbd_do_request(request_queue_t * q)
goto error_out;
}
- /*
+ /*
enqueue request to tx_queue, where it will be fetched
- by the tx_loop
+ by the tx_loop
*/
spin_unlock_irq(q->queue_lock);
dnbd_enq_request(&dnbd->tx_queue, req, 1);
@@ -871,7 +891,7 @@ static int dnbd_clear_sock(dnbd_device_t * dnbd)
result = -EINVAL;
goto out;
}
- /*
+ /*
* space for operations when socket has to be cleared,
* which is done from user space (client/client.c)
*/
@@ -903,9 +923,9 @@ static int dnbd_do_it(dnbd_device_t * dnbd)
if (result < 0)
goto out;
- /*
- * will return when session ends (disconnect), which is
- * invoked from user space
+ /*
+ * will return when session ends (disconnect), which is
+ * invoked from user space
*/
dnbd_wait_threads_finished(dnbd);
@@ -1066,7 +1086,7 @@ static int dnbd_release(struct inode *inode, struct file *file)
return -ENODEV;
down(&dnbd->semalock);
-
+
/* decrement reference counter */
atomic_dec(&dnbd->refcnt);
@@ -1135,7 +1155,7 @@ static int __init dnbd_init(void)
for (i = 0; i < MAX_DNBD; i++) {
- /*
+ /*
* get pre initialized structure for block device minor
*/
struct gendisk *disk = alloc_disk(1);
@@ -1144,8 +1164,8 @@ static int __init dnbd_init(void)
goto out;
}
dnbd_dev[i].disk = disk;
- /*
- * initizialisation of request queue
+ /*
+ * initizialisation of request queue
* dnbd_do_request() is our function to handle the requests
*/
disk->queue =
diff --git a/kernel/net.h b/kernel/net.h
index cdd7996..8fad623 100644
--- a/kernel/net.h
+++ b/kernel/net.h
@@ -2,7 +2,7 @@
#define LINUX_DNBD_NET_H 1
#include <linux/spinlock.h>
-#include <asm/semaphore.h>
+#include <linux/semaphore.h>
#include <linux/list.h>
#include <linux/param.h>
#include <linux/jiffies.h>
@@ -20,7 +20,7 @@
/* beta is 99% (990/1000) */
#define SRTT_BETA 990
-#define SRTT_BETA_BASE 1000
+#define SRTT_BETA_BASE 1000
#define SRTT_SHIFT 10
/* normalize weights to 255 as there is no float arithmetic in kernel */
@@ -29,7 +29,7 @@
#define dnbd_rx_update(servers, id) \
if ((id > 0) && (id <= SERVERS_MAX)) servers.serverlist[id-1].last_rx = jiffies;
-
+
#define dnbd_tx_update(servers, id) \
if ((id > 0) && (id <= SERVERS_MAX)) servers.serverlist[id-1].last_tx = jiffies;
@@ -59,7 +59,7 @@ struct dnbd_servers {
};
typedef struct dnbd_servers dnbd_servers_t;
-
+
/* functions */
int dnbd_set_serverid(dnbd_servers_t * servers, int id);
int dnbd_next_server(dnbd_servers_t * servers);
@@ -69,5 +69,5 @@ int dnbd_servers_init(dnbd_servers_t *servers);
void dnbd_servers_weight(dnbd_servers_t * servers);
int dnbd_show_servers(dnbd_servers_t * servers, void *buf, int size);
void dnbd_clean_servers(dnbd_servers_t * servers);
-
+
#endif
diff --git a/kernel/queue.h b/kernel/queue.h
index f349637..287965b 100644
--- a/kernel/queue.h
+++ b/kernel/queue.h
@@ -2,7 +2,7 @@
#define LINUX_DNBD_QUEUE_H 1
#include <linux/spinlock.h>
-#include <asm/semaphore.h>
+#include <linux/semaphore.h>
#include <linux/list.h>
#include <linux/wait.h>