Skip to content

Commit

Permalink
don't fallocate on block devices
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjohnso committed May 15, 2024
1 parent d5ae0ec commit a1873ab
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit a1873ab

Please sign in to comment.