-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch-root: use MS_REC for /run, unless we are soft-rebooting #28497
Conversation
src/core/main.c
Outdated
@@ -1884,7 +1884,8 @@ static int do_reexecute( | |||
if (switch_root_dir) { | |||
r = switch_root(/* new_root= */ switch_root_dir, | |||
/* old_root_after= */ NULL, | |||
/* flags= */ objective == MANAGER_SWITCH_ROOT ? SWITCH_ROOT_DESTROY_OLD_ROOT : 0); | |||
/* flags= */ (objective == MANAGER_SWITCH_ROOT ? SWITCH_ROOT_DESTROY_OLD_ROOT : 0) | | |||
(objective == MANAGER_SOFT_REBOOT ? SWITCH_ROOT_NON_RECURSIVE_RUN : 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually name things in positive, So, I'd like the following.
(objective == MANAGER_SWITCH_ROOT ? SWITCH_ROOT_DESTROY_OLD_ROOT | SWITCH_ROOT_RECURSIVE_RUN : 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that requires changing more places, so I'll leave it as-is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that requires changing more places, so I'll leave it as-is
More places? The enum is introduced by the commit. I do not think that's so many. Only three places in your patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch_root() is used elsewhere too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked now, and it's used in exactly two places ;) So I think it'd be nicer to rework the flag to be positive. The definition of run_mount_flags
below becomes much nicer with a positive option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty clear and should fix the issue. My vote in the naming bikeshed is to rename, but it's not terribly important. If you disagree, feel free to set back the flag back.
src/core/main.c
Outdated
@@ -1884,7 +1884,8 @@ static int do_reexecute( | |||
if (switch_root_dir) { | |||
r = switch_root(/* new_root= */ switch_root_dir, | |||
/* old_root_after= */ NULL, | |||
/* flags= */ objective == MANAGER_SWITCH_ROOT ? SWITCH_ROOT_DESTROY_OLD_ROOT : 0); | |||
/* flags= */ (objective == MANAGER_SWITCH_ROOT ? SWITCH_ROOT_DESTROY_OLD_ROOT : 0) | | |||
(objective == MANAGER_SOFT_REBOOT ? SWITCH_ROOT_NON_RECURSIVE_RUN : 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked now, and it's used in exactly two places ;) So I think it'd be nicer to rework the flag to be positive. The definition of run_mount_flags
below becomes much nicer with a positive option.
There are applications that rely on mounts under /run surviving the switch from initrd to rootfs, so use MS_REC unless we are soft rebooting. Follow-up for 7c764d4 Fixes systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
I prefer to have a flag that is used when the non-default behaviour is needed - I have renamed it to |
Sounds good to me. |
There are applications that rely on mounts under /run surviving the
switch from initrd to rootfs, so use MS_REC unless we are soft
rebooting.
FIxes #28452