Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robj/fallocate blockdev fix #623

Merged
merged 9 commits into from
May 16, 2024
13 changes: 10 additions & 3 deletions src/platform_linux/laio.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,16 @@ io_handle_init(laio_handle *io, io_config *cfg, platform_heap_id hid)
return CONST_STATUS(errno);
}

if (is_create) {
int rc = fallocate(io->fd, 0, 0, 128 * 1024);
if (rc) {
struct stat statbuf;
int r = fstat(io->fd, &statbuf);
if (r) {
platform_error_log("fstat failed: %s\n", strerror(errno));
return STATUS_IO_ERROR;
}

if (S_ISREG(statbuf.st_mode) && statbuf.st_size < 128 * 1024) {
r = fallocate(io->fd, 0, 0, 128 * 1024);
if (r) {
platform_error_log("fallocate failed: %s\n", strerror(errno));
return STATUS_IO_ERROR;
}
Expand Down