[PATCH] D39464: Define fs::allocate_file which preallocates disk blocks.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 15:13:19 PST 2017
Mark Kettenis <mark.kettenis at xs4all.nl> writes:
>> > ftruncate(2)/NetBSD as an extension extends area and makes it
>> > zero-filled. It's equivalent to lseek(2) + write(2).
>>
>> Cool, so an mmap of the file after a ftruncate will never crash because
>> of disk full, correct?
>
> I seriously doubt ftruncate(2) behaves differently on NetBSD. There
> is nothing in the man page that suggests this, and users would
> probably scream if creating sparse files was broken.
Surry, but sparse file is the problem in here. If ftruncate creates a
sparse file we cannot use it. What we need is the guarantee that a
write or page fault on that range will not fail because the disk is full.
>> If so we could use use ftruncate on netbsd as a special case, similar to
>> the special case we have for OS X.
>
> I still think OS-specific code should be avoided when a reasonable
> portable alternative exists. Maybe OS X is important enough that a
> performance regressions in unacceptable. But the Linux-specific code
> provides no benefit over the posix_fallocate(2) code for the vast
> majority of use cases where output files will be created on
> filesystems that support fallocate(2).
I would personally be OK with dropping the linux special case as it is
just slow on some less common file systems.
Cheers,
Rafael
More information about the llvm-commits
mailing list