Skip to content

util/disk_cache: use fallocate() for index files on linux

Juston Li requested to merge justonli/mesa:disk-cache-fallocate into main

ftruncate() allocates disk space lazily. If the disk is full and it is unable to allocate disk space when accesed via mmap(), it will crash with a SIGBUS.

Switch to posix_fallocate(), which ensures disk space is allocated otherwise it fails if there isn't enough disk space. The disk cache won't be enabled in this case.

For normal cases, a small increase in disk usage as the 1.3MB index file will be fully allocated when initialized now.

fallback to ftruncate() if posix_fallocate() isn't found.

Edited by Juston Li

Merge request reports