summaryrefslogtreecommitdiff
path: root/src/libsystemd
Commit message (Collapse)AuthorAgeFilesLines
* sd-event: allocate event source objects with the actually needed sizeLennart Poettering2023-02-171-9/+33
| | | | | | | | | | Currently we allocate fixed-size memory for event sources: the largest any of the event source type needs. Discrepancy in the sizes needed for the various event sources is quite major however: it's 144 bytes on x86_64, i.e. more than two cache lines. hence, let's be a tiny bit more careful, and allocate exactly as much as we need, but not more.
* Merge pull request #26213 from poettering/journal-rework-seqnumLuca Boccassi2023-02-154-5/+62
|\ | | | | journal sequence number rework
| * journald: maintain entry seqnum counter in mmap()ed file in /run/Lennart Poettering2023-02-082-5/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's ensure that entry seqnums remain stable and monotonic across the entire runtime of the system, even if local storage is turned off. Let's do this by maintainer a counter file in /run/ which we mmap() and wherein we maintain the counter from early-boot on till late shutdown. This takes inspiration of the kernel-seqnum file we already maintain like that that tracks which kmsg messages we already processed. In fact, we reuse the same code for maintaining it. This should allow the behaviour entry seqnums to be more predictable, in particular when journal local storage is turned off. Previously, we'd maintain the seqnum simply by always bumping it to the maximum of the last written entry seqnum plus one, and the biggest seqnum so far written to the journal file on disk. If we'd never write a file on disk, or if no journal file was existing during the initrd→seqnum transition we'd completely lose the current seqnum position during daemon restarts (such as the one happening during the switch-root operation). This also will cause a journal file rotation whenever we try to write to a journal file with multiple sequence number IDs, so that we know that from early boot trhough the entire runtime we'll have stable sequence numbers that do not jump, and thus can be used to determine "lost" messages.
| * sd-journal: add high-level API for querying seqnum for journal entries, ↵Lennart Poettering2023-02-082-0/+32
| | | | | | | | along with seqnum id
* | journal: modernize sd_journal_get_realtime_usec() a bitLennart Poettering2023-02-081-4/+8
| | | | | | | | | | | | | | | | This does what 404803e6caad2de2d8e74caab0b79ec3f030f801 did for the monotonic timestamp getter, but for the realtime timestamp. It also also makes the return value optional, exactly as for the monotonic timestamp logic.
* | Merge pull request #26350 from keszybz/reload-messagesLuca Boccassi2023-02-081-4/+10
|\ \ | |/ |/| Improve messages emitted when Reload or Reexec is requested
| * sd-bus: adjust line breaksZbigniew Jędrzejewski-Szmek2023-02-081-4/+10
| |
* | Merge pull request #26328 from yuwata/udev-worker-set-process-nameZbigniew Jędrzejewski-Szmek2023-02-081-4/+1
|\ \ | | | | | | udev: set worker process name
| * | tree-wide: set FORK_RLIMIT_NOFILE_SAFE flagYu Watanabe2023-02-071-4/+1
| |/ | | | | | | No functional changes, just refactoring.
* | journal: minor modernizationsLennart Poettering2023-02-071-12/+7
| |
* | Merge pull request #26336 from poettering/journal-etoomanyrefsLuca Boccassi2023-02-072-2/+2
|\ \ | | | | | | journal: print nicer log message when limit of open journal files during display is hit
| * | journal: print a useful error message if we hit the journal file open limitLennart Poettering2023-02-072-2/+2
| |/ | | | | | | See: #20921
* | resolve: define normal macros for BUS_ERROR_DNS error codesZbigniew Jędrzejewski-Szmek2023-02-072-18/+37
|/ | | | | | This result is identical after cpp is done, so we don't save anything by not having the usual macros. And with the usual macros it's easier to grep and code-crossreferencing works better.
* sd-journal: avoid use of fake flex arraysZbigniew Jędrzejewski-Szmek2023-02-061-18/+24
| | | | | | I tried to use DECLARE_FLEX_ARRAY like the kernel does, but it does not work for anonymous structs (they cannot be declared inline), so an open-coded version is used.
* id128: introduce ERRNO_IS_MACHINE_ID_UNSET() helper macroLennart Poettering2023-02-012-5/+15
|
* journald: some minor modernizationsLennart Poettering2023-02-011-2/+2
|
* journal: generate a clean message when we try to write to a journal file ↵Lennart Poettering2023-02-011-1/+2
| | | | from a different host
* journal-file: refuse writing to journal files where the header size is ↵Lennart Poettering2023-02-011-0/+5
| | | | | | | | | | | | | | | different then expected We keep adding fields to the header, and it's fine reading files with different header sizes, as we check via the size if the fields we need are included. However, let's be stricter when writing journal files than when reading, and insist that the header structure in the file actually matches our expectations. Refuse otherwise, so that a new file is created after rotation that then matches our expectations. This makes sure that mismatch in header size is treated exactly as unknown "compatible" flags, which is our other mechanism to allow extending the journal file format in a non-breaking way.
* journal-file: be a tiny bit more careful with generating seqnumsLennart Poettering2023-01-261-14/+16
| | | | | Let's handle overflows in a vaguely reasonable way, i.e. avoid the special values 0 and UINT64_MAX
* Merge pull request #26198 from poettering/journal-strict-modeLennart Poettering2023-01-262-8/+44
|\ | | | | journal: enforce strict ordering only when writing journal files from journald, but not from journal-remote and similar
| * journal-file: make strict order optionalLennart Poettering2023-01-252-8/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow-up for 1d8d483f59ffa62974772fb58a8ef4abe88550ec and makes the strict ordering by realtime clock within each journal file optional, not mandatory. It then enables it for all journal files written by journald, but leaves it off on others (for example those written by journald-remote). This relaxes the logic behind writing journal files to the status quo ante for all cases where the journal files are not generated, but are merged/processed/propagated. Typically when processing journal records from many files ordering by realtime clock and monotonic clock are contradictory, and cannot be universally guaranteed as the records are interleaved. By enforcing strict rules we would thus end up generating myriads of separate journal files, each with just a few records in them. Hence, let's losen restrictions again, but continue to enforce them in journald, i.e. when we original create the journal files locally. Note that generally there's nothing really wring with having journal files with non-monotonically ordered entries by realtime clock. Looking for records will not be deterministic anymore, but that's inherent to a realtime clock that jumps up and down. So you won't get the "only" answer, but still *a* answer that is correct if you seek for a realtime clock. This also adds similar logic on the monotonic clock, which is also only enabled when generating journal files locally. This should be harder to trigger (as journald will generate the messages, and should run with a stable boot id and monotonic clock), but let's better be safe than sorry, and refuse on the lower layer what makes no sense, even if it's unlikely the higher layer will ever generate records that aren't ordered by their monotonic clock.
* | journal: automatically pick up boot ID in journal_file_append_entry()Lennart Poettering2023-01-261-0/+9
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's pick up the boot ID early if unspecified, in journal_file_append_entry(). This is symmetric to the fact that we already pick up the monotonic timestamp in journal_file_append_entry() if unspecified, and given that the monotonic clock is not too useful without its boot ID it makes a lot of sense to pick them up at the same time. There are two relevant callers of journal_file_append_entry() right now: journald (which leaves the boot ID unspecified) and journal-remote (there are also some tests, but those don't matter too much). The former calls it to store new entries in the journal file, the latter for converting/processing/merging existing ones (where it passes along the original boot ID). This new code hence only is relevant on the former, and using the boot ID of the current system is the right choice for live generated entries. Note that this effectively changes little, since the lower-level function journal_file_append_entry_internal() will copy boot ID stored in the file header into all records if unspecified, and typically that's the one of the local system. But strictly speaking this is not the right thing to do, since we actually might end up appending to journal files from previous boots. (The lower level function is indirectly used by various tests, where the copying-from-header logic kinda makes sense since they are detached from any live messages streaming in from the host after all).
* Merge pull request #26204 from poettering/journal-header-compoung-initLennart Poettering2023-01-252-13/+12
|\ | | | | journal: use compound initialization for journal file "Header" structure
| * journal: use compound initialization for journal file Header structureLennart Poettering2023-01-251-12/+11
| |
| * journal-def: fix type of signature to match the actual field in the Header ↵Lennart Poettering2023-01-251-1/+1
| | | | | | | | structure
* | journal-file: cast file size to to fixed size typeLennart Poettering2023-01-252-5/+5
| | | | | | | | | | (We generally avoid using off_t for file sizes/offsets, and instead use uint64_t to get the same behaviour everywhere. Do so here too.)
* | journal-file: fix type of array counterLennart Poettering2023-01-252-2/+3
|/
* meson: Do not include headers in source listsJan Janssen2023-01-241-52/+2
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* Merge pull request #25145 from yuwata/udevadm-triggerZbigniew Jędrzejewski-Szmek2023-01-232-0/+2
|\ | | | | udev: make 'udevadm trigger --settle' work even if device is renamed
| * sd-id128: introduce id128_hash_ops_freeYu Watanabe2023-01-192-0/+2
| |
* | sd-path: export env. generators pathsDavid Tardon2023-01-211-0/+20
| |
* | systemctl,test: -EBADF instead of -EBADFDYu Watanabe2023-01-211-1/+1
| | | | | | | | Follow-up for da20baaeccbcca78350bf64bdc069dec685c95bc.
* | sd-journal: validate monotonic timestamp before returning itLennart Poettering2023-01-211-3/+6
| |
* | journal: use compound initializors at one more placeLennart Poettering2023-01-201-6/+8
| |
* | journal: modernize match_make_string()Lennart Poettering2023-01-201-17/+8
| |
* | Merge pull request #26114 from bluca/sd_login_pidfdLennart Poettering2023-01-203-0/+241
|\ \ | | | | | | sd-login: add sd_pidfd_* APIs
| * | sd-login: add sd_pidfd_* APIsLuca Boccassi2023-01-203-0/+241
| |/ | | | | | | | | | | Same as the sd_pid_* counterparts, but take a pid file descriptor instead of a pid, so that the callers can be sure that the returned values are really about the process they asked for, and not about a recycled PID.
* | Merge pull request #23309 from DaanDeMeyer/log-contextLuca Boccassi2023-01-206-0/+111
|\ \ | |/ |/| basic: Add log context
| * device-monitor: Add extra fields to the log context before callbackDaan De Meyer2023-01-083-0/+82
| |
| * sd-bus: Log extra fields when processing bus messageDaan De Meyer2023-01-083-0/+29
| |
* | Merge pull request #26021 from fbuihuu/some-journald-improvementsLennart Poettering2023-01-184-0/+84
|\ \ | | | | | | Some journald improvements
| * | journald: introduce journal_file_parse_uid_from_filename() helperFranck Bui2023-01-164-0/+84
| | |
* | | udev: support '-=' operator for SYMLINKFranck Bui2023-01-172-0/+15
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some (corner) cases, it might be desirable to disable the generation of some persistent storage symlinks that 60-persistent-storage.rules creates. For example on big setups with a high number of partitions which uses the same label name, this can result in a noticeable slow-down in the (re)start of the udevd as there are many contenders for the symlink /dev/disk/by-partlabel. However it's currently pretty hard to overwrite just some specific part of the rule file. Indeed one need to copy and modify the whole rule file in /etc but will lost any upcoming updates/fixes that the distro might release in the future. With this simple patch, one can now disable the generation of the "by-partlabel" symlinks (for example) with the following single rule: $ cat /etc/udev/rules.d/99-no-by-partlabel.rules ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK-="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}" Closes #24607.
* | network: Show network and link file dropins in networkctl statusDaan De Meyer2023-01-121-0/+19
| | | | | | | | Fixes #24428
* | Merge pull request #25986 from yuwata/test-netlinkLuca Boccassi2023-01-101-246/+167
|\ \ | | | | | | test-netlink: cleanups
| * | test-netlink: use dummy interface to test assigning new interface nameYu Watanabe2023-01-101-4/+55
| | | | | | | | | | | | Fixes #25981.
| * | test: modernize test-netlink.cYu Watanabe2023-01-091-246/+116
| |/
* | Merge pull request #24939 from msizanoen1/journal-realtime-enforce-consistencyDaan De Meyer2023-01-101-0/+6
|\ \ | | | | | | journal: enforce strict consistency for realtime timestamps on write
| * | journal: enforce strict consistency for realtime timestamps on writemsizanoen12023-01-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure all realtime timestamps in a journal file are strictly ordered on write as a defense-in-depth measure. All known callers of journal_file_append_entry and journal_file_copy_entry, which call this function, should be able to handle the error by rotating the journal. This is especially helpful for systems with RTC local time enabled, where all log entries from initramfs might be recorded as several hours later than it actually is, which won't get caught by journald during log flushing. In those cases, the resulting inconsistency can cause libsystemd to loop infinitely through journal files as observed in `abrt-dump-journal-oops`.
* | | sd-device: introduce device_get_property_int()Yu Watanabe2023-01-102-0/+21
| | |