summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kernel/core.c2
-rw-r--r--src/kernel/dnbd3.h10
-rw-r--r--src/kernel/net.c26
3 files changed, 33 insertions, 5 deletions
diff --git a/src/kernel/core.c b/src/kernel/core.c
index cc19b58..8bb23d9 100644
--- a/src/kernel/core.c
+++ b/src/kernel/core.c
@@ -104,7 +104,7 @@ again:
}
}
- if (!sock) {
+ if (!sock) { // TODO let the mq queues be the same number as NUMBER_CONNECTIONS than handle them
warn_dev(dev, "index is %d but no socket was found", index);
dev_err_ratelimited(disk_to_dev(dev->disk), "attempted send on invalid socket\n");
if (sock_alive > 0) {
diff --git a/src/kernel/dnbd3.h b/src/kernel/dnbd3.h
index edd19e1..2c3ec39 100644
--- a/src/kernel/dnbd3.h
+++ b/src/kernel/dnbd3.h
@@ -55,6 +55,11 @@
#define DEBUG_FILE 1
+//TODO test with ip tables regel. jedes x paket an port 58007 zerstoeren
+// iptables -A OUTPUT -p tcp -m statistic --mode random --probability 0.1 -j REJECT --reject-with tcp-reset
+//TODO setup mit 2 vms eine langsam eine schnell tc (traffic control)
+// -> geschwindigkkeit sollte in Richtung schnellen VM gehen mit 2 Queues
+
extern struct workqueue_struct *dnbd3_wq;
/**
@@ -68,7 +73,7 @@ struct dnbd3_server {
dnbd3_host_t host;
uint64_t rtts[4];
uint16_t protocol_version;
- uint8_t failures;
+ uint16_t failures; // TODO failures runterzaehlen wenn wieder verbindung moeglich, seltener messen bei hohem failure count
/*
* TODO would this help?
@@ -163,7 +168,7 @@ struct dnbd3_device {
struct dnbd3_sock socks[NUMBER_CONNECTIONS];
char *imgname;
struct dnbd3_server initial_server;
- struct dnbd3_server alt_servers[NUMBER_SERVERS];
+ struct dnbd3_server alt_servers[NUMBER_SERVERS];//TODO just add server to list do not remove
int new_servers_num;
dnbd3_server_entry_t new_servers[NUMBER_SERVERS];
bool update_available;
@@ -188,6 +193,7 @@ struct dnbd3_device {
* @requed: 'true' if the command is requed
*/
struct dnbd3_cmd {
+ //TODO do we want the socket here (index)?
struct dnbd3_device *dnbd3;
struct mutex lock;
uint32_t cookie;
diff --git a/src/kernel/net.c b/src/kernel/net.c
index 2d0b6ad..5478e95 100644
--- a/src/kernel/net.c
+++ b/src/kernel/net.c
@@ -208,6 +208,10 @@ int dnbd3_send_request(struct dnbd3_sock *sock, struct request *req,
result = kernel_sendmsg(sock->sock, &msg, iov, iov_num, lng);
if (result != lng) {
error_sock(sock, "connection to server lost");
+ if (cmd) {
+ blk_mq_requeue_request(req, true);
+ }
+ sock->panic = true;
sock->server->failures++;
goto error;
}
@@ -823,7 +827,7 @@ static void dnbd3_adjust_connections(struct dnbd3_device *dev) {
uint64_t best_rtt = RTT_UNREACHABLE;
struct dnbd3_server *server, *existing_server;
- /* connect empty sockets */
+ /* connect empty sockets */ //TODO check if panic worker connects at the same time, than we would have a problem
sock_alive = 0;
for (i = 0; i < NUMBER_CONNECTIONS; i++) {
if (!dnbd3_is_sock_alive(dev->socks[i])) {
@@ -1094,6 +1098,7 @@ static void dnbd3_merge_new_server(struct dnbd3_device *dev,
// existing_server->failures = 0; // reset failure count
return;
} else if (free_server) {
+ //TODO disconnect the server if it is connected
free_server->host = new_server->host;
} else if (failed_server) {
failed_server->host = new_server->host;
@@ -1357,6 +1362,13 @@ error:
return result;
}
+static void dnbd3_clear_req(struct request *req, void *data, bool reserved)
+{
+ struct dnbd3_cmd *cmd = blk_mq_rq_to_pdu(req);
+
+ cmd->status = BLK_STS_IOERR;
+ blk_mq_complete_request(req);
+}
/**
* dnbd3_socket_disconnect - disconnect a socket or server
@@ -1406,7 +1418,6 @@ static int dnbd3_socket_disconnect(struct dnbd3_sock *sock)
}
mutex_unlock(&sock->tx_lock);
mutex_destroy(&sock->tx_lock);
- blk_mq_update_nr_hw_queues(&dev->tag_set, sock_alive - 1);
cancel_work_sync(&sock->receive_worker);
@@ -1414,6 +1425,17 @@ static int dnbd3_socket_disconnect(struct dnbd3_sock *sock)
sock_release(sock->sock);
sock->sock = NULL;
}
+ debug_sock(sock, "update nr hw queues to %d", sock_alive -1);
+// blk_mq_quiesce_queue(dev->disk->queue);
+// debug_sock(sock, "busy iter");
+// blk_mq_tagset_busy_iter(&dev->tag_set, dnbd3_clear_req, NULL);
+// debug_sock(sock, "update");
+ //TODO can we just stop the failed queue?
+ blk_mq_update_nr_hw_queues(&dev->tag_set, sock_alive - 1);
+// debug_sock(sock, "unquisco");
+// blk_mq_unquiesce_queue(dev->disk->queue);
+// debug_sock(sock, "donee");
+
sock->server = NULL;
sock->panic = false;
return 0;