On 05/08/14 at 12:07pm, Vivek Goyal wrote:
On Thu, May 08, 2014 at 08:30:19PM +0800, WANG Chao wrote:
[..]
> Because when emergency.service is triggered, all the other services are
> stopped running, even the mounted filesystem is umounted.
This is strange. Why already mounted filesysems should be unmounted. I
think we should send a mail to systemd and ask about this behavior.
I think that a mount unit is just like a service unit from systemd's
point of view. When systemd "isolate" to emergency.target, all the rest
of units (including service/target/mount/slice/... man systemd.unit(5)
for more types) will be stopped.
"isolate" is targeting all unit types, not just for xxx.service.
FWIW one can specify "IgnoreOnIsolate=yes" to any type of unit to avoid
being stopped. But this is not our case, because mount units are
generated runtime.
>
> But I've figured a way to bring /sysroot back to life before
> dump_to_rootfs by manually:
>
> systemctl start initqueue
s/initqueue/dracut-initqueue
> systemctl start sysroot.mount
I am not convinced with this idea of trying to call back into systemd
to start some units after failure. This sounds little fragile to me.
dracut-initqueue only have dependencies for udev related unit. In fact,
it will only run the scripts under initqueue hook (like dracut-pre-pivot
hook). The initqueue hook is used to bring device online by some
installed scripts at generate-time.
It looks to me both dracut-initqueue.service and sysroot.mount are
pretty much independant. So I think that would be too much risky to call
back to these two.
Having said that, it might not be perfect solution but if it works, it
might not be too bad a solution till we find even better solution.
Bottom line is we need /sysroot when dump_to_rootfs ...
Do we really have to kick initqueue again? Just starging sysroot.mount
is not enough?
Probally not "again". Failure can happen at any point of time, that
means it could happen before dracut-initqueue gets started. So starting
dracut-initqueue will ensure that the desired device is brought up
before trying to mount it. Otherwise starting sysroot.mount will be
blocking to wait for the disk.
Also after starting sysroot.mount, how long will you wait for root to
be mounted?
"systemctl start sysroot.mount" will block as long as it's mounted or
the worst case timeout after 90 seconds.
If everything goes smoothly, sysroot.mount shouldn't block for long.
How are you inducing failure to invoke this error path?
There's a critical path for systemd boot (man bootup(7)).
Any failure of the units in this path would cause an isolation to
emergency.target. Take initrd-fs.target as an example:
[..]
OnFailure=emergency.target
OnFailureIsolate=yes
It explicitly says what to do when failure happens on this unit. That
said, when failure happens, systemd will isolate to emergency.target,
which will in turn call emergency.service.
>
> I'm not sure if I'm supposed to do. But it seems to be the best chance
> to make root fs available and mounted.
I think here one fundamental problem is that we are not propagating
the failure status upwards if a target fails to reach. If we can look
into that and talk to systemd folks that how about failing all the
services which are waiting on a particular target and we know that
that target has failed to reach. (It could be done at same time
when OnFailure= for target is called).
I'll look into that and find out the possibilies.
IOW, I was thinking how about making kdump dump saving code a service
and make that service "Requires" relevant services and targets. And
if any of the service or target fails, kdump service failure routine
should be invoked. I think that probably will require changes in systemd
and is a long term solution.
I did that in my patchset. But I'm not sure if that's what you want ...
I think in short term we should be able to live with following.
- Fix systemd to not unmount already mounted file sysmtems as kdump
error handler requires that.
I'm not convincing by that. I think if isolation happens, all unit
should be stopped, ie. mount unit should be unmounted.
- Drop into kdump through emergency shell and check if root is mounted
and save dump to root (in dump_to_rootfs) case, otherwise reboot.
sysroot.mount probally doesn't even get started when emergency is
triggered. Why don't we mount /sysroot ourselves?
Thanks
WANG Chao