diff options
author | Simon Rettberg | 2020-02-24 14:13:01 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-02-24 14:13:01 +0100 |
commit | dd0880b8ee67f9a69802a2a3ef26cd5df6881129 (patch) | |
tree | 04cdf5c186b2c5959c77484b6198bcdb21a19329 /src/server/image.c | |
parent | [SERVER] Lookup image on storage even in proxy mode (diff) | |
download | dnbd3-dd0880b8ee67f9a69802a2a3ef26cd5df6881129.tar.gz dnbd3-dd0880b8ee67f9a69802a2a3ef26cd5df6881129.tar.xz dnbd3-dd0880b8ee67f9a69802a2a3ef26cd5df6881129.zip |
[SERVER] Introduce ignoreAllocErrors
If enabled, a failed fallocate will not abort image replication, but
retry with sparse mode.
Diffstat (limited to 'src/server/image.c')
-rw-r--r-- | src/server/image.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/image.c b/src/server/image.c index 16dae45..6017e59 100644 --- a/src/server/image.c +++ b/src/server/image.c @@ -1111,14 +1111,19 @@ bool image_create(char *image, int revision, uint64_t size) logadd( LOG_DEBUG1, "Could not allocate %d bytes for %s (errno=%d)", mapsize, cache, err ); } // Now write image + bool fallback = false; if ( !_sparseFiles && !file_alloc( fdImage, 0, size ) ) { logadd( LOG_ERROR, "Could not allocate %" PRIu64 " bytes for %s (errno=%d)", size, path, errno ); logadd( LOG_ERROR, "It is highly recommended to use a file system that supports preallocating disk" " space without actually writing all zeroes to the block device." ); logadd( LOG_ERROR, "If you cannot fix this, try setting sparseFiles=true, but don't expect" " divine performance during replication." ); - goto failure_cleanup; - } else if ( _sparseFiles && !file_setSize( fdImage, size ) ) { + if ( !_ignoreAllocErrors ) { + goto failure_cleanup; + } + fallback = true; + } + if ( ( _sparseFiles || fallback ) && !file_setSize( fdImage, size ) ) { logadd( LOG_ERROR, "Could not create sparse file of %" PRIu64 " bytes for %s (errno=%d)", size, path, errno ); logadd( LOG_ERROR, "Make sure you have enough disk space, check directory permissions, fs errors etc." ); goto failure_cleanup; |