logrotate(8) and copytruncate as default

Miloslav Trmač mitr at volny.cz
Thu Jun 27 19:51:04 UTC 2013

On Thu, Jun 27, 2013 at 6:57 PM, Miloslav Trmač <mitr at volny.cz> wrote:
> On Thu, Jun 27, 2013 at 6:49 PM, Jan Kaluza <jkaluza at redhat.com> wrote:
>> I have the same opinion for now, but I will at least try to evaluate
>> that locking idea. Maybe it can end up like more reliable
>> copytruncate directive.
> I've been looking at that option - AFAICS mandatory file locking, at
> least currently, doesn't work reliably with O_APPEND
> (rw_verify_area->locks_mandatory_area doesn't use the O_APPEND flag at
> all).
... which is irrelevant, as long as _some_ range is validated, the
write will block if the whole file is locked.  The necessary guarantee
is that O_APPEND is evaluated only after after the blocked writer is
unblocked, so that the log writer starts writing from the start of the
file again.  From my, generally ignorant, reading of the kernel
source, this is what actually happens (in generic_write_checks()), so
the mandatory locking should actually work.

More information about the devel mailing list