Why print_log() is doing the memlock check?
Hello,
I am testing a writing error message to the /var/log/messages. However, a part of the error message wasn't written.
It's blocked by memlock() function in print_log() function in lib/log.c.
lib/log.c:364
if (_syslog && (_log_while_suspended || !memlock())) {
~~~~~~~~~~
va_start(ap, format);
vsyslog(level, trformat, ap);
va_end(ap);
}I think that "memlock()" check is unnecessary. Please teach me a reason why it is doing the memlock check.
Regards,
/* -------------------------------------------------------------
Shinn'ya Hoshino mailto:hoshino-s at ma.dnes.nec.co.jp
------------------------------------------------------------- */
Quoted 3 lines · Shinn'ya Hoshino
I am testing a writing error message to the
/var/log/messages. However, a part of the error message wasn't written.
It's blocked bymemlock()function inprint_log()function inlib/log.c.
LVM2 metadata changes go:
suspend i/o to device
flip to new metadata
resume i/o
While i/o is suspended you could have a situation where most of the rest of the system blocks up until i/o is resumed, so it is vital that the process that is going to perform the resume does not itself also block up. Writing a log message can lead to that, so logging is disabled in such critical sections.
Override for testing with log/activation set to 1 in the config.
Alasdair
Signature · 1 line
agk at redhat.com
Thanks for reply.
Quoted 3 lines · Alasdair G Kergon
While i/o is suspended you could have a situation where most of the rest of the system blocks up until i/o is resumed,
However, when a trouble occurs in the server currently used for business, it needs to avoid that it becomes impossible to investigate in order that there may be no log.
If logging is suspended until unlocked, does it solve?
When it is true, I shall want to consider the addition which suspends logging.
/* -------------------------------------------------------------
Shinn'ya Hoshino mailto:hoshino-s at ma.dnes.nec.co.jp
------------------------------------------------------------- */
Quoted 3 lines · Shinn'ya Hoshino
However, when a trouble occurs in the server currently used for business, it needs to avoid that it becomes impossible to investigate in order that there may be no log.
We don't have a safe way of logging yet.
What happens, is people temporarily turn on logging during activation in the config file while debugging, and put things back again afterwards.
A long time ago I started attempting to write some such code but never finished it. Look for init_log_direct().
Another approach might be to cache the log messages in memory then write them out when exiting the critical section.
Alasdair
Signature · 1 line
agk at redhat.com
Quoted 4 lines · Alasdair G Kergon
Date: Tue, 9 Jan 2007 20:48:24 +0000
Another approach might be to cache the log messages in memory then write them out when exiting the critical section.
I am going to try it with static buffer.
Thanks, regards.
/* -------------------------------------------------------------
Shinn'ya Hoshino mailto:hoshino-s at ma.dnes.nec.co.jp
------------------------------------------------------------- */