Commit Graph

37 Commits

Author SHA1 Message Date
Sage Weil
631469c40b Revert "Speed optimizations. Merged 3 writes into 1."
This reverts commit 91497e4633.

Oops, this is injecting \0 in the log output.

Signed-off-by: Sage Weil <sage@redhat.com>
2015-10-25 11:50:20 -04:00
Adam Kupczyk
91497e4633 Speed optimizations. Merged 3 writes into 1.
Got rid of std::string construction.
More unification on syslog,stderr,fd.

Signed-off-by: Adam Kupczyk <akupczyk@mirantis.com>
2015-10-19 14:05:20 +02:00
Samuel Just
8778ab3a1c Log::reopen_log_file: take m_flush_mutex
Otherwise, _flush() might continue to write to m_fd after it's closed.
This might cause log data to go to a data object if the filestore then
reuses the fd during that time.

Fixes: #12465
Backport: firefly, hammer
Signed-off-by: Samuel Just <sjust@redhat.com>
2015-07-24 15:38:20 -07:00
Jason Dillaman
c1e1445177 log: fix helgrind warnings regarding possible data race
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
2015-06-04 16:49:51 -04:00
Sage Weil
a8c943a0e4 log: add simple test to verify an internal SEGV doesn't hang
Test that the segv injection works.

Test that a segv while logging something doesn't hang when the signal
handlers are installed.  Note that this fails/hangs without the previous
fix.

Signed-off-by: Sage Weil <sage@redhat.com>
2014-09-12 17:18:01 -07:00
Sage Weil
558463e815 log: add Log::is_inside_log_lock()
Signed-off-by: Sage Weil <sage@redhat.com>
2014-09-12 15:24:50 -07:00
Andrey Kuznetsov
59d18ac22d [RGW, memory leak] Memory leak in RGW has been fixed: deletion of allocated pointer to pointer to Log object has been added to "on_exit" handler.
Memory leaks detector report:

