summaryrefslogtreecommitdiffstats
path: root/src/server/uplink.c
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-08 16:57:08 +0100
committerSimon Rettberg2017-11-08 16:57:08 +0100
commit57d333b8d7b77be83872ad39007940bb93e2cfa0 (patch)
tree4c0be45516d6df6481c0f9f73f9442c3a6cd4c0f /src/server/uplink.c
parent[SERVER] rpc: Add q=logfile, q=altservers and q=config to /query (diff)
downloaddnbd3-57d333b8d7b77be83872ad39007940bb93e2cfa0.tar.gz
dnbd3-57d333b8d7b77be83872ad39007940bb93e2cfa0.tar.xz
dnbd3-57d333b8d7b77be83872ad39007940bb93e2cfa0.zip
[SERVER] altservers: Short timeout during RTT measurement, round request range
Rounding to 4k so caching works efficiently This should now close #3231
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r--src/server/uplink.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c
index bed7b54..aec47cb 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -473,14 +473,17 @@ static void uplink_sendRequests(dnbd3_connection_t *link, bool newOnly)
spin_lock( &link->queueLock );
for (j = 0; j < link->queueLen; ++j) {
if ( link->queue[j].status != ULR_NEW && (newOnly || link->queue[j].status != ULR_PENDING) ) continue;
- //logadd( LOG_DEBUG2 %p] Sending slot %d, now %d, handle %" PRIu64 ", Range: %" PRIu64 "-%" PRIu64 "\n", (void*)link, j, link->queue[j].status, link->queue[j].handle, link->queue[j].from, link->queue[j, ".to );
link->queue[j].status = ULR_PENDING;
- const uint64_t offset = link->queue[j].from;
- const uint32_t size = (uint32_t)( link->queue[j].to - link->queue[j].from );
uint8_t hops = link->queue[j].hopCount;
+ const uint64_t reqStart = link->queue[j].from & ~(uint64_t)(DNBD3_BLOCK_SIZE - 1);
+ const uint32_t reqSize = (uint32_t)(((link->queue[j].to + DNBD3_BLOCK_SIZE - 1) & ~(uint64_t)(DNBD3_BLOCK_SIZE - 1)) - reqStart);
+ /*
+ logadd( LOG_DEBUG2, "[%p] Sending slot %d, now %d, handle %" PRIu64 ", Range: %" PRIu64 "-%" PRIu64 " (%" PRIu64 "-%" PRIu64 ")",
+ (void*)link, j, link->queue[j].status, link->queue[j].handle, link->queue[j].from, link->queue[j].to, reqStart, reqStart+reqSize );
+ */
spin_unlock( &link->queueLock );
if ( hops < 200 ) ++hops;
- const int ret = dnbd3_get_block( link->fd, offset, size, offset, COND_HOPCOUNT( link->version, hops ) );
+ const int ret = dnbd3_get_block( link->fd, reqStart, reqSize, reqStart, COND_HOPCOUNT( link->version, hops ) );
if ( !ret ) {
// Non-critical - if the connection dropped or the server was changed
// the thread will re-send this request as soon as the connection