[PATCH] D39464: Define fs::allocate_file which preallocates disk blocks.

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 00:55:04 PDT 2017


mgorny added inline comments.


================
Comment at: llvm/lib/Support/Unix/Path.inc:443
+#ifdef HAVE_FALLOCATE
+  if (fallocate(FD, 0, 0, Size) == -1)
+    return std::error_code(errno, std::generic_category());
----------------
ruiu wrote:
> mgorny wrote:
> > Any reason not to use `posix_fallocate()` which is more portable by definition?
> `posix_fallocate` does not fail even on filesystems that do not support block preallocation. What it does (at least in glibc) when the underlying filesystem doesn't have the feature is to write a zero byte for each disk block to force the filesystem to actually allocate disk blocks. It is as you can imagine pretty slow.
Ok then.


https://reviews.llvm.org/D39464





More information about the llvm-commits mailing list