summaryrefslogtreecommitdiffstats
path: root/src/server/globals.c
diff options
context:
space:
mode:
authorSimon Rettberg2018-03-15 22:03:36 +0100
committerSimon Rettberg2018-03-15 22:03:36 +0100
commit09dbfb968c4ef469f4a43dad3b9818fd2ed4ef82 (patch)
treea2e936ba7e199badad7b18efa71576203bf5b48b /src/server/globals.c
parent[SERVER] Make TSAN happy (diff)
downloaddnbd3-09dbfb968c4ef469f4a43dad3b9818fd2ed4ef82.tar.gz
dnbd3-09dbfb968c4ef469f4a43dad3b9818fd2ed4ef82.tar.xz
dnbd3-09dbfb968c4ef469f4a43dad3b9818fd2ed4ef82.zip
[SERVER] Experimental support for sparse files in proxy mode
Will not preallocate images in this mode. Old images are only deleted if the disk is full, determined by write() calls to the cache file yielding ENOSPC or EDQUOT. In such a case, the least recently used image(s) will be deleted to free up at least 256MiB, and then the write() call will be repeated. This *should* work somewhat reliably unless the cache partition is ridiculously small. Performance might suffer a little, and disk fragmentation might occur much faster than in prealloc mode. Testing is needed.
Diffstat (limited to 'src/server/globals.c')
-rw-r--r--src/server/globals.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/server/globals.c b/src/server/globals.c
index b1775f0..0502bbc 100644
--- a/src/server/globals.c
+++ b/src/server/globals.c
@@ -18,6 +18,7 @@ int _clientPenalty = 0;
bool _isProxy = false;
bool _backgroundReplication = true;
bool _lookupMissingForProxy = true;
+bool _sparseFiles = false;
bool _removeMissingImages = true;
int _uplinkTimeout = SOCKET_TIMEOUT_UPLINK;
int _clientTimeout = SOCKET_TIMEOUT_CLIENT;
@@ -54,6 +55,7 @@ static int ini_handler(void *custom UNUSED, const char* section, const char* key
SAVE_TO_VAR_BOOL( dnbd3, proxyPrivateOnly );
SAVE_TO_VAR_BOOL( dnbd3, backgroundReplication );
SAVE_TO_VAR_BOOL( dnbd3, lookupMissingForProxy );
+ SAVE_TO_VAR_BOOL( dnbd3, sparseFiles );
SAVE_TO_VAR_BOOL( dnbd3, removeMissingImages );
SAVE_TO_VAR_BOOL( dnbd3, closeUnusedFd );
SAVE_TO_VAR_UINT( dnbd3, serverPenalty );
@@ -146,6 +148,10 @@ void globals_loadConfig()
}
}
}
+ if ( _backgroundReplication && _sparseFiles ) {
+ logadd( LOG_WARNING, "Ignoring 'sparseFiles=true' since backgroundReplication is set to true" );
+ _sparseFiles = false;
+ }
// Dump config as interpreted
char buffer[2000];
globals_dumpConfig( buffer, sizeof(buffer) );
@@ -257,6 +263,7 @@ size_t globals_dumpConfig(char *buffer, size_t size)
PBOOL(isProxy);
PBOOL(backgroundReplication);
PBOOL(lookupMissingForProxy);
+ PBOOL(sparseFiles);
PBOOL(removeMissingImages);
PINT(uplinkTimeout);
PINT(clientTimeout);