summaryrefslogtreecommitdiffstats
path: root/src/server
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
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')
-rw-r--r--src/server/altservers.c4
-rw-r--r--src/server/uplink.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/server/altservers.c b/src/server/altservers.c
index d0bb206..27fb27e 100644
--- a/src/server/altservers.c
+++ b/src/server/altservers.c
@@ -451,6 +451,7 @@ static void *altservers_main(void *data UNUSED)
logadd( LOG_DEBUG1, "Image has gone away that was queued for RTT measurement\n" );
continue;
}
+ logadd( LOG_DEBUG2, "Running altcheck for '%s:%d'", image->name, (int)image->rid );
assert( uplink->rttTestResult == RTT_INPROGRESS );
// Now get 4 alt servers
numAlts = altservers_getListForUplink( servers, ALTS, uplink->fd == -1 );
@@ -474,7 +475,7 @@ static void *altservers_main(void *data UNUSED)
usleep( 1000 ); // Wait a very short moment for the network to recover (we might be doing lots of measurements...)
// Connect
clock_gettime( BEST_CLOCK_SOURCE, &start );
- int sock = sock_connect( &servers[itAlt], 750, _uplinkTimeout );
+ int sock = sock_connect( &servers[itAlt], 750, 1000 );
if ( sock < 0 ) continue;
// Select image ++++++++++++++++++++++++++++++
if ( !dnbd3_select_image( sock, image->name, image->rid, SI_SERVER_FLAGS ) ) {
@@ -560,6 +561,7 @@ static void *altservers_main(void *data UNUSED)
if ( bestSock != -1 && (uplink->fd == -1 || (bestRtt < 10000000 && RTT_THRESHOLD_FACTOR(currentRtt) > bestRtt)) ) {
// yep
logadd( LOG_DEBUG1, "Change @ %s - best: %luµs, current: %luµs\n", image->name, bestRtt, currentRtt );
+ sock_setTimeout( bestSock, _uplinkTimeout );
spin_lock( &uplink->rttLock );
uplink->betterFd = bestSock;
uplink->betterServer = servers[bestIndex];
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