summaryrefslogtreecommitdiff
path: root/zen/file_io.cpp
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-06-20 07:46:53 -0400
committerB. Stack <bgstack15@gmail.com>2023-06-20 07:46:53 -0400
commitf76994f1fb3e25c4563c9d8afce6bbc86701d1d2 (patch)
treeb39389163603195a0169af57712eb0765e5c11f4 /zen/file_io.cpp
parentadd upstream 12.3 (diff)
downloadFreeFileSync-f76994f1fb3e25c4563c9d8afce6bbc86701d1d2.tar.gz
FreeFileSync-f76994f1fb3e25c4563c9d8afce6bbc86701d1d2.tar.bz2
FreeFileSync-f76994f1fb3e25c4563c9d8afce6bbc86701d1d2.zip
add upstream 12.412.4
Diffstat (limited to 'zen/file_io.cpp')
-rw-r--r--zen/file_io.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/zen/file_io.cpp b/zen/file_io.cpp
index 2e4ab60a..8c985f64 100644
--- a/zen/file_io.cpp
+++ b/zen/file_io.cpp
@@ -245,6 +245,11 @@ void FileOutputPlain::reserveSpace(uint64_t expectedSize) //throw FileError
try
{
+#if 0 /* fallocate(FALLOC_FL_KEEP_SIZE):
+ - perf: no real benefit (in a quick and dirty local test)
+ - breaks Btrfs compression: https://freefilesync.org/forum/viewtopic.php?t=10356
+ - apparently not even used by cp: https://github.com/coreutils/coreutils/blob/17479ef60c8edbd2fe8664e31a7f69704f0cd221/src/copy.c#LL1234C5-L1234C5 */
+
//don't use ::posix_fallocate which uses horribly inefficient fallback if FS doesn't support it (EOPNOTSUPP) and changes files size!
//FALLOC_FL_KEEP_SIZE => allocate only, file size is NOT changed!
if (::fallocate(getHandle(), //int fd
@@ -253,6 +258,7 @@ void FileOutputPlain::reserveSpace(uint64_t expectedSize) //throw FileError
expectedSize) != 0) //off_t len
if (errno != EOPNOTSUPP) //possible, unlike with posix_fallocate()
THROW_LAST_SYS_ERROR("fallocate");
+#endif
}
catch (const SysError& e) { throw FileError(replaceCpy(_("Cannot write file %x."), L"%x", fmtPath(getFilePath())), e.toString()); }
bgstack15