Repository navigation
shutdown: Finalize file systems and devices after attempting exitrd - #38767
ElvishJerricco wants to merge 1 commit into
Conversation
|
Please rebase. |
The `nonunmountable_path` function attempts to avoid unmounting OS file systems like `/usr` during shutdown so that the `system-shutdown/` executables can function. However, some "extrinsic" file systems may still be necessary here, which aren't covered by that function. For example, if `/usr` is an overlayfs with a `lowerdir=` / `upperdir=` based on another file system, those other file systems should be considered extrinsic, and should also not be unmounted before `/usr`. More generally, a file system is considered "extrinsic" when it is setup by the initrd, and these file systems should accordingly be torn down by the exitrd. Similar points can be made for MD / DM / loopback devices. If these resources survive past `umount.target` and `shutdown.target`, we should allow exitrd to be the one responsible for reaping them. If there is no exitrd, fallback to the old behavior.
a1544bd to
da5e29f
Compare
|
@yuwata Done |
|
Humpf, this doesn't seem right to me. It's a major change in behaviour to let the exitrd do everything. So far the exitrd was just the fallback to clean up the rest, not the primary thing. I am not convicned we are ready to change this all. Why this at all? it appears to me this is a cosmetic issue, no? when we dissassmble things and cannot disassemble some dirs, then we'll give up and hand over to exitrd, which seems to be exactly what you want? |
|
it might make sense to add x-systemd.extrinsic or so as a userspace mount option you could set, that if set we'll skip during the umount loop. |
The problem is that it can disassemble some things that it really shouldn't be. It uses
Note that the term "extrinsic" is already used to describe these mounts, because we give them That said, to me letting the exitrd handle things first just makes sense. The exitrd seems less like a fallback and more like a counterpart to initrd to me. It makes sense to me that, if we have an exitrd, we should let it handle anything that the initrd had set up. |
hmm, "destroyed"? didn't overlayfs pin the superblocks of its layers, so that they can otherwise be unmounted? what do you mean by "breaks the systemd-shutdown hooks" precisely? |
well, our detach loop does considerably more than unmounting, i.e. killing and detaching all kinds of stuff. I am quite confident we should disassemble everything we can before letting the exitrd do the final bits. |
Huh... I was quite confident when I made this PR that there was a problem with this. I thought that unmounting with If I make an overlay whose |
It still seems reasonable to me that the extrinsic mounts should be left for exitrd to unmount. So maybe we leave the loop where it is, but change which things it unmounts. Do you think it would be good to be checking against |
|
hmm, this is all written with the thinking that file systems which are still used return EBUSY. The only reason we do nonunmountable_path() is because trying to unmount those is pointless or wrong. but the extrinsic ones are not of that kind i would say, it just means that during normal operation they shouldn't be shut down, i.e. via .mount units. it does not say anything about the final shutdown phases. or to say this differently: i really prefer if the file systems in question would actually be fixed to not fail on any of this and would behave like all others, i.e. return EBUSY if referenced without causing desaster. (i'd be more open to adding a new userspace mount option that allows excluding mounts from the final umount spree, but i think that'd be a hack too, and the right fix would be to make sure your p9/overlayfs case would be fixed in the kernel) |
|
hmm, i wonder if this is caused by our use of MNT_FORCE, as per umount2() docs this has an effect on 9pfs.. |
confirmed this with my resident kernel vfs expert. Not sure what the right approach to deal with that is now. Maybe something like this: Right now our shutdown umount loop works something like this:
Let's modify this loop so that we do step 1 without MNT_FORCE first. and then in step 3, set a flag so that the next umount() we call, we'll do with MNT_FORCE. if that worked for one umount we immediately unset that flag again, and do another run of the loop, and continue as usual. Only if we did a full loop cycle where the flag stayed on until the end (i.e. where MNT_FORCE didn't help) we'll exit the loop. That would mean, in your overlayfs on top of 9pfs we'd always try to umount the overlayfs before issuing a destructive 9p umount request. Does that make sense? |
|
Let's close this one, new pr with the approach suggested by @poettering would be welcome |
The
nonunmountable_pathfunction attempts to avoid unmounting OS file systems like/usrduring shutdown so that thesystem-shutdown/executables can function. However, some "extrinsic" file systems may still be necessary here, which aren't covered by that function.For example, if
/usris an overlayfs with alowerdir=/upperdir=based on another file system, those other file systems should be considered extrinsic, and should also not be unmounted before/usr.More generally, a file system is considered "extrinsic" when it is setup by the initrd, and these file systems should accordingly be torn down by the exitrd. Similar points can be made for MD / DM / loopback devices. If these resources survive past
umount.targetandshutdown.target, we should allow exitrd to be the one responsible for reaping them.If there is no exitrd, fallback to the old behavior.
A little extra context: We ran into this with NixOS because our VM tests usually use an overlay for
/nix/store(and we patchnonunmountable_pathsto include/nix/store), and theMNT_FORCEinumount_with_timeouton/nix/.ro-store(thelowerdir) broke the overlay and prevented oursystem-shutdown/scripts from functioning. But it seems logical to me in the general case that file systems setup by initrd should be torn down by exitrd, and not before the transition to exitrd.