On Fri, 28.06.13 13:23, P J P (pj.pandit(a)yahoo.co.in) wrote:
> The systemd-journald takes care of all of: receiving messages,
writing
> them to storage, and rotating the storage.
>
> We do synchronous rotation before each write. i.e. the moment we append
> to a file we check if the write would cause the disk usage to be out of
> limits, and then do the rotation right away.
I see. While doing this rotation, I guess systemd uses flock(2) or similar
mechanism to pause writing to a log file, move/rename or copy-truncate that
file and continue writes again?
journald is the only writer, it doesn't need locking. The changes it
does are done in a way so that concurrent readers will either see the
changes or not, but never half-written changes.
Also note that locking on Linux is seriously broken. You can get a lock
on any file you can read, thus you can freeze everybody else who might
want a lock. Or in other words: if a logging daemon takes a lock on its
lock files, then you can use this to make that service freeze forever.
File system locking on Unix cannot really work.
Lennart
--
Lennart Poettering - Red Hat, Inc.