$ valgrind  --leak-check=full /usr/bin/radosgw -c /etc/ceph/ceph.conf -n
client.radosgw.gateway -
...
==16986== 8 bytes in 1 blocks are definitely lost in loss record 14 of 83
==16986==    at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298)
==16986==    by 0x58980B8: ceph::log::Log::set_flush_on_exit() (in /usr/lib64/librados.so.2.0.0)
==16986==    by 0x6BE3CA: global_init(std::vector<char const*, std::allocator<char const*> >*, st
==16986==    by 0x5B6B0A: main (in /usr/bin/radosgw)
...

Signed-off-by: Andrey Kuznetsov <Andrey_Kuznetsov@epam.com>
2014-06-29 22:26:25 +04:00
Noah Watkins
0e376ee742 compat: avoid unused warn with TEMP_FAILURE_RETRY
The version of TEMP_FAILURE_RETRY found on Linux has a GNU extension
that squashes the unused return value warning where applicable. This
adds a VOID_TEMP_FAILURE_RETRY to make the case explicit, casting the
expression value to void to avoid the warning.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2014-02-23 11:17:42 -08:00
Noah Watkins
7aa980528c log: use on exit manager to flush logs on exit
on_exit is not portable, and atexit doesn't allow parameters to be
passed to callbacks.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2014-01-04 12:54:03 -08:00
Noah Watkins
e2be099118 compat: define replacement TEMP_FAILURE_RETRY
Not all platforms have it.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2013-12-07 10:18:51 -08:00
Roald J. van Loon
6949d221ad automake cleanup: implementing non-recursive make
- Enabling subdir objects
- Created a Makefile-env.am with basic automake init
- Created .am files per subdir, included from src/Makefile.am

Signed-off-by: Roald J. van Loon <roaldvanloon@gmail.com>
2013-09-08 00:11:09 +02:00
Noah Watkins
88f4a962e1 log: remove unused lock
m_lock is initialized and destroyed, but never used.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2013-07-22 19:54:37 -07:00
Danny Al-Gaaf
aad71dfd6b src/log/Entry.h: pass function parameter by reference
Fix "(performance) Function parameter 's' should be passed by reference."
from cppchecker.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-02-11 11:38:02 +01:00
Sage Weil
43cba617aa log: fix locking typo/stupid for dump_recent()
We weren't locking m_flush_mutex properly, which in turn was leading to
racing threads calling dump_recent() and garbling the crash dump output.

Backport: bobtail, argonaut
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-01-02 17:01:32 -08:00
Sage Weil
813787af3d log: broadcast cond signals
We were using a single cond, and only signalling one waiter.  That means
that if the flusher and several logging threads are waiting, and we hit
a limit, we the logger could signal another logger instead of the flusher,
and we could deadlock.

Similarly, if the flusher empties the queue, it might signal only a single
logger, and that logger could re-signal the flusher, and the other logger
could wait forever.

Intead, break the single cond into two: one for loggers, and one for the
flusher.  Always signal the (one) flusher, and always broadcast to all
loggers.

Backport: bobtail, argonaut
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2012-12-28 15:08:29 -08:00
Sage Weil
50914e7a42 log: fix flush/signal race
We need to signal the cond in the same interval where we hold the lock
*and* modify the queue.  Otherwise, we can have a race like:

 queue has 1 item, max is 1.
 A: enter submit_entry, signal cond, wait on condition
 B: enter submit_entry, signal cond, wait on condition
 C: flush wakes up, flushes 1 previous item
 A: retakes lock, enqueues something, exits
 B: retakes lock, condition fails, waits
  -> C is never woken up as there are 2 items waiting

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2012-12-20 13:48:06 -08:00
Sage Weil
ae1c38f195 LogEntry: fix uninit in ctor
At (2): Non-static class member "m_thread" is not initialized in this constructor nor in any functions that it calls.
At (4): Non-static class member "m_prio" is not initialized in this constructor nor in any functions that it calls.
At (6): Non-static class member "m_subsys" is not initialized in this constructor nor in any functions that it calls.
CID 717229: Uninitialized scalar field (UNINIT_CTOR)
At (8): Non-static class member "m_static_buf" is not initialized in this constructor nor in any functions that it calls.

Signed-off-by: Sage Weil <sage@inktank.com>
2012-09-28 13:18:05 -07:00
Sage Weil
46c08d6c28 log: protect m_stop with lock
CID 716965: Data race condition (MISSING_LOCK)
At (2): Accessing "this->m_stop" ("_ZN4ceph3log3LogE.m_stop") requires the "_ZN4ceph3log3LogE.m_queue_mutex" lock.

This isn't strictly needed since we assume only one thread will call this
method and start a thead, but it makes coverity happy.

Signed-off-by: Sage Weil <sage@inktank.com>
2012-08-31 13:11:35 -07:00
Sage Weil
36d0a3555f log: simplify log logic a bit
Whether an entry is eligible to log/dump is independent of the channel it
is sent to.  Some channels impose additional restrictions.

Signed-off-by: Sage Weil <sage@inktank.com>
2012-07-17 08:36:54 -07:00
Sage Weil
f9c1a6fb0a Merge branch 'next' 2012-07-16 16:13:55 -07:00
Sage Weil
52f96b9fd1 log: apply log_level to stderr/syslog logic
In non-crash situations, we want to make sure the message is both below the
syslog/stderr threshold and also below the normal log threshold.  Otherwise
we get anything we gather on those channels, even when the log level is
low.

Signed-off-by: Sage Weil <sage@inktank.com>
2012-07-16 16:02:14 -07:00
Sage Weil
de524abdb1 log: dump logging levels in crash dump
So you know what you are/are not seeing.

Signed-off-by: Sage Weil <sage@inktank.com>
2012-07-16 15:53:59 -07:00
Sage Weil
64f745008b log: fix event gather condition
We should gather an event if it is below the log or gather threshold.

Previously we were only gathering if we were going to print it, which makes
the dump no more useful than what was already logged.

Signed-off-by: Sage Weil <sage@inktank.com>
2012-07-16 15:36:44 -07:00
Sage Weil
a24145fcbf log: add missing .cc file
Signed-off-by: Sage Weil <sage@newdream.net>
2012-05-30 15:35:30 -07:00
Sage Weil
52187c3eac log: uninline SubsystemMap mutators
This lets you do something like

 p g_ceph_context->_conf->subsys.set_log_level(ceph_subsys_mon, 20)

from gdb.

Signed-off-by: Sage Weil <sage@newdream.net>
2012-05-30 15:15:50 -07:00
Sage Weil
c4c59a094d log: do not set on_exit() callback for libraries
Set this up in either global_init() or common_init_finish(), both opportune
times that occur after config parsing has happened and the user has the
option to modify this behavior.  The exception would be libraries like
librados, which can't use rados_conf_* to enable this.  Arguably flush
functionality should be exposed through the librados API directly, instead
of futzing with on_exit().

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
2012-04-28 16:27:22 -07:00
Sage Weil
4e2e87941b config: allow {get,set}_val on subsystem debug levels
This mimics the allows you to get and set subsystem debug levels via the
normal config access methods.  Among other things, this allows librados
users to set debug levels.

Fixes: #2350
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
2012-04-26 21:52:23 -07:00
Sage Weil
f7699cc993 log: prefix dump with line numbers
This makes it easier to interpret the dump, and makes it obvious what is
dump (and potentially a dup of something that was already logged) and what
is not.

Signed-off-by: Sage Weil <sage@newdream.net>
2012-04-20 16:36:54 -07:00
Sage Weil
37cdbcd4b4 log: fix up unittest
Fewer entries; compile.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
2012-03-28 06:32:12 -07:00
Sage Weil
ce61a83f3b log: throttle message submission, trim recent
Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 11:20:53 -07:00
Sage Weil
339956df31 log: don't spam -1 to syslog; add err_to_syslog for consistency
This matches the stderr settings.

Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 11:05:25 -07:00
Sage Weil
17a95c223e log: use PrebufferedStreambuf
It's faster than ostringstream!

Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 10:44:52 -07:00
Sage Weil
3a87e452e1 log/EntryQueue: no implicit trim
dequeue() things explicitly if you want to remove them.

Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 10:42:55 -07:00
Sage Weil
362ca19bc8 log: move create_entry() into Log interface
This will let us be smarter than putting it on the heap.

Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 10:41:15 -07:00
Sage Weil
23f0af3c06 test log performance with PreallocatedStreambuf
- faster than ostringstream in optimistic case
- same as ostreamstream + std::string assignment in worst case (use
  overflow string)

Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 10:41:15 -07:00
Sage Weil
c7242bfe5e log: flush on_exit
Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 10:41:14 -07:00
Sage Weil
f41887e38d log: new logging infrastructure
- explicitly defined subsystems, and ceph_subsys_FOO enums to go with them
- modular log system with Entry object
- separate gather level and log level
- drop lots of DoutStreambuf hackery

Signed-off-by: Sage Weil <sage@newdream.net>
2012-03-27 10:41:12 -07:00