diff options
author | Igor Zhbanov <i.zhbanov@omprussia.ru> | 2021-04-20 17:22:28 +0000 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-04-21 23:08:35 +0200 |
commit | 4c54768c9732532f4e56eab1be3e5474769e0d7a (patch) | |
tree | 923a47cd754d0409c5700a27ba5fb6b18f271912 /src/libsystemd | |
parent | 6f4a5f25fc0644158325bb5960f4d40a83ac3fc0 (diff) | |
download | systemd-4c54768c9732532f4e56eab1be3e5474769e0d7a.tar.gz |
journald: Retry if posix_fallocate returned -1 (EINTR)
On some conditions (particularly when mobile CPUs are going to sleep),
the posix_fallocate(), which is called when a new journal file is allocated,
can return -1 (EINTR). This is counted as a fatal error. So the journald
closes both old and journals, and simply throwing away further incoming
events, because of no log files open.
Introduce posix_fallocate_loop() that restarts the function in the case
of EINTR. Also let's make code base more uniform by returning negative
values on error.
Fix assert in test-sigbus.c that incorrectly counted positive values as
success. After changing the function return values, that will actually work.
Fixes: #19041
Signed-off-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-journal/journal-file.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index f8bb708e58..3cf26f8e44 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -707,9 +707,9 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) /* Note that the glibc fallocate() fallback is very inefficient, hence we try to minimize the allocation area as we can. */ - r = posix_fallocate(f->fd, old_size, new_size - old_size); - if (r != 0) - return -r; + r = posix_fallocate_loop(f->fd, old_size, new_size - old_size); + if (r < 0) + return r; f->header->arena_size = htole64(new_size - old_header_size); |