1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00
Commit Graph

11522 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
cbd671772c journal: letting (interleaved) seqnums go
In the following scenario:
  server creates system.journal
  server creates user-1000.journal
both journals share the same seqnum_id.
Then
  server writes to user-1000.journal first,
  and server writes to system.journal a bit later,
and everything is fine.
The server then terminates (crash, reboot, rsyslog testing,
whatever), and user-1000.journal has entries which end with
a lower seqnum than system.journal. Now
  server is restarted
  server opens user-1000.journal and writes entries to it...
BAM! duplicate seqnums for the same seqnum_id.

Now, we usually don't see that happen, because system.journal
is closed last, and opened first. Since usually at least one
message is written during boot and lands in the system.journal,
the seqnum is initialized from it, and is set to a number higher
than than anything found in user journals. Nevertheless, if
system.journal is corrupted and is rotated, it can happen that
an entry is written to the user journal with a seqnum that is
a duplicate with an entry found in the corrupted system.journal~.
When browsing the journal, journalctl can fall into a loop
where it tries to follow the seqnums, and tries to go the
next location by seqnum, and is transported back in time to
to the older duplicate seqnum. There is not way to find
out the maximum seqnum used in a multiple files, without
actually looking at all of them. But we don't want to do
that because it would be slow, and actually it isn't really
possible, because a file might e.g. be temporarily unaccessible.

Fix the problem by using different seqnum series for user
journals. Using the same seqnum series for rotated journals
is still fine, because we know that nothing will write
to the rotated journal anymore.

Likely related:
https://bugs.freedesktop.org/show_bug.cgi?id=64566
https://bugs.freedesktop.org/show_bug.cgi?id=59856
https://bugs.freedesktop.org/show_bug.cgi?id=64296
https://bugs.archlinux.org/task/35581
https://bugzilla.novell.com/show_bug.cgi?id=817778

Possibly related:
https://bugs.freedesktop.org/show_bug.cgi?id=64293
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
5cb24cd32b tests: add testcase for duplicate seqnums 2013-06-10 10:10:07 -04:00
Marius Vollmer
7a050b54b7 tests: add testcase for skipping-entries-on-direction-change-bug
This test case failed until a3e6f050de.

Taken from https://bugs.freedesktop.org/show_bug.cgi?id=65255.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
bc3029268c journal: change direction tests to use the same convention (cp </> np)
The order was different in various places, which makes it harder to
read to code. Also consistently use ternany for all direction checks.

Remove one free(NULL).
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
87011c25d9 journal: remember last direction of search and keep offset cache
The fields in JournalFile are moved around to avoid wasting
7 bytes because of alignment.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
8d98da3f11 journalctl: allow the user to specify the file(s) to use
This is useful for debugging and feels pretty natural. For example
answering the question "is this big .journal file worth keeping?"
is made easier.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
5302ebe15f journal: add sd_journal_open_files
This allows the caller to explicitly specify which journal files
should be opened. The same functionality could be achieved before
by creating a directory and playing around with symlinks. It
is useful to debug stuff and explore the journal, and has been
requested before.

Waiting is supported, the journal will notice modifications on
the files supplied when opening the journal, but will not add
any new files.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
6eb7a9a001 tests: add test for empty journal files
The headers are currently not printed properly: some "(null)"s appear.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
ed375bebf4 journalctl: print monotonic timestamp in --header 2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
2765b7bb69 journalctl: print proper IDs with --header
The same buffer was used for two different IDs, messing up
the output.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
507f22bd01 Use stdint.h macros instead of casts to print uint64_t values
Casts are visually heavy, and can obscure unwanted truncations.
2013-06-10 10:10:07 -04:00
Zbigniew Jędrzejewski-Szmek
b32ff51219 Properly check for overflow in offsets 2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek
3001c74580 journalctl: no color for --reboot-- when not on tty 2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek
2bc8ca0ca2 journal: loop less in MATCH_AND_TERM conditionals
AND term usually don't have many subterms (4 seems to be the maximum
sensible number, e.g. _BOOT_ID && _SYSTEMD_UNIT && _PID && MESSAGE_ID).
Nevertheless, the cost of checking each subterm can be relatively
high, especially when the nested terms are compound, and it
makes sense to minimize the number of checks.

