journald: process SIGBUS for the memory maps we set up

System Internals / systemd - Lennart Poettering [poettering.net] - 4 January 2015 18:40 UTC

Even though we use fallocate() it appears that file systems like btrfs will trigger SIGBUS on certain low-disk-space situation. We should handle that, hence catch the signal, add it to a list of invalidated pages, and replace the page with an empty memory area. After each write check if SIGBUS was triggered, and consider the write invalid if it was.

This should make journald a lot more robust with file systems where fallocate() is not reliable, for example all CoW file systems (btrfs...), where changing written data can fail with disk full errors.

https://bugzilla.redhat.com/show_bug.cgi?id=1045810

fa6ac76 journald: process SIGBUS for the memory maps we set up
.gitignore | 1 +
Makefile.am | 11 ++-
src/journal/journal-file.c | 67 +++++++++++++-----
src/journal/journal-file.h | 2 +-
src/journal/journald-server.c | 3 +
src/journal/journald.c | 4 ++
src/journal/mmap-cache.c | 126 +++++++++++++++++++++++++++++++---
src/journal/mmap-cache.h | 5 +-
src/shared/sigbus.c | 152 +++++++++++++++++++++++++++++++++++++++++
src/shared/sigbus.h | 25 +++++++
src/test/test-sigbus.c | 62 +++++++++++++++++
11 files changed, 430 insertions(+), 28 deletions(-)

Upstream: github.com


  • Share