Merge pull request #19817 from keszybz/switch-root-serialization
Drop serialization of mounts and automounts over root switch
This commit is contained in:
@@ -1087,6 +1087,7 @@ const UnitVTable automount_vtable = {
|
||||
.can_transient = true,
|
||||
.can_fail = true,
|
||||
.can_trigger = true,
|
||||
.exclude_from_switch_root_serialization = true,
|
||||
|
||||
.init = automount_init,
|
||||
.load = automount_load,
|
||||
|
||||
+1
-5
@@ -3321,11 +3321,7 @@ int manager_serialize(
|
||||
if (u->id != t)
|
||||
continue;
|
||||
|
||||
/* Start marker */
|
||||
fputs(u->id, f);
|
||||
fputc('\n', f);
|
||||
|
||||
r = unit_serialize(u, f, fds, !switching_root);
|
||||
r = unit_serialize(u, f, fds, switching_root);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -2176,6 +2176,7 @@ const UnitVTable mount_vtable = {
|
||||
|
||||
.can_transient = true,
|
||||
.can_fail = true,
|
||||
.exclude_from_switch_root_serialization = true,
|
||||
|
||||
.init = mount_init,
|
||||
.load = mount_load,
|
||||
|
||||
@@ -89,13 +89,25 @@ static const char *const io_accounting_metric_field_last[_CGROUP_IO_ACCOUNTING_M
|
||||
[CGROUP_IO_WRITE_OPERATIONS] = "io-accounting-write-operations-last",
|
||||
};
|
||||
|
||||
int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
|
||||
int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool switching_root) {
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
assert(f);
|
||||
assert(fds);
|
||||
|
||||
if (switching_root && UNIT_VTABLE(u)->exclude_from_switch_root_serialization) {
|
||||
/* In the new root, paths for mounts and automounts will be different, so it doesn't make
|
||||
* much sense to serialize things. API file systems will be moved to the new root, but we
|
||||
* don't have mount units for those. */
|
||||
log_unit_debug(u, "not serializing before switch-root");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Start marker */
|
||||
fputs(u->id, f);
|
||||
fputc('\n', f);
|
||||
|
||||
if (unit_can_serialize(u)) {
|
||||
r = UNIT_VTABLE(u)->serialize(u, f, fds);
|
||||
if (r < 0)
|
||||
@@ -175,7 +187,7 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
|
||||
(void) serialize_item_format(f, ip_accounting_metric_field[m], "%" PRIu64, v);
|
||||
}
|
||||
|
||||
if (serialize_jobs) {
|
||||
if (!switching_root) {
|
||||
if (u->job) {
|
||||
fputs("job\n", f);
|
||||
job_serialize(u->job, f);
|
||||
|
||||
+13
-10
@@ -543,8 +543,8 @@ typedef struct UnitVTable {
|
||||
|
||||
bool (*can_reload)(Unit *u);
|
||||
|
||||
/* Write all data that cannot be restored from other sources
|
||||
* away using unit_serialize_item() */
|
||||
/* Serialize state and file descriptors that should be carried over into the new
|
||||
* instance after reexecution. */
|
||||
int (*serialize)(Unit *u, FILE *f, FDSet *fds);
|
||||
|
||||
/* Restore one item from the serialization */
|
||||
@@ -646,7 +646,7 @@ typedef struct UnitVTable {
|
||||
/* Type specific cleanups. */
|
||||
void (*shutdown)(Manager *m);
|
||||
|
||||
/* If this function is set and return false all jobs for units
|
||||
/* If this function is set and returns false all jobs for units
|
||||
* of this type will immediately fail. */
|
||||
bool (*supported)(void);
|
||||
|
||||
@@ -654,25 +654,28 @@ typedef struct UnitVTable {
|
||||
UnitStatusMessageFormats status_message_formats;
|
||||
|
||||
/* True if transient units of this type are OK */
|
||||
bool can_transient:1;
|
||||
bool can_transient;
|
||||
|
||||
/* True if cgroup delegation is permissible */
|
||||
bool can_delegate:1;
|
||||
bool can_delegate;
|
||||
|
||||
/* True if the unit type triggers other units, i.e. can have a UNIT_TRIGGERS dependency */
|
||||
bool can_trigger:1;
|
||||
bool can_trigger;
|
||||
|
||||
/* True if the unit type knows a failure state, and thus can be source of an OnFailure= dependency */
|
||||
bool can_fail:1;
|
||||
bool can_fail;
|
||||
|
||||
/* True if units of this type shall be startable only once and then never again */
|
||||
bool once_only:1;
|
||||
bool once_only;
|
||||
|
||||
/* Do not serialize this unit when preparing for root switch */
|
||||
bool exclude_from_switch_root_serialization;
|
||||
|
||||
/* True if queued jobs of this type should be GC'ed if no other job needs them anymore */
|
||||
bool gc_jobs:1;
|
||||
bool gc_jobs;
|
||||
|
||||
/* True if systemd-oomd can monitor and act on this unit's recursive children's cgroup(s) */
|
||||
bool can_set_managed_oom:1;
|
||||
bool can_set_managed_oom;
|
||||
} UnitVTable;
|
||||
|
||||
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
|
||||
|
||||
Reference in New Issue
Block a user