summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Robra2019-10-20 13:46:56 +0200
committerFrederic Robra2019-10-20 13:46:56 +0200
commitf5e2caf1f369ec06d50650a2e1dbd859b0fa3b04 (patch)
tree1ede19bdbff21a9b731e83b6feb29a96f7c0bb67
parentpatch from Thiago Abdo, casts and includ (diff)
downloaddnbd3-ng-f5e2caf1f369ec06d50650a2e1dbd859b0fa3b04.tar.gz
dnbd3-ng-f5e2caf1f369ec06d50650a2e1dbd859b0fa3b04.tar.xz
dnbd3-ng-f5e2caf1f369ec06d50650a2e1dbd859b0fa3b04.zip
added comments
-rw-r--r--src/kernel/core.c2
-rw-r--r--src/kernel/dnbd3.h9
-rw-r--r--src/kernel/mq.c15
-rw-r--r--src/kernel/mq.h5
-rw-r--r--src/kernel/net-txrx.h8
-rw-r--r--src/kernel/net.c31
-rw-r--r--src/kernel/net.h12
7 files changed, 41 insertions, 41 deletions
diff --git a/src/kernel/core.c b/src/kernel/core.c
index 6e9ce2b..874980b 100644
--- a/src/kernel/core.c
+++ b/src/kernel/core.c
@@ -212,7 +212,7 @@ static int dnbd3_ioctl(struct block_device *bdev, fmode_t mode,
break;
default:
- warn_dev(dev, "ioctl unhandled cmd %d", cmd);
+ debug_dev(dev, "ioctl unhandled cmd %d", cmd);
result = -EIO;
break;
}
diff --git a/src/kernel/dnbd3.h b/src/kernel/dnbd3.h
index 848acdd..437edec 100644
--- a/src/kernel/dnbd3.h
+++ b/src/kernel/dnbd3.h
@@ -76,7 +76,6 @@ struct dnbd3_server {
* @server: the server this socket is connected to, 'NULL' if not connected
* @tx_lock: mutex to lock when sending
* @sock: the socket, 'NULL' if not connected
- * @panic: 'true' if it is not possible to send or receive
* @cookie: is incremented for every send, used to find the mq request in the
* receiver
* @keepalive_worker: worker to send a keepalive package
@@ -91,7 +90,6 @@ struct dnbd3_sock {
struct mutex tx_lock;
struct socket *sock;
-// bool panic;
uint32_t cookie;
struct work_struct keepalive_worker;
@@ -108,10 +106,10 @@ struct dnbd3_sock {
* @disk: the gendisk
* @kobj: the kobject
* @device_lock: mutex to lock when device changes
- * @socks: array of dnbd3_sock to connect to
+ * @connected: 'true' when device is connected
+ * @number_connections: the nummber of parallel connections
+ * @socks: array of dnbd3_sock to connect to, the size is number_connections
* @imgname: the connected image name
- * @initial_server: the server which was configured with ioctl, will not be
- * overriden
* @alt_servers: array of alternative servers
* @new_servers_num: number of new alternative servers that are waiting to be
* copied to above array
@@ -165,7 +163,6 @@ struct dnbd3_device {
* @dnbd3: the dnbd3 device this command belongs to
* @lock: mutex to lock the cmd
* @cookie: the cookie of the command, this is set by the socket when sending
- * @status: the status of the command
* @requed: 'true' if the command is requed
*/
struct dnbd3_cmd {
diff --git a/src/kernel/mq.c b/src/kernel/mq.c
index d83f7e4..34a8a5b 100644
--- a/src/kernel/mq.c
+++ b/src/kernel/mq.c
@@ -25,9 +25,9 @@
#include <linux/blk-mq.h>
/**
- * dnbd3_busy_iter - iterator for blk_mq_tagset_busy_iter
+ * dnbd3_busy_iter - iterator to set a bit for busy reqeust
* @req: the request
- * @priv: the passed argument from blk_mq_tagset_busy_iter
+ * @priv: the passed argument busy
* @arg: unknown
*/
static void dnbd3_busy_iter(struct request *req, void *priv, bool arg)
@@ -70,6 +70,13 @@ unsigned long dnbd3_is_mq_busy(struct dnbd3_device *dev)
return busy;
}
+
+/**
+ * dnbd3_busy_iter - iterator to requeue inflight commands
+ * @req: the request
+ * @priv: the passed argument from blk_mq_tagset_busy_iter
+ * @arg: unknown
+ */
static void dnbd3_busy_iter_requeue(struct request *req, void *priv, bool arg)
{
struct dnbd3_sock *sock = priv;
@@ -83,6 +90,10 @@ static void dnbd3_busy_iter_requeue(struct request *req, void *priv, bool arg)
mutex_unlock(&cmd->lock);
}
+/**
+ * dndb3_reque_busy_requests - reque busy (inflight) requests
+ * @sock: the socket
+ */
void dndb3_reque_busy_requests(struct dnbd3_sock *sock)
{
struct blk_mq_tag_set *set = &sock->device->tag_set;
diff --git a/src/kernel/mq.h b/src/kernel/mq.h
index c29e99a..fad285c 100644
--- a/src/kernel/mq.h
+++ b/src/kernel/mq.h
@@ -32,6 +32,11 @@
*/
unsigned long dnbd3_is_mq_busy(struct dnbd3_device *dev);
+
+/**
+ * dndb3_reque_busy_requests - reque busy (inflight) requests
+ * @sock: the socket
+ */
void dndb3_reque_busy_requests(struct dnbd3_sock *sock);
/**
diff --git a/src/kernel/net-txrx.h b/src/kernel/net-txrx.h
index 3636ffe..3c57ca4 100644
--- a/src/kernel/net-txrx.h
+++ b/src/kernel/net-txrx.h
@@ -29,6 +29,14 @@
#define dnbd3_is_sock_alive(s) ((s).sock && (s).server)
+/**
+ * dnbd3_send_request - send a request
+ * @sock: the socket where the request is send
+ * @req: the request to send
+ * @cmd: optional - the dnbd3_cmd from mq
+ *
+ * the tx_lock of the socket must be held
+ */
int dnbd3_send_request(struct dnbd3_sock *sock, struct request *req, struct dnbd3_cmd *cmd);
/**
diff --git a/src/kernel/net.c b/src/kernel/net.c
index 0cedb4c..a837702 100644
--- a/src/kernel/net.c
+++ b/src/kernel/net.c
@@ -235,37 +235,6 @@ static struct dnbd3_server **dnbd3_sort_server(struct dnbd3_device *dev) {
return sorted_servers;
}
-//static int dnbd3_panic_connect(struct dnbd3_device *dev)
-//{
-// struct dnbd3_server *working = NULL;
-// int i;
-// debug_dev(dev, "panic connect");
-// for (i = 0; i < NUMBER_CONNECTIONS; i++) {
-// if (dnbd3_is_sock_alive(dev->socks[i])) {
-// working = dev->socks[i].server;
-// debug_server(dev, working, "found server for panic");
-// }
-// }
-// if (working == NULL) {
-// for (i = 0; i < NUMBER_SERVERS; i++) {
-// if (!dnbd3_socket_connect(&dev->socks[0],
-// &dev->alt_servers[i])) {
-// working = &dev->alt_servers[i];
-// debug_server(dev, working, "found server for panic");
-// }
-// }
-// }
-// if (working == NULL) {
-// return -ENOENT;
-// }
-// for (i = 0; i < NUMBER_CONNECTIONS; i++) {
-// if (dev->socks[i].server != working) {
-// dnbd3_socket_connect(&dev->socks[i], working);
-// }
-// }
-// return 0;
-//}
-
/**
* dnbd3_compare_servers - comparator for the connecion plan
* @lhs: left hand sign
diff --git a/src/kernel/net.h b/src/kernel/net.h
index b8df66e..5800e42 100644
--- a/src/kernel/net.h
+++ b/src/kernel/net.h
@@ -25,8 +25,18 @@
#include "dnbd3.h"
-
+/**
+ * dnbd3_net_connect - connect device
+ * @dev: the device to connect
+ *
+ * dnbd3_device.alt_servers[0] must be set
+ */
int dnbd3_net_connect(struct dnbd3_device *dev);
+
+/**
+ * dnbd3_net_disconnect - disconnect device
+ * @dev: the device to disconnect
+ */
int dnbd3_net_disconnect(struct dnbd3_device *dev);
#endif /* NET_H_ */