summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kernel/blk.c4
-rw-r--r--src/kernel/net.c15
-rw-r--r--src/server/uplink.c1
3 files changed, 13 insertions, 7 deletions
diff --git a/src/kernel/blk.c b/src/kernel/blk.c
index 82469f4..d0a3b00 100644
--- a/src/kernel/blk.c
+++ b/src/kernel/blk.c
@@ -243,8 +243,8 @@ static int dnbd3_blk_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
for (i = 0; i < NUMBER_SERVERS; ++i) {
alt_server = &dev->alt_servers[i];
if (is_same_server(&alt_server->host, &new_addr)) {
- alt_server->rtts[0] = alt_server->rtts[1] = alt_server->rtts[2]
- = alt_server->rtts[3] = 4;
+ alt_server->rtts[0] = alt_server->rtts[1]
+ = alt_server->rtts[2] = alt_server->rtts[3] = 4;
alt_server->best_count = 100;
} else {
alt_server->rtts[0] <<= 2;
diff --git a/src/kernel/net.c b/src/kernel/net.c
index b206d5a..0eb1d5e 100644
--- a/src/kernel/net.c
+++ b/src/kernel/net.c
@@ -471,7 +471,8 @@ static int dnbd3_net_send(void *data)
return 0;
cleanup:
- if (!atomic_read(&dev->connection_lock)) {
+ if (!atomic_read(&dev->connection_lock) && !kthread_should_stop()) {
+ dev_dbg(dnbd3_device_to_dev(dev), "send thread: Triggering panic mode...\n");
if (dev->sock)
kernel_sock_shutdown(dev->sock, SHUT_RDWR);
dev->panic = 1;
@@ -540,7 +541,6 @@ static int dnbd3_net_receive(void *data)
/* for all errors other than -EAGAIN, print message and abort thread */
if (!atomic_read(&dev->connection_lock))
dnbd3_dev_err_host_cur(dev, "connection to server lost (receive)\n");
- ret = -ESHUTDOWN;
goto cleanup;
}
}
@@ -548,7 +548,7 @@ static int dnbd3_net_receive(void *data)
/* check if arrived data is valid */
if (ret != sizeof(dnbd3_reply)) {
if (!atomic_read(&dev->connection_lock))
- dnbd3_dev_err_host_cur(dev, "recv msg header\n");
+ dnbd3_dev_err_host_cur(dev, "recv partial msg header (%d bytes)\n", ret);
ret = -EINVAL;
goto cleanup;
}
@@ -605,10 +605,14 @@ static int dnbd3_net_receive(void *data)
dnbd3_dev_dbg_host_cur(
dev, "remote peer has performed an orderly shutdown\n");
ret = 0;
+ } else if (ret < 0) {
+ if (!atomic_read(&dev->connection_lock))
+ dnbd3_dev_err_host_cur(dev,
+ "disconnect: receiving from net to block layer\n");
} else {
if (!atomic_read(&dev->connection_lock))
dnbd3_dev_err_host_cur(dev,
- "receiving from net to block layer\n");
+ "receiving from net to block layer (%d bytes)\n", ret);
ret = -EINVAL;
}
// Requeue request
@@ -696,7 +700,8 @@ static int dnbd3_net_receive(void *data)
return 0;
cleanup:
- if (!atomic_read(&dev->connection_lock)) {
+ if (!atomic_read(&dev->connection_lock) && !kthread_should_stop()) {
+ dev_dbg(dnbd3_device_to_dev(dev), "recv thread: Triggering panic mode...\n");
if (dev->sock)
kernel_sock_shutdown(dev->sock, SHUT_RDWR);
dev->panic = 1;
diff --git a/src/server/uplink.c b/src/server/uplink.c
index 11c9d05..4329663 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -973,6 +973,7 @@ static void handleReceive(dnbd3_uplink_t *uplink)
dnbd3_reply_t inReply;
int ret;
assert_uplink_thread();
+ assert( uplink->queueLen >= 0 );
for (;;) {
ret = dnbd3_read_reply( uplink->current.fd, &inReply, false );
if ( unlikely( ret == REPLY_INTR ) && likely( !_shutdown && !uplink->shutdown ) ) continue;