summaryrefslogtreecommitdiffstats
path: root/src/core/swap.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core/service: preserve RuntimeDirectory= even if oneshot service exitsMike Yuan2024-12-021-1/+1
| | | | | | | | | Follow-up for c26948c6dae1d2ca13499b36f193b13a0760834c We only want to get rid of cred mount here, and RuntimeDirectory= is documented to be retained for SERVICE_EXITED state. Fixes #35427
* core: make mount(8) and swapon(8) inherit SMACK label from systemdŁukasz Stelmach2024-10-301-0/+3
| | | | | | | | | By default mount(8), umount(8), swapon(8) and swapoff(8) should run with with the SMACK label inherited from systemd rather than the default one meant for services. Fixes: aa5ae9711ef3cd0c69b7fcfbd65bca05fb704a8a Follow-up-for: 20bbf5ee4c6c80599a91e7a4b7474e931a27db4a
* core: move check for combination of PAMName= + KillMode= to ↵Mike Yuan2024-08-261-3/+0
| | | | | | | | unit_verify_contexts() While at it, allow "mixed" for all unit types too, i.e. also apply ebc2259da1d1579347b86fc2ebca9f96334b6f22 to socket/mount/swap units.
* core/unit: unexport cg_kill log funcs, rather take in boolMike Yuan2024-08-021-2/+3
| | | | It seems unnecessary to duplicate the func ptrs everywhere.
* core: do not set up cgroup runtime on coldplugMike Yuan2024-06-281-3/+1
| | | | | | | | | | | | | | | | Currently, unit_setup_cgroup_runtime() is called in various _coldplug() functions if the unit is not inactive. That seems unnecessary though, and kinda defeats the purpose of CGroupRuntime. If we need to fork off a process for the unit or got something during deserialization, the CGroupRuntime would be automatically set up by unit_prepare_exec() / cgroup_runtime_deserialize_one(). Otherwise it would mean the cgroup doesn't exist and we don't need to allocate that in the first place. Plus, note that socket units might also carry a cgroup with ExecStartPre=/ExecStartPost=/... Hence the existing code is really inconsistent.
* core/swap: rename variable 'new' -> 'new_unit'Mike Yuan2024-05-151-4/+4
| | | | | | | | | Follow-up for ba31a5018f99864c22dd4e0f10712456c7abc934 'new' is already used as a macro for memory allocation. Let's avoid the confusion here. Addresses https://github.com/systemd/systemd/pull/31902#discussion_r1557672858
* swap: hook up with handoff timestampsLennart Poettering2024-04-251-0/+18
|
* mount,swap: include ExecStatus output in dumpLennart Poettering2024-04-241-0/+15
| | | | | socket and service units output there ExecCommand/ExecStatus definitions already, but this was missing in mount/swap. Fix that.
* core: Serialize both pid and pidfd to keep downgrades workingDaan De Meyer2024-04-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when downgrading from a version with pidfd support to a version without pidfd support, all information about running processes is lost as the newer systemd will serialized pidfds which are not recognized by the older systemd when deserializing. To improve the situation, let's serialize both the pid and the pidfd. This is safe because existing versions will either replace the first deserialized pidref with the second one or discard the second one in favor of the first one depending on the unit and field. Older versions that don't support pidfd's will silently discard any fields that contain a pidfd as those will try to parse the field as a pid and since a pidfd field will start with '@', those versions will debug error log and ignore the value. To make sure we reuse the existing pidfd as much as possible, the pidfd is serialized first. Both for scopes and service main pids, if the same pid is seen multiple times, the first pidref is kept. So by serializing the pidfd first we make sure the original pidfd is used instead of the new one which is opened when deserializing the first pid field. For other control units, older versions with pidfd support will discard the first pidfd and replace it with a new pidfd from the second pid field. This is a slight regression on downgrades, but we make sure it doesn't happen for future versions (and older versions when this commit is backported) by modifying the logic to only use the first successfully deserialized pidref so that the raw pid without pidfd is discarded instead of it replacing the existing pidfd.
* core: align tableYu Watanabe2024-03-291-7/+7
|
* core: introduce UNIT_IS_LOAD_ERROR helperMike Yuan2024-03-231-1/+1
|
* core/swap: another try on memory mgmtMike Yuan2024-03-231-0/+2
| | | | | | | Follow-up for ba31a5018f99864c22dd4e0f10712456c7abc934 Another stupid mistake... Shouldn't have written anything when I was tired.
* core/swap: fix memory management in swap_setup_unitMike Yuan2024-03-221-33/+17
| | | | Follow-up for e9fa1bf704ad2f0a7e257e29889315118b0df459
* core: use RET_GATHER moreMike Yuan2024-03-211-13/+7
|
* core: use ASSERT_PTR(CAST(u)) everywhereMike Yuan2024-03-211-75/+53
|
* core: split out cgroup specific state fields from Unit → CGroupRuntimeLennart Poettering2024-02-161-2/+8
| | | | | | | | | | | | | | | | | | | | | This refactors the Unit structure a bit: all cgroup-related state fields are moved to a new structure CGroupRuntime, which is only allocated as we realize a cgroup. This is both a nice cleanup and should make unit structures considerably smaller that have no cgroup associated, because never realized or because they belong to a unit type that doesn#t have cgroups anyway. This makes things nicely symmetric: ExecContext → static user configuration about execution ExecRuntime → dynamic user state of execution CGroupContext → static user configuration about cgroups CGroupRuntime → dynamic user state of cgroups And each time the XyzContext is part of the unit type structures such as Service or Slice that need it, but the runtime object is only allocated when a unit is started.
* core: use PidRef in exec_spawnLuca Boccassi2024-02-011-6/+1
|
* core: introduce unit_unwatch_pidref_done() helper functionYu Watanabe2024-01-251-6/+1
| | | | No functional change, just refactoring.
* core: use helper functions like unit_main_pid() in unit_kill_context()Yu Watanabe2024-01-241-7/+1
| | | | No functional changes. Just refactoring.
* core: maintain a single table with event source prioritiesLennart Poettering2024-01-191-1/+1
| | | | | | | | | | | | It's hard to oversee the assigned processing priorities of the various event sources we have. Let's unify them in a table (an enum), where we can have a single consisten look at them, and then reference the table entries by expressive symbols. This doesn#t change behaviour in any way, it just gives each priority a nice label, but doesn't change any of the priorities. Prompted by: #30799
* core: add WantsMountsFor=Luca Boccassi2023-11-291-1/+1
| | | | | | | | This is the equivalent of RequiresMountsFor=, but adds Wants= instead of Requires=. It will be useful for example for the autogenerated systemd-cryptsetup units. Fixes https://github.com/systemd/systemd/issues/11646
* core: rename and add comment to ExecParameters cleanup functionsLuca Boccassi2023-11-011-1/+1
|
* swap: Move two functions to swap.hDaan De Meyer2023-10-201-0/+21
|
* process-util: add pidref_is_unwaited() and make pid_is_unwaited() return errorsLennart Poettering2023-10-181-1/+1
|
* core: ensure execute/spawn functions can work without Unit objectLuca Boccassi2023-10-121-9/+2
| | | | | When switching to serialization later, the Unit object will not be serialized, move parameters around instead
* core: ensure execute/spawn functions can work without manager objectLuca Boccassi2023-10-121-5/+7
| | | | | When switching to serialization later, the Manager object will not be serialized, move parameters around instead
* pid1: serialize pidrefs as pidfds if possibleLennart Poettering2023-10-051-7/+2
| | | | One major step towards total pidfdification of systemd.
* core: move pid watch/unwatch logic of the service manager to pidfdLennart Poettering2023-09-281-3/+3
| | | | | | | | | | | This makes sure unit_watch_pid() and unit_unwatch_pid() will track processes by pidfd if supported. Also ports over some related code. Should not really change behaviour. Note that this does *not* add support waiting for POLLIN on the pidfds as additional exit notification. This is left for a later commit (this commit is already large enough), in particular as that would add new logic and not just convert existing logic.
* core: generalize service_arm_timer() for all unit typesLennart Poettering2023-09-271-30/+6
|
* swap: also modernize state engine log message generationLennart Poettering2023-09-271-24/+37
|
* core: port unit_fork_helper_process() and unit_fork_and_watch_rm_rf() to PidRefLennart Poettering2023-09-181-6/+1
|
* core: port unit_main_pid() + unit_control_pid() to PidRef and drop ↵Lennart Poettering2023-09-181-11/+2
| | | | | | | | | | | | unit_kill_common() This ports over unit_main_pid() + unit_control_pid() to return PidRef* pointers (which also means the underlying UnitVTable function pointers are changed accordingly). This then uses te functions to simplify the unit_kill() call, by avoiding the kill() vtable indirection and instead just suing unit_main_pid() and unit_control_pid() directly.
* core: port over unit_kill_context() to PidRefLennart Poettering2023-09-181-6/+7
|
* Merge pull request #29130 from poettering/unit-defaultsLuca Boccassi2023-09-091-3/+3
|\ | | | | core: introduce UnitDefaults structure for unit defaults
| * manager: move various fields that declare unit defaults into a new structure ↵Lennart Poettering2023-09-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UnitDefaults This adds a new structure UnitDefaults which embedds the various default settings for units we maintain. We so far maintained two sets of variables for this, one in main.c as static variables and one in the Manager structure. This moves them into a common structure. This is most just search/replace, i.e. very dumb refactoring. The fact that we now use a common structure for this allows us further refactorings later. Inspired by the discussions on #27890
* | core: don't manually destroy timer when we can't spawn a childLennart Poettering2023-09-091-9/+5
| | | | | | | | | | | | | | | | | | | | | | Let's stop manually destroying the timers when we fail to spawn a child. We don't do this in any of the similar codepaths in any of the unit types, only in two specific ones in socket/swap. Destroying the timer is unnecessary, since this is done anyway in the _set_state() call of each unit type if not appropriate, and every failure path here runs through that anyway. This brings all these similar codepaths into sync.
* | core: also port swap units to PidRefLennart Poettering2023-09-091-26/+35
|/
* tree-wide: drop _pure_ + _const_ from local, static functionsLennart Poettering2023-08-091-4/+4
| | | | | | | | | | | This is supposed to be a help for compilers to apply optimizations on functions where they can't determine whether they are const/pure on their own. For static, local functions the compiler can do this on its own easily however, hence the decoration with pure/const is just noise. Let's drop it, and let the compiler to its thing better. (Use it for exported functions, since compilers can't 'reach-over' into other modules to determine if they are pure, except if LTO is used)
* Merge pull request #27867 from keszybz/vconsole-reload-againLuca Boccassi2023-07-151-5/+1
|\ | | | | Restore ordering between vconsole-setup and firstboot services
| * Revert "pid1: order units using TTYVHangup= after vconsole setup"Zbigniew Jędrzejewski-Szmek2023-07-121-5/+1
| | | | | | | | | | | | | | | | | | | | This reverts commit e019ea738d63d5f7803f378f8bd3e074d66be08f. In the new approach, a lock on /dev/console will be used. This lock will solve the issue for services which run in early boot. Services which run later are ordered after sysinit.target, so they'll run much later anyway so this automatic dependency is not useful. Let's remove it again to make the code simpler.
* | device-util: Declare iterator variables inlineDaan De Meyer2023-07-121-2/+2
|/
* pid1: also encode whether to send plymouth notifications in UnitVTableLennart Poettering2023-06-301-0/+2
|
* core: drop UnitNotifyFlagsMike Yuan2023-05-241-1/+1
| | | | | | This essentially reverts 2ad2e41a72ec19159c0746a78e15ff880fe32a63. No longer needed after dropping UNIT_NOTIFY_WILL_AUTO_RESTART.
* pid1: order units using TTYVHangup= after vconsole setupZbigniew Jędrzejewski-Szmek2023-05-191-1/+5
| | | | | | | | | | | | | | | | The goal of this change is to delay getty services until after systemd-vconsole-setup has finished. systemd-vconsole-setup starts loadkeys, and it seems that when loadkeys is interrupted by the TTY hangup call we do when starting tty services [1], so that loadkeys starts getting EIO from the ioctl("/dev/tty1", KDSKBENT) syscall it does. Fixes #26908. [1] https://github.com/legionus/kbd/issues/92#issuecomment-1554451788 Initially I wanted to add ordering dependencies to individual units, but TTYVHangup= can be added to other various external units too. The solution with an implicit dependency should cover those cases too.
* core: Move DynamicCreds into ExecRuntimeDaan De Meyer2023-03-271-9/+1
| | | | | This is just another piece of runtime data so let's store it in ExecRuntime alongside the other runtime data.
* core: Introduce unit private exec runtimeDaan De Meyer2023-03-271-2/+2
| | | | | | | | Currently, exec runtimes can be shared between units (using JoinsNamespaceOf=). Let's introduce a concept of a private exec runtime that isn't shared with JoinsNamespaceOf=. The existing ExecRuntime struct is renamed to ExecRuntimeShared and becomes a private member of the new private ExecRuntime.
* execute: Do not pass destroy as a boolean argument to unref()Daan De Meyer2023-03-271-2/+2
| | | | | Let's mimick what we do for DynamicUser and have two separate functions for unreffing and destroying a ExecSharedRuntime object.
* execute: Rename ExecRuntime to ExecSharedRuntimeDaan De Meyer2023-03-271-2/+2
| | | | Preparation for next commit
* pid1: add unit file settings to control memory pressure logicLennart Poettering2023-03-011-0/+1
|
* pid1: add a new D-Bus method for enquing POSIX signals with values to unit ↵Lennart Poettering2023-02-171-2/+2
| | | | | | | | | | | processes This augments the existing KillUnit() + Kill() methods with QueueSignalUnit() + QueueSignal(), which are what sigqueue() is to kill(). This is useful for sending our new SIGRTMIN+18 control signals to system services.