summaryrefslogtreecommitdiffstats
path: root/src/server/globals.h
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-04 14:39:43 +0200
committerSimon Rettberg2018-07-04 14:39:43 +0200
commit053ca3b9a9601467d5ce30c56c3cea078c897f57 (patch)
tree29b60273e13684bb98b1badcd784b6f2b2e4d0f4 /src/server/globals.h
parent[SERVER] cmake: Add config option for extra compiler opptions (diff)
downloaddnbd3-053ca3b9a9601467d5ce30c56c3cea078c897f57.tar.gz
dnbd3-053ca3b9a9601467d5ce30c56c3cea078c897f57.tar.xz
dnbd3-053ca3b9a9601467d5ce30c56c3cea078c897f57.zip
[SERVER] Refactor uplink/cache handling, improve crc checking
The cacheFd is now moved to the uplink data structure and will only be handled by the uplink thread. The integrity checker now supports checking all blocks of an image. This will be triggered automatically whenever a check for a single block failed. Also, if a crc check on startup fails, the image won't be discarded anymore, but rather a full check will be initiated. Furthermore, when calling image_updateCacheMap() on an image that was previously complete, the cache map will now be re-initialized, and a new uplink connection created.
Diffstat (limited to 'src/server/globals.h')
-rw-r--r--src/server/globals.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/server/globals.h b/src/server/globals.h
index 2e39cb8..2fd1af2 100644
--- a/src/server/globals.h
+++ b/src/server/globals.h
@@ -57,9 +57,10 @@ struct _dnbd3_connection
dnbd3_host_t currentServer; // Current server we're connected to
pthread_spinlock_t rttLock; // When accessing rttTestResult, betterFd or betterServer
int rttTestResult; // RTT_*
- dnbd3_host_t betterServer; // The better server
+ int cacheFd; // used to write to the image, in case it is relayed. ONLY USE FROM UPLINK THREAD!
int betterVersion; // protocol version of better server
int betterFd; // Active connection to better server, ready to use
+ dnbd3_host_t betterServer; // The better server
uint8_t *recvBuffer; // Buffer for receiving payload
uint32_t recvBufferLen; // Len of ^^
volatile bool shutdown; // signal this thread to stop, must only be set from uplink_shutdown() or cleanup in uplink_mainloop()
@@ -70,6 +71,7 @@ struct _dnbd3_connection
uint64_t bytesReceived; // Number of bytes received by the connection.
uint64_t lastBytesReceived; // Number of bytes received last time we updated the global counter.
int queueLen; // length of queue
+ int idleCount; // How many iterations of keepalive check connection was idle
dnbd3_queued_request_t queue[SERVER_MAX_UPLINK_QUEUE];
};
@@ -112,7 +114,6 @@ struct _dnbd3_image
uint32_t *crc32; // list of crc32 checksums for each 16MiB block in image
uint32_t masterCrc32; // CRC-32 of the crc-32 list
int readFd; // used to read the image. Used from multiple threads, so use atomic operations (pread et al)
- int cacheFd; // used to write to the image, in case it is relayed. ONLY USE FROM UPLINK THREAD!
int completenessEstimate; // Completeness estimate in percent
int users; // clients currently using this image
int id; // Unique ID of this image. Only unique in the context of this running instance of DNBD3-Server