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
17 changes: 11 additions & 6 deletions src/platform_linux/laio.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,16 @@ 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) {

#define SUPERBLOCK_SIZE 128 * 1024

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

#undef SUPERBLOCK_SIZE

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