[PATCH] Use posix_fallocate instead of ftruncate.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 12:45:40 PDT 2016


On Tue, Jul 19, 2016 at 2:29 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> On 19 July 2016 at 15:11, Rui Ueyama <ruiu at google.com> wrote:
> > I'd use fallocate(2) instead of posix_fallocate. fallocate does,
> contrary to
> > posix's one, return an error if an underlying filesystem doesn't support
> the
> > feature. You can just ignore the error.
>
> But why is that an advantage? It the underlying FS don't support
> ftruncate we would have to implement an emulation similar to what
> posix_fallocate does or risk a sigbus. We would also need more ifdefs
> for freebsd for example.


Well, is detecting a disk full event so important to risk that it could
slow down the linker on NFS or such? It'd depend how often you hit it, but
to me it doesn't feel like a good trade-off.

> Since fallocate is Linux-specific, you would have to add HAS_FALLOCATE.
>
> Well, since it is linux only we could use "#if defined(__linux__)"
> which is already used in Path.inc.
>
> In any case, a patch that also works on OS X is attached.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160719/9823735c/attachment.html>


More information about the llvm-commits mailing list