summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederic Robra2019-11-08 13:49:47 +0100
committerFrederic Robra2019-11-08 13:49:47 +0100
commitb57dadc2dd577fb8ce21975722cdfa2f010cd718 (patch)
treef96137339a2a8cf39def653cb205f06ca312c647 /src
parentif connection is lost while connected modul now waits for new connection (diff)
downloaddnbd3-ng-b57dadc2dd577fb8ce21975722cdfa2f010cd718.tar.gz
dnbd3-ng-b57dadc2dd577fb8ce21975722cdfa2f010cd718.tar.xz
dnbd3-ng-b57dadc2dd577fb8ce21975722cdfa2f010cd718.zip
added timeout and small bug when reqeuing in send
Diffstat (limited to 'src')
-rw-r--r--src/kernel/core.c1
-rw-r--r--src/kernel/mq.c27
-rw-r--r--src/kernel/net-txrx.c12
3 files changed, 23 insertions, 17 deletions
diff --git a/src/kernel/core.c b/src/kernel/core.c
index 4ef7221..7e05505 100644
--- a/src/kernel/core.c
+++ b/src/kernel/core.c
@@ -277,6 +277,7 @@ int dnbd3_add_device(struct dnbd3_device *dev, int minor)
dev->tag_set.ops = &dnbd3_mq_ops;
/* this can be changed later with blk_mq_update_nr_hw_queues() */
dev->tag_set.nr_hw_queues = 1;
+ dev->tag_set.timeout = 5 * HZ;
dev->tag_set.queue_depth = 128;
dev->tag_set.numa_node = NUMA_NO_NODE;
dev->tag_set.cmd_size = sizeof(struct dnbd3_cmd);
diff --git a/src/kernel/mq.c b/src/kernel/mq.c
index f859c0f..f9e1bd2 100644
--- a/src/kernel/mq.c
+++ b/src/kernel/mq.c
@@ -109,18 +109,22 @@ void dndb3_reque_busy_requests(struct dnbd3_sock *sock)
blk_mq_tagset_busy_iter(set,(busy_tag_iter_fn *) dnbd3_busy_iter_requeue, sock);
}
-static void dnbd3_wait_for_sockets(struct dnbd3_cmd * cmd) {
+/**
+ * dnbd3_wait_for_sockets - wait for any socket to be alive or a disconnect
+ * @dev: the device
+ */
+static void dnbd3_wait_for_sockets(struct dnbd3_device *dev) {
int i;
bool wait = true;
- while (wait && cmd->dnbd3->connected) {
- for (i = 0; i < cmd->dnbd3->number_connections; i++) {
- if (dnbd3_is_sock_alive(cmd->dnbd3->socks[cmd->index])) {
+ while (wait && dev->connected) {
+ for (i = 0; i < dev->number_connections; i++) {
+ if (dnbd3_is_sock_alive(dev->socks[i])) {
wait = false;
}
- if (wait && cmd->dnbd3->connected) {
- debug("no socket alive sleeping");
- msleep(100);
- }
+ }
+ if (wait && dev->connected) {
+ debug("no socket alive sleeping");
+ msleep(100);
}
}
}
@@ -132,7 +136,7 @@ static void dnbd3_wait_for_sockets(struct dnbd3_cmd * cmd) {
void dnbd3_requeue_cmd(struct dnbd3_cmd *cmd)
{
struct request *req = blk_mq_rq_from_pdu(cmd);
- dnbd3_wait_for_sockets(cmd);
+ dnbd3_wait_for_sockets(cmd->dnbd3);
if (!cmd->requed/* && blk_queued_rq(req)*/) {
cmd->requed = true;
@@ -152,11 +156,6 @@ void dnbd3_end_cmd(struct dnbd3_cmd *cmd, blk_status_t error)
}
-void dnbd3_end_all_rq(struct dnbd3_device *dev)
-{
- struct request_queue *q = dev->disk->queue;
-}
-
/**
* dnbd3_handle_cmd - handles a mq command
* @cmd: the cmd to send
diff --git a/src/kernel/net-txrx.c b/src/kernel/net-txrx.c
index 87a9169..27b07ea 100644
--- a/src/kernel/net-txrx.c
+++ b/src/kernel/net-txrx.c
@@ -165,14 +165,20 @@ int dnbd3_send_request(struct dnbd3_sock *sock, struct request *req,
lng = iov_num == 1 ? iov[0].iov_len : iov[0].iov_len + iov[1].iov_len;
if (unlikely(!sock->sock)) {
warn_sock(sock, "socket was shutdown while sending");
+ result = -EIO;
goto error;
}
result = kernel_sendmsg(sock->sock, &msg, iov, iov_num, lng);
if (result != lng) {
error_sock(sock, "connection to server lost");
- if (cmd) {
- dnbd3_requeue_cmd(cmd);
- }
+ /*
+ * this triggers:
+ * kernel BUG at block/blk-mq.c:704!
+ * command will be reqeued by timeout
+ */
+// if (cmd) {
+// dnbd3_requeue_cmd(cmd);
+// }
sock->server->failures++;
goto error;
}