summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kernel/core.c12
-rw-r--r--src/kernel/dnbd3.h24
-rw-r--r--src/kernel/net.c10
-rw-r--r--src/kernel/sysfs.c38
-rw-r--r--src/kernel/sysfs.h22
5 files changed, 52 insertions, 54 deletions
diff --git a/src/kernel/core.c b/src/kernel/core.c
index 7e985f7..c2d14d2 100644
--- a/src/kernel/core.c
+++ b/src/kernel/core.c
@@ -60,7 +60,7 @@ DEFINE_IDR(dnbd3_index_idr);
DEFINE_MUTEX(dnbd3_index_mutex);
static unsigned int max_devs = NUMBER_DEVICES;
-static dnbd3_device *device;
+static struct dnbd3_device *device;
int major;
@@ -183,7 +183,7 @@ static struct blk_mq_ops dnbd3_mq_ops = {
-static void dnbd3_blk_fail_all_requests(dnbd3_device *dev)
+static void dnbd3_blk_fail_all_requests(struct dnbd3_device *dev)
{
printk(KERN_DEBUG "dnbd3: fail all requests device %i\n", dev->minor);
}
@@ -193,7 +193,7 @@ static void dnbd3_blk_fail_all_requests(dnbd3_device *dev)
static int dnbd3_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
{
int result = -EIO;
- dnbd3_device *dev = bdev->bd_disk->private_data;
+ struct dnbd3_device *dev = bdev->bd_disk->private_data;
char *imgname = NULL;
dnbd3_ioctl_t *msg = NULL;
@@ -328,7 +328,7 @@ static struct block_device_operations dnbd3_fops =
-int dnbd3_add_device(dnbd3_device *dev, int minor)
+int dnbd3_add_device(struct dnbd3_device *dev, int minor)
{
struct gendisk *disk;
struct request_queue *q;
@@ -364,7 +364,7 @@ int dnbd3_add_device(dnbd3_device *dev, int minor)
dev->tag_set.nr_hw_queues = 1; // this can be changed later with blk_mq_update_nr_hw_queues()
dev->tag_set.queue_depth = 128;
dev->tag_set.numa_node = NUMA_NO_NODE;
- dev->tag_set.cmd_size = sizeof(dnbd3_cmd);
+ dev->tag_set.cmd_size = sizeof(struct dnbd3_cmd);
dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE |
BLK_MQ_F_SG_MERGE | BLK_MQ_F_BLOCKING;
dev->tag_set.driver_data = dev;
@@ -501,7 +501,7 @@ static void dnbd3_put(struct dnbd3_device *dnbd3)
static void __exit dnbd3_exit(void)
{
- dnbd3_device *dnbd3;
+ struct dnbd3_device *dnbd3;
LIST_HEAD(del_list);
printk(KERN_DEBUG "dnbd3: stopping kernel module\n");
diff --git a/src/kernel/dnbd3.h b/src/kernel/dnbd3.h
index 33f707d..cde94a2 100644
--- a/src/kernel/dnbd3.h
+++ b/src/kernel/dnbd3.h
@@ -36,29 +36,29 @@
extern struct workqueue_struct *dnbd3_wq;
-typedef struct dnbd3_server {
+struct dnbd3_server {
dnbd3_host_t host;
uint64_t rtts[4]; // Last four round trip time measurements in microsecond
uint16_t protocol_version; // dnbd3 protocol version of this server
uint8_t failures; // How many times the server was unreachable
-} dnbd3_server;
+};
-typedef struct dnbd3_sock {
+struct dnbd3_sock {
struct socket *sock;
struct mutex lock;
struct request *pending;
struct dnbd3_server *server;
uint32_t heartbeat_count;
uint32_t cookie;
- uint8_t panic, discover, panic_count;
+// uint8_t panic, discover, panic_count;
struct dnbd3_device *device;
struct work_struct keepalive;
struct timer_list keepalive_timer;
struct work_struct receive;
-} dnbd3_sock;
+};
-typedef struct dnbd3_device {
+struct dnbd3_device {
int minor;
struct blk_mq_tag_set tag_set;
struct list_head list;
@@ -72,10 +72,10 @@ typedef struct dnbd3_device {
struct mutex device_lock;
// network
- dnbd3_sock socks[NUMBER_CONNECTIONS];
+ struct dnbd3_sock socks[NUMBER_CONNECTIONS];
char *imgname;
- dnbd3_server initial_server;
- dnbd3_server alt_servers[NUMBER_SERVERS]; // array of alt servers
+ struct dnbd3_server initial_server;
+ struct dnbd3_server alt_servers[NUMBER_SERVERS]; // array of alt servers
int new_servers_num; // number of new alt servers that are waiting to be copied to above array
dnbd3_server_entry_t new_servers[NUMBER_SERVERS]; // pending new alt servers
uint8_t update_available;
@@ -85,10 +85,10 @@ typedef struct dnbd3_device {
struct work_struct discovery; // if in irq and need to send request
struct timer_list discovery_timer;
-} dnbd3_device;
+};
-typedef struct dnbd3_cmd {
+struct dnbd3_cmd {
struct dnbd3_device *dnbd3;
struct mutex lock;
// int index;
@@ -96,7 +96,7 @@ typedef struct dnbd3_cmd {
blk_status_t status;
unsigned long flags;
// uint32_t cmd_cookie;
-} dnbd3_cmd;
+};
#endif /* DNBD_H_ */
diff --git a/src/kernel/net.c b/src/kernel/net.c
index 5d3e344..7df8369 100644
--- a/src/kernel/net.c
+++ b/src/kernel/net.c
@@ -51,8 +51,8 @@
static DECLARE_WAIT_QUEUE_HEAD(send_wq);
static uint64_t send_wq_handle;
-static int dnbd3_socket_connect(dnbd3_device *dev, dnbd3_server *server);
-static int dnbd3_socket_disconnect(dnbd3_device *dev, dnbd3_server *server, dnbd3_sock *sock);
+static int dnbd3_socket_connect(struct dnbd3_device *dev, struct dnbd3_server *server);
+static int dnbd3_socket_disconnect(struct dnbd3_device *dev, struct dnbd3_server *server, struct dnbd3_sock *sock);
static void dnbd3_print_host(struct dnbd3_host_t *host, char *msg)
{
@@ -449,7 +449,7 @@ static void dnbd3_discovery_timer(struct timer_list *arg)
static void dnbd3_discovery_worker(struct work_struct *work)
{
struct dnbd3_device *dev = container_of(work, struct dnbd3_device, discovery);
- dnbd3_sock *sock = &dev->socks[0]; // we use the first sock for discovery
+ struct dnbd3_sock *sock = &dev->socks[0]; // we use the first sock for discovery
int i, j;
struct dnbd3_server *existing_server, *free_server, *failed_server;
dnbd3_server_entry_t *new_server;
@@ -574,7 +574,7 @@ error:
return result;
}
-static int dnbd3_socket_connect(dnbd3_device *dev, dnbd3_server *server)
+static int dnbd3_socket_connect(struct dnbd3_device *dev, struct dnbd3_server *server)
{
int i;
int result = -EIO;
@@ -675,10 +675,10 @@ static int dnbd3_socket_disconnect(struct dnbd3_device *dev, struct dnbd3_server
*/
if (sock->sock) {
kernel_sock_shutdown(sock->sock, SHUT_RDWR);
+ sock->server = NULL;
}
mutex_unlock(&sock->lock);
mutex_destroy(&sock->lock);
- sock->server = NULL;
printk(KERN_DEBUG "dnbd3: cancel receiver work device %i\n", dev->minor);
cancel_work_sync(&sock->receive);
diff --git a/src/kernel/sysfs.c b/src/kernel/sysfs.c
index 2c319e3..f5fb99a 100644
--- a/src/kernel/sysfs.c
+++ b/src/kernel/sysfs.c
@@ -29,7 +29,7 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
-ssize_t show_initial_server_addr(char *buf, dnbd3_device *dev)
+ssize_t show_initial_server_addr(char *buf, struct dnbd3_device *dev)
{
if (dev->initial_server.host.type == HOST_IP4)
return MIN(snprintf(buf, PAGE_SIZE, "%pI4,%d\n", dev->initial_server.host.addr, (int)ntohs(dev->initial_server.host.port)), PAGE_SIZE);
@@ -39,7 +39,7 @@ ssize_t show_initial_server_addr(char *buf, dnbd3_device *dev)
return 0;
}
-ssize_t show_connected_servers(char *buf, dnbd3_device *dev)
+ssize_t show_connected_servers(char *buf, struct dnbd3_device *dev)
{
int i, size = PAGE_SIZE, ret;
for (i = 0; i < NUMBER_CONNECTIONS; ++i) {
@@ -78,7 +78,7 @@ ssize_t show_connected_servers(char *buf, dnbd3_device *dev)
// return MIN(snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)dev->cur_rtt), PAGE_SIZE);
//}
-ssize_t show_alt_server_num(char *buf, dnbd3_device *dev)
+ssize_t show_alt_server_num(char *buf, struct dnbd3_device *dev)
{
int i, num = 0;
for (i = 0; i < NUMBER_SERVERS; ++i)
@@ -88,7 +88,7 @@ ssize_t show_alt_server_num(char *buf, dnbd3_device *dev)
return MIN(snprintf(buf, PAGE_SIZE, "%d\n", num), PAGE_SIZE);
}
-ssize_t show_alt_servers(char *buf, dnbd3_device *dev)
+ssize_t show_alt_servers(char *buf, struct dnbd3_device *dev)
{
int i, size = PAGE_SIZE, ret;
for (i = 0; i < NUMBER_SERVERS; ++i)
@@ -120,30 +120,30 @@ ssize_t show_alt_servers(char *buf, dnbd3_device *dev)
return PAGE_SIZE - size;
}
-ssize_t show_image_name(char *buf, dnbd3_device *dev)
+ssize_t show_image_name(char *buf, struct dnbd3_device *dev)
{
if (dev->imgname == NULL) return sprintf(buf, "(null)");
return MIN(snprintf(buf, PAGE_SIZE, "%s\n", dev->imgname), PAGE_SIZE);
}
-ssize_t show_rid(char *buf, dnbd3_device *dev)
+ssize_t show_rid(char *buf, struct dnbd3_device *dev)
{
return MIN(snprintf(buf, PAGE_SIZE, "%d\n", dev->rid), PAGE_SIZE);
}
-ssize_t show_update_available(char *buf, dnbd3_device *dev)
+ssize_t show_update_available(char *buf, struct dnbd3_device *dev)
{
return MIN(snprintf(buf, PAGE_SIZE, "%d\n", dev->update_available), PAGE_SIZE);
}
-device_attr_t initial_server =
+struct device_attr_t initial_server =
{
.attr = {.name = "initial_server", .mode = 0444 },
.show = show_initial_server_addr,
.store = NULL,
};
-device_attr_t connected_server =
+struct device_attr_t connected_server =
{
.attr = {.name = "connected_server", .mode = 0444 },
.show = show_connected_servers,
@@ -156,35 +156,35 @@ device_attr_t connected_server =
// .store = NULL,
//};
-device_attr_t alt_server_num =
+struct device_attr_t alt_server_num =
{
.attr = {.name = "alt_server_num", .mode = 0444 },
.show = show_alt_server_num,
.store = NULL,
};
-device_attr_t alt_servers =
+struct device_attr_t alt_servers =
{
.attr = {.name = "alt_servers", .mode = 0444 },
.show = show_alt_servers,
.store = NULL,
};
-device_attr_t image_name =
+struct device_attr_t image_name =
{
.attr = {.name = "image_name", .mode = 0444 },
.show = show_image_name,
.store = NULL,
};
-device_attr_t rid =
+struct device_attr_t rid =
{
.attr = {.name = "rid", .mode = 0444 },
.show = show_rid,
.store = NULL,
};
-device_attr_t update_available =
+struct device_attr_t update_available =
{
.attr = {.name = "update_available", .mode = 0444 },
.show = show_update_available,
@@ -193,8 +193,8 @@ device_attr_t update_available =
ssize_t device_show(struct kobject *kobj, struct attribute *attr, char *buf)
{
- device_attr_t *device_attr = container_of(attr, device_attr_t, attr);
- dnbd3_device *dev = container_of(kobj, dnbd3_device, kobj);
+ struct device_attr_t *device_attr = container_of(attr, struct device_attr_t, attr);
+ struct dnbd3_device *dev = container_of(kobj, struct dnbd3_device, kobj);
return device_attr->show(buf, dev);
}
@@ -217,7 +217,7 @@ struct sysfs_ops device_ops =
.show = device_show,
};
-void release(struct kobject *kobj)
+static void release(struct kobject *kobj)
{
kobj->state_initialized = 0;
}
@@ -230,7 +230,7 @@ struct kobj_type device_ktype =
};
-void dnbd3_sysfs_init(dnbd3_device *dev)
+void dnbd3_sysfs_init(struct dnbd3_device *dev)
{
int error;
struct kobject *kobj = &dev->kobj;
@@ -242,7 +242,7 @@ void dnbd3_sysfs_init(dnbd3_device *dev)
printk("Error initializing dnbd3 device!\n");
}
-void dnbd3_sysfs_exit(dnbd3_device *dev)
+void dnbd3_sysfs_exit(struct dnbd3_device *dev)
{
kobject_put(&dev->kobj);
}
diff --git a/src/kernel/sysfs.h b/src/kernel/sysfs.h
index b48acc3..7f40ff4 100644
--- a/src/kernel/sysfs.h
+++ b/src/kernel/sysfs.h
@@ -23,23 +23,21 @@
#include "dnbd3.h"
-void dnbd3_sysfs_init(dnbd3_device *dev);
+void dnbd3_sysfs_init(struct dnbd3_device *dev);
-void dnbd3_sysfs_exit(dnbd3_device *dev);
+void dnbd3_sysfs_exit(struct dnbd3_device *dev);
-typedef struct
-{
+struct device_attr_t {
struct attribute attr;
- ssize_t (*show)(char *, dnbd3_device *);
- ssize_t (*store)(const char *, size_t, dnbd3_device *);
-} device_attr_t;
+ ssize_t (*show)(char *, struct dnbd3_device *);
+ ssize_t (*store)(const char *, size_t, struct dnbd3_device *);
+};
-typedef struct
-{
+struct server_attr_t {
struct attribute attr;
- ssize_t (*show)(char *, dnbd3_server *);
- ssize_t (*store)(const char *, size_t, dnbd3_server *);
-} server_attr_t;
+ ssize_t (*show)(char *, struct dnbd3_server *);
+ ssize_t (*store)(const char *, size_t, struct dnbd3_server *);
+};
#endif /* SYSFS_H_ */