Re: [PATCH] syslog: fill buffer with more than a single message for SYSLOG_ACTION_READ

Kay Sievers
2012-06-23T18:04:17Z

On Fri, Jun 22, 2012 at 5:36 PM, Jan Beulich <JBeulich@suse.com> wrote:
> The recent changes to the printk buffer management resulted in
> SYSLOG_ACTION_READ to only return a single message, whereas previously
> the buffer would get filled as much as possible. As, when too small to
> fit everything, filling it to the last byte would be pretty ugly with
> the new code, the patch arranges for as many messages as possible to
> get returned in a single invocation. User space tools in at least all
> SLES versions depend on the old behavior.

What a weird assumption for using that interface. It does a simple
one-time read and assumes it will never block in that? If something
would clear the log, or it would not contain a message, that read will
block and the tool would just hang? :)

But sure, sounds needed to restore the old behaviour if such weird
users exist, and the patch looks fine from looking over it.

> This at once addresses the issue attempted to get fixed with commit
> b56a39ac263e5b8cafedd551a49c2105e68b98c2 ("printk: return -EINVAL if
> the message len is bigger than the buf size"), and since that commit
> widened the possibility for losing a message altogether, the patch
> here assumes that this other commit would get reverted first
> (otherwise the patch here won't apply).
>
> Furthermore, this patch also addresses the problem dealt with in
> commit 4a77a5a06ec66ed05199b301e7c25f42f979afdc ("printk: use mutex
> lock to stop syslog_seq from going wild"), so I'd recommend reverting
> that one too (albeit there's no direct collision between the two).

Are you sure that is covered? Doesn't the other thread would just
return 0 to the caller then, instead of continuing to stay in the
syscall when the first thread got the message?

Kay