Instead of looping to the end and then again over the whole list once
again after at least one term changed the offset, start the loop at
the term which caused the change. This way ½ terms in the AND match
are not checked unnecessarily again.
2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek
3f3a438f58 journalctl: add --system/--user flags
--user basically gives messages from your own systemd --user services.
--system basically gives messages from PID 1, kernel, and --system
services. Those two options are not exahustive, because a priviledged
user might be able to see messages from other users, and they will not
be shown with either or both of those flags.
2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek
a688baa8b7 journal: add ability to filter by current user
This is the just the library part.

SD_JOURNAL_CURRENT_USER flags is added to sd_j_open(), to open
files from current user.

SD_JOURNAL_SYSTEM_ONLY is renamed to SD_JOURNAL_SYSTEM,
and changed to mean to (also) open system files. This way various
flags can be combined, which gives them nicer semantics, especially
if other ones are added later.

Backwards compatibility is kept, because SD_JOURNAL_SYSTEM_ONLY
is equivalent to SD_JOURNAL_SYSTEM if used alone, and before there
we no other flags.
2013-06-10 10:10:06 -04:00
Zbigniew Jędrzejewski-Szmek
c5a10d9ca0 journal: simplify match_free_if_empty 2013-06-10 09:26:42 -04:00
Zbigniew Jędrzejewski-Szmek
696fee7d95 dev-setup: do not create a dangling /proc/kcore symlink
https://bugs.freedesktop.org/show_bug.cgi?id=65382
https://bugs.gentoo.org/472060?id=472060
2013-06-10 08:50:59 -04:00
Zbigniew Jędrzejewski-Szmek
a72b63536f journalctl: fix verbose output when no logs are found
$ journalctl -o verbose _EXE=/quiet/binary -f
-- Logs begin at Sun 2013-03-17 17:28:22 EDT. --
Failed to get realtime timestamp: Cannot assign requested address

JOURNAL_FOREACH_DATA_RETVAL is added, which allows the caller
to get the return value from sd_journal_enumerate_data. I think
we might want to expose this macro like SD_JOURNAL_FOREACH_DATA,
but for now it is in journal-internal.h.

There's a change in behaviour for output_*, not only in
output_verbose, that errors in sd_j_enumerate_data are not silently
ignored anymore.

https://bugs.freedesktop.org/show_bug.cgi?id=56459
2013-06-09 22:38:29 -04:00
Ross Lagerwall
62220cf70e service: don't report alien child as alive when it's not
When a sigchld is received from an alien child, main_pid is set to
0 then service_enter_running calls main_pid_good to check if the
child is running.  This incorrectly returned true because
kill(main_pid, 0) would return >= 0.

This fixes an error where a service would die and the cgroup would
become empty but the service would still report as active (running).
2013-06-09 18:26:41 -04:00
Daniel Wallace
7085053a43 Allow for the use of @ in remote host calls
Without this you have to use %40 with the -H flag because dbus doesn't
like the @ sign being unescaped.
2013-06-09 18:26:41 -04:00
Zbigniew Jędrzejewski-Szmek
856323c9cb systemctl: remove extra padding from status output
In 131601349 'systemctl: align all status fields to common column',
padding was calculated for 'ListenStream: ...', etc. Later on in
45a4f7233 'systemctl: tweak output of Listen: fields a bit' output
was changed to 'Listen: ... (stream)', but calculation didn't change.

Just remove the calculation, since now the result will be always 8,
and it it more important to have everything aligned to the widest
field ("Main-PID"), than to save a few columns, usually at most two
(e.g. "Listen").

Note: strlen is more natural, and is optimized to sizeof even
with -O0.
2013-06-09 14:31:17 -04:00
Zbigniew Jędrzejewski-Szmek
31f7bf1994 logs-show: print multiline messages
[    0.019862] fedora kernel: CPU0: Thermal monitoring enabled (TM1)
[    0.019900] fedora kernel: Last level iTLB entries: 4KB 512, 2MB 0, 4MB 0
                              Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32
                              tlb_flushall_shift: 5
[    0.020118] fedora kernel: Freeing SMP alternatives: 24k freed
2013-06-09 13:49:38 -04:00
Lennart Poettering
4e09014daf update TODO 2013-06-06 16:25:58 +02:00
Lennart Poettering
b043cd0b7e cgroup: the "tasks" attribute is obsolete, cgroup.procs is the new replacement 2013-06-06 15:49:01 +02:00
Lennart Poettering
3d585edbb1 build-sys: we do not support --disable-largefile builds 2013-06-06 10:38:31 +02:00
Cristian Rodríguez
5e63ce78b5 build-sys: do not allow --enable static 2013-06-06 10:10:54 +02:00
Lennart Poettering
af4713396c service: execute ExecStopPost= commands when the watchdog timeout hits
We can assume that a service for which a watchdog timeout was triggered
is unresponsive to a clean shutdown. However, it still makes sense to
execute the post-stop cleanup commands that can be configured with
ExecStopPost=. Hence, when the timeout is hit enter STOP_SIGKILL rather
than FINAL_SIGKILL.
2013-06-06 09:10:12 +02:00
Chengwei Yang
1cce5d639c manager: Do not handle SIGKILL since we can not
This is a minor fix because it's not a major issue, this fix just avoid
to get EINVAL error from sigaction(2).

There are two signals can not handled at user space, SIGKILL and
SIGSTOP even we're PID 1, trying to handle these two signals will get
EINVAL error.

There are two kinds of systemd instance, running as system manager or
user session manager, apparently, the latter is a general user space
process which can not handle SIGKILL. The special pid 1 also can not
do that refer to kernel/signal.c:do_sigaction().

However, pid 1 is unkillable because the kernel did attach
SIGNAL_UNKILLABLE to it at system boot up, refer to
init/main.c:start_kernel()
    --> rest_init()
        --> kernel_thread()
            --> kernel_init()
                --> init_post()
                    current->signal->flags |= SIGNAL_UNKILLABLE
2013-06-06 08:58:58 +02:00
Harald Hoyer
4a4c0be0ab libsystemd-bus/bus-kernel.h: set MEMFD_MIN_SIZE to 128k 2013-06-05 12:25:02 +02:00
Harald Hoyer
6cbf6931d2 test-bus-kernel-benchmark: corrected output for memfd bisect 2013-06-05 12:24:17 +02:00
Kay Sievers
83d97ce664 bus: benchmark - adjust printf and MAX_SIZE 2013-06-05 10:26:00 +02:00
Pierre Neidhardt
f3dbb13c85 keymap: add some more Asus laptop keys
With Linux 3.9 (commit a935eaecef2b209ad661dadabb4e32b7c9a9b924), the
Asus keyboard driver has changed to be more compliant to the symbol
signification. This has led to some issues with udev. In particular,
the XF86TouchpadToggle (a Fn key) does not work anymore on Asus X52J.

I found another similar patch which does not seem to have been ever
submitted/merged:

  https://launchpadlibrarian.net/73337842/95-keymap.rules.patch

Find enclosed the patch containing both the launchpad patch and mine
into one file.

https://bugs.freedesktop.org/show_bug.cgi?id=65375
2013-06-04 17:45:41 -04:00
Zbigniew Jędrzejewski-Szmek
bdf874d4bf man: mention that units are 1024-based 2013-06-04 17:45:40 -04:00
Kay Sievers
bf30e48fe5 bus: unmap memfd retrieved from the memfd cache 2013-06-04 23:37:57 +02:00
Kay Sievers
311754514c bus-benchmark: add performance data output mode
- for now, comment out munmap() check to enable memfd passing
  - print tab-separated values and header
  - add memcpy() to fill the memfd, to produce real-world results

$ ./test-bus-kernel-benchmark
SIZE    COPY    MEMFD
4194304 370     370
2097152 810     810
1048576 2130    2130
524288  4090    4090
262144  7080    7080
131072  11380   11380
65536   17140   17140
98304   13930   13930
114688  12890   12890
122880  12350   12350
126976  12150   12150
129024  12170   12170
130048  12040   12040
130560  12080   12080
130816  12010   12010
130944  12020   12020
131008  12040   12040
131040  12050   12050
131056  12010   12010
131064  12060   12060
131068  12040   12040
131070  11310   11310
131069  11420   11420
Copying/memfd are equally fast at 131068 bytes

$ ./test-bus-kernel-benchmark chart
SIZE    COPY    MEMFD
1       35570   23690
2       36470   23680
4       36160   23520
8       36600   22220
16      33900   20830
32      33990   21360
64      33480   21280
128     34050   20910
256     32950   21750
512     34730   21900
1024    33810   22890
2048    36280   23110
4096    30790   21610
8192    29380   21100
16384   26880   19820
32768   22510   17980
65536   17270   15180
131072  11400   11420
262144  7140    8270
524288  4090    5050
1048576 2110    2780
2097152 800     1140
4194304 350     580
2013-06-04 21:00:30 +02:00
Zbigniew Jędrzejewski-Szmek
3a256a12ad systemctl: add missing verbs to help 2013-06-04 10:58:00 -04:00
Zbigniew Jędrzejewski-Szmek
5ec7641776 systemctl: limit logs in status to current boot
Also reworded a few debug messages for brevity, and added a log
statement which prints out the filter at debug level:

Journal filter: (((UNIT=sys-module-configfs.device AND _PID=1) OR (COREDUMP_UNIT=sys-module-configfs.device AND MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1) OR _SYSTEMD_UNIT=sys-module-configfs.device) AND _BOOT_ID=4e3c518ab0474c12ac8de7896fe6b154)
2013-06-04 09:59:06 -04:00
Karel Zak
7c1b8f043e units: cleanup agetty command line
* baud rate is optional and unnecessary for virtual terminals
 * term type is optional (default is 'linux' for virtual terminals
   and 'vt102' for serial lines)
 * long options are more user-friendly

... all this is supported since util-linux v2.20 (Aug 2011).
2013-06-04 15:34:44 +02:00
Lennart Poettering
59967d30e5 bus-benchmark: lower loop time to 100ms by default, to ensure "make check" finishes more quickly
To get useful results you should however specify a much longer time on
the command line.
2013-06-04 12:00:50 +02:00
Lennart Poettering
061b2c4365 test: determine number of transactions per second rather than time per transaction
This way the measurements are not skewed by twoo short total measurement
times, and results become stabler.
2013-06-04 11:53:11 +02:00
Zbigniew Jędrzejewski-Szmek
02b9e969a6 systemctl,core: allow nuking of symlinks to removed units
Before, one the unit file was deleted, install_context_for_removal()
would refuse to look for symlinks. But we can remove dangling symlinks
anyway.

In principle, package installation/deinstallation scripts should do
that before the unit is uninstalled, but they don't always do. Also,
a user might have added additional symlinks manually.

https://bugs.freedesktop.org/show_bug.cgi?id=62395
2013-06-03 13:55:17 -04:00
Tom Gundersen
5b46fc6c60 Makefile.am: merge conditionals
Merge all ENABLE_TMPFILES conditionals into one, and merge two ENABLE_EFI
conditionals. Also make sure the .in files are always distributed.
2013-06-03 16:00:51 +02:00
Thomas Hindoe Paaboel Andersen
2b7d6965be analyze: fix font size on plot
The font-size was missing a unit so they were ignored. This patch sets
the unit to 'px' and adjusts the sizes a bit as the text got very small.
2013-06-02 22:29:31 +02:00
Thomas Hindoe Paaboel Andersen
d9acfb71db analyze: show unit file loading on plot
This will add another color to the legend called "Loading unit files"
Like the generators it will mark a part of the systemd bar indicating
the time spent while loading unit files.
2013-06-02 22:26:13 +02:00
Umut Tezduyar
518d10e985 analyze: show generators on plot 2013-06-02 22:26:05 +02:00
Umut Tezduyar
6351163bf3 build-sys: option to disable tmpfiles 2013-06-02 11:12:14 +02:00
Daniel Albers
fe1abefcd3 journal: take KeepFree into account when reporting maximum size
When reporting the maximum journal size add a hint if it's limited
by KeepFree.
2013-06-01 09:15:11 -04:00
Kay Sievers
1a2a4cf250 bus: update for kdbus changes 2013-05-31 04:56:10 +02:00
Zbigniew Jędrzejewski-Szmek
1058cbf2ad systemctl: suggest 'systemctl daemon-reload' without --system
--system is default anyway, and some poor user might type 9
characters without needing to.
2013-05-30 20:44:41 -04:00