summaryrefslogtreecommitdiffstats
path: root/src/server/globals.h
diff options
context:
space:
mode:
authorSimon Rettberg2020-03-04 17:49:50 +0100
committerSimon Rettberg2020-03-04 17:49:50 +0100
commit930b65f26cb39687a113641f56711a2d58f886ca (patch)
treee0a0c5e73ea9820a4d64641209bde320359c37a2 /src/server/globals.h
parent[SERVER] Likewise, get rid of same loops in client handler (diff)
downloaddnbd3-930b65f26cb39687a113641f56711a2d58f886ca.tar.gz
dnbd3-930b65f26cb39687a113641f56711a2d58f886ca.tar.xz
dnbd3-930b65f26cb39687a113641f56711a2d58f886ca.zip
[SERVER] Add timer task for saving cache maps
Cache maps will now be saved periodically, but only if either they have a "dirty" bit set, which happens if any bits in the map get cleared again (due to corruption), or if new data has been replicated from an uplink server. This either means at least one byte received and 5 minutes have passed, or at least 500MB have been downloaded. The timer currently runs every 20 seconds.
Diffstat (limited to 'src/server/globals.h')
-rw-r--r--src/server/globals.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/server/globals.h b/src/server/globals.h
index 5de4180..10d3ee3 100644
--- a/src/server/globals.h
+++ b/src/server/globals.h
@@ -93,6 +93,7 @@ struct _dnbd3_uplink
// If BGR == BGR_HASHBLOCK, -1 means "currently no incomplete block"
uint64_t replicationHandle; // Handle of pending replication request
atomic_uint_fast64_t bytesReceived; // Number of bytes received by the uplink since startup.
+ atomic_uint_fast64_t bytesReceivedLastSave; // Number of bytes received when we last saved the cache map
int queueLen; // length of queue
uint32_t idleTime; // How many seconds the uplink was idle (apart from keep-alives)
dnbd3_queued_request_t queue[SERVER_MAX_UPLINK_QUEUE];
@@ -128,7 +129,6 @@ struct _dnbd3_image
uint64_t virtualFilesize; // virtual size of image (real size rounded up to multiple of 4k)
uint64_t realFilesize; // actual file size on disk
ticks atime; // last access time
- ticks lastWorkCheck; // last time a non-working image has been checked
ticks nextCompletenessEstimate; // next time the completeness estimate should be updated
uint32_t *crc32; // list of crc32 checksums for each 16MiB block in image
uint32_t masterCrc32; // CRC-32 of the crc-32 list
@@ -144,6 +144,7 @@ struct _dnbd3_image
atomic_bool queue; // Too many requests waiting on uplink
} problem;
uint16_t rid; // revision of image
+ atomic_bool mapDirty; // Cache map has been modified outside uplink (only integrity checker for now)
pthread_mutex_t lock;
};