summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-03-24 15:03:34 +0100
committerSimon Rettberg2022-03-24 15:03:34 +0100
commit9abe9e6b16e3e460ac4e8e5c1fd75d8745d8fea7 (patch)
tree87ee76db89e51f0399e85d535d978762427cc8e7
parent[KERNEL] Fix possible stall when switching server (diff)
downloaddnbd3-9abe9e6b16e3e460ac4e8e5c1fd75d8745d8fea7.tar.gz
dnbd3-9abe9e6b16e3e460ac4e8e5c1fd75d8745d8fea7.tar.xz
dnbd3-9abe9e6b16e3e460ac4e8e5c1fd75d8745d8fea7.zip
[KERNEL] IOCTL_SWITCH: Always boost/fake RTT values
Even if we didn't switch because we already use the requested server.
-rw-r--r--src/kernel/blk.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/kernel/blk.c b/src/kernel/blk.c
index bc18c44..6e9952b 100644
--- a/src/kernel/blk.c
+++ b/src/kernel/blk.c
@@ -211,25 +211,25 @@ static int dnbd3_blk_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
if (result != 0) {
/* switching didn't work */
result = -EAGAIN;
- } else {
- /* switch succeeded */
- /* fake RTT so we don't switch away again soon */
- mutex_lock(&dev->alt_servers_lock);
- for (i = 0; i < NUMBER_SERVERS; ++i) {
- alt_server = &dev->alt_servers[i];
- if (is_same_server(&alt_server->host, &new_addr)) {
- for (j = 0; j < DISCOVER_HISTORY_SIZE; ++j)
- alt_server->rtts[j] = 1;
- alt_server->best_count = 100;
- } else {
- for (j = 0; j < DISCOVER_HISTORY_SIZE; ++j)
- if (alt_server->rtts[j] < 5000)
- alt_server->rtts[j] = 5000;
- alt_server->best_count = 0;
- }
+ }
+ }
+ if (result == 0) {
+ /* fake RTT so we don't switch away again soon */
+ mutex_lock(&dev->alt_servers_lock);
+ for (i = 0; i < NUMBER_SERVERS; ++i) {
+ alt_server = &dev->alt_servers[i];
+ if (is_same_server(&alt_server->host, &new_addr)) {
+ for (j = 0; j < DISCOVER_HISTORY_SIZE; ++j)
+ alt_server->rtts[j] = 1;
+ alt_server->best_count = 100;
+ } else {
+ for (j = 0; j < DISCOVER_HISTORY_SIZE; ++j)
+ if (alt_server->rtts[j] < 5000)
+ alt_server->rtts[j] = 5000;
+ alt_server->best_count = 0;
}
- mutex_unlock(&dev->alt_servers_lock);
}
+ mutex_unlock(&dev->alt_servers_lock);
}
}
}