El sáb., 17 ago. 2019 a las 20:01, Laurent Bercot escribió:
>
> - If a filesystem can track all the processes that have a handle on
> it, it is possible to have it be mounted/unmounted symmetrically by
> the service manager.
I don't think there are filesystems that can do that?
> At unmount time, kill the processes that would
> block the unmount operation, then perform the unmount, then run the
> additional commands. In that case it's all done at the service manager
> level, s6-linux-init doesn't have to do anything.
That's OpenRC's approach, except it does not rely on filesystem
features. It just uses 'fuser -m -k'. But it leads to code that's
quite ugly I think, compared to the simplicity of s6-linux-init's
'kill(-1, SIGTERM)' + 'kill(-1, SIGKILL)':
*
https://github.com/OpenRC/openrc/blob/882c6bf3bcaba6903d9dc593f8ae41e505b4e4e7/sh/rc-mount.sh
(mountinfo is another OpenRC internal command)
> - There could be a hook in the autogenerated stage 4 script, which
> runs a user-provider script, something like rc.shutdown.after-umount.
This is probably better, but I'd also like to hear other opinions.
> I don't much like giving control to a user script at that level, when
> there are no services running and no mounted filesystems, possibly
> not even /proc or /sys,
You'd probably have to make some exclusions in
s6-linux-init-umountall, like Casper said. Maybe parse the fstype
field in /proc/mounts lines and omit sysfs, proc, tmpfs and devtmpfs?
BTW, OpenRC also does exclusions, via --skip-point-regex and
--skip-fstype-regex options passed to mountinfo (see do_unmount
invocations in services localmount and mount-ro). I admit this
complicates s6-linux-init-umountall.
> and when a hang in a user script could
> very well prevent a clean reboot
I haven't thougt of that. Ouch. Maybe a mechanism like the one
s6-supervise uses to limit execution of the finish file in
s6-linux-init-shutdownd, or some shutdown hook runner? I admit it
complicates s6-linux-init-shutdownd :)
> Admins/distros would have to make sure the deactivate_* functions
> only call binaries that are on the root filesystem.
It is obvious to me that it must be that way, but in this era in which
some distributions want to put every executable in /usr/bin and mount
/usr from an initramfs, who knows :P But that's the distribution's
job, I agree.
G.
G.
Received on Sun Aug 18 2019 - 15:08:55 UTC