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

Mark Kettenis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 06:09:54 PDT 2017


kettenis 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());
----------------
mgorny wrote:
> 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.
Can I ask you to reconsider this?  fallocate(2) is Linux-specific and other systems are likely to only implement the standardized posix_fallocate(2).  And while the posix_fallocate(2) implementation might be somewhat suboptimal on filesystems that don't implement fallocate(2), this should only affect the small number of users that use lld on non-standard filesystems.

When I said that we might consider implementing fallocate(2) on OpenBSD, I really meant to say that we will consider implementing posix_fallocate(2).


https://reviews.llvm.org/D39464





More information about the llvm-commits mailing list