Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/platform_linux/laio.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,17 @@ laio_handle_create(io_config *cfg, platform_heap_id hid)
return NULL;
}

if (S_ISREG(statbuf.st_mode) && statbuf.st_size < 128 * 1024) {
r = fallocate(io->fd, 0, 0, 128 * 1024);
if (r == EOPNOTSUPP) {

// 32 4KB pages
#define EXTENT_SIZE (32 * 4 * 1024)

if (S_ISREG(statbuf.st_mode) && statbuf.st_size < EXTENT_SIZE) {
r = fallocate(io->fd, 0, 0, EXTENT_SIZE);
if (r && errno == EOPNOTSUPP) {
if (statbuf.st_size == 0) {
uint8_t zeroes[128 * 1024] = {0};
r = pwrite(io->fd, &zeroes, 128 * 1024, 0);
if (r) {
uint8_t zeroes[EXTENT_SIZE] = {0};
r = pwrite(io->fd, &zeroes, EXTENT_SIZE, 0);
if (r != EXTENT_SIZE) {
platform_error_log("fallocate not supported by filesystem and "
"fallback write failed: %s\n",
strerror(errno));
Expand All @@ -626,6 +630,8 @@ laio_handle_create(io_config *cfg, platform_heap_id hid)
}
}

#undef EXTENT_SIZE

io->pecnode.termination = laio_process_termination_callback;
io->pecnode.arg = io;
platform_linux_add_process_event_callback(&io->pecnode);
Expand Down
Loading