diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/core.c | 9 | ||||
-rw-r--r-- | kernel/core.h | 7 | ||||
-rw-r--r-- | kernel/sysfs.c | 40 |
3 files changed, 42 insertions, 14 deletions
diff --git a/kernel/core.c b/kernel/core.c index 6bee380..01ff4b1 100644 --- a/kernel/core.c +++ b/kernel/core.c @@ -15,8 +15,11 @@ int dnbd2_major; static dnbd2_device_t dev[DNBD2_DEVICES]; - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) +void dnbd2_request(struct request_queue *q) +#else void dnbd2_request(request_queue_t *q) +#endif { int i; struct request *req; @@ -311,8 +314,12 @@ void dnbd2_end_request(struct request *req, int success) dev = req->rq_disk->private_data; 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)) { +#else if (!end_that_request_first(req, success, req->nr_sectors)) { end_that_request_last(req, success); +#endif } dev->pending_reqs--; spin_unlock_irqrestore(&dev->blk_lock, flags); diff --git a/kernel/core.h b/kernel/core.h index 3c75ade..1b315d1 100644 --- a/kernel/core.h +++ b/kernel/core.h @@ -30,7 +30,12 @@ extern int dnbd2_major; * 2. Enqueues the request into the send-queue. * 3. Wakes up dnbd2_tx_loop. */ -void dnbd2_request(request_queue_t *q); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) + void dnbd2_request(struct request_queue *q); +#else + void dnbd2_request(request_queue_t *q); +#endif + /* * This thread sleeps until there are requests in the send-queue. diff --git a/kernel/sysfs.c b/kernel/sysfs.c index 802e9d2..2ed8174 100644 --- a/kernel/sysfs.c +++ b/kernel/sysfs.c @@ -13,8 +13,8 @@ #define RW 0644 #define RO 0444 -#define kobj_to_dev(kp) container_of(kp, dnbd2_device_t, kobj) -#define kobj_to_srv(kp) container_of(kp, struct srv_info, kobj) +#define kobject_to_dev(kp) container_of(kp, dnbd2_device_t, kobj) +#define kobject_to_srv(kp) container_of(kp, struct srv_info, kobj) #define attr_to_srvattr(ap) container_of(ap, struct server_attr, attr) #define attr_to_devattr(ap) container_of(ap, struct device_attr, attr) @@ -119,7 +119,7 @@ ssize_t device_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct device_attr *device_attr = attr_to_devattr(attr); - dnbd2_device_t *dev = kobj_to_dev(kobj); + dnbd2_device_t *dev = kobject_to_dev(kobj); return device_attr->show(buf, dev); } @@ -128,7 +128,7 @@ ssize_t device_store(struct kobject *kobj, struct attribute *attr, { int ret; struct device_attr *device_attr = attr_to_devattr(attr); - dnbd2_device_t *dev = kobj_to_dev(kobj); + dnbd2_device_t *dev = kobject_to_dev(kobj); down(&dev->config_mutex); ret = device_attr->store(buf, count, dev); up(&dev->config_mutex); @@ -139,7 +139,7 @@ ssize_t server_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct server_attr *server_attr = attr_to_srvattr(attr); - struct srv_info *srv_info = kobj_to_srv(kobj); + struct srv_info *srv_info = kobject_to_srv(kobj); return server_attr->show(buf, srv_info); } @@ -148,7 +148,7 @@ ssize_t server_store(struct kobject *kobj, struct attribute *attr, { int ret; struct server_attr *server_attr = attr_to_srvattr(attr); - struct srv_info *srv_info = kobj_to_srv(kobj); + struct srv_info *srv_info = kobject_to_srv(kobj); down(&srv_info->dev->config_mutex); ret = server_attr->store(buf, count, srv_info); up(&srv_info->dev->config_mutex); @@ -418,10 +418,16 @@ int setup_kobj(struct kobject *kobj, char *name, struct kobject *parent, memset(kobj, 0, sizeof(struct kobject)); kobj->parent = parent; kobj->ktype = ktype; - if (kobject_set_name(kobj, name)) + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) + if (kobject_init_and_add(kobj, ktype, parent, name)) return -1; +#else + if (kobject_set_name(kobj, name)) + return -1; if (kobject_register(kobj)) return -1; +#endif return 0; } @@ -434,20 +440,24 @@ int start_sysfs(dnbd2_device_t *dev) int i; char name[] = "server99"; - if (setup_kobj(&dev->kobj, "config", &dev->disk->kobj, &device_ktype)) + if (setup_kobj(&dev->kobj, "config", &dev->disk->dev.kobj, &device_ktype)) return -1; for_each_server(i) { sprintf(name, "server%d", i); if (setup_kobj(&dev->servers[i].kobj, name, - &dev->disk->kobj, &server_ktype)) + &dev->disk->dev.kobj, &server_ktype)) goto out; } return 0; out: while (i--) - kobject_unregister(&dev->servers[i].kobj); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) + kobject_put(&dev->servers[i].kobj); +#else + kobject_unregister(&dev->servers[i].kobj); +#endif return -1; } @@ -455,6 +465,12 @@ void stop_sysfs(dnbd2_device_t *dev) { int i; for_each_server(i) - kobject_unregister(&dev->servers[i].kobj); - kobject_unregister(&dev->kobj); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) + kobject_put(&dev->servers[i].kobj); + kobject_put(&dev->kobj); +#else + kobject_unregister(&dev->servers[i].kobj); + kobject_unregister(&dev->kobj); + +#endif } |