On Sun, May 03, 2015 at 06:06:58PM +0300, Andrei Borzenkov wrote: > В Sun, 3 May 2015 16:17:15 +0200 > Lennart Poettering <lenn...@poettering.net> пишет: > > > On Sat, 02.05.15 13:16, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) > > wrote: > > > > So, the last time we discussed this we figured we should do this > > differently, and simply generate systemd-fsck-root.service in the > > initrd as well, that uses a different command line internally. The end > > result would then be that we can do without flag file, and always have > > the guarantee that "systemd-fsck-root.service" is the services that > > fsck'ed the root file system, regardless whether in initrd or not. > > > > systemd-fsck@.service has explicit dependency on > systemd-fsck-root.service so other mounts (/usr, anything else?) will > be serialized after it. Currently they can run in parallel. > > Not I think it is a big problem, but at least to consider. Yeah, that's the main wart. I tried to outline it in the second bullet point below.
I prepared a patch to generate systemd-fsck-root.service in generator_write_fsck_deps() first, but I wasn't happy with the result. If we ignore the dependency issue, it might be judged more elegant, since it just uses unit stat to pass information. > > Harald, can you comment? Zbyszek > > > In the initramfs, we run systemd-fsck@<sysroot-device>.service. > > > In the real system we run systemd-fsck-root.service. It is hard > > > to pass the information that the latter should not run if the first > > > succeeded using unit state only. > > > > > > - in the real system, we need a synchronization point between the fsck > > > for root and other fscks, to express the dependency to run this > > > systemd-fsck@.service "before all other systemd-fsck@ units". We > > > cannot express it directly, because there are no wildcard > > > dependencies. We could use a target as a sychronization point, but > > > then we would have to provide drop-ins to order > > > systemd-fsck@-.service before the target, and all others after it, > > > which becomes messy. The currently used alternative of having a > > > special unit (systemd-fsck-root.service) makes it easy to express > > > this dependency, and seems to be the best solution. > > > > > > - we cannot use systemd-fsck-root.service in the initramfs, because > > > other fsck units should not be ordered after it. In the real system, > > > the root device is always checked and mounted before other filesystems, > > > but in the initramfs this doesn't have to be true: /sysroot might be > > > stacked on other filesystems and devices. > > > > > > - the name of the root device can legitimately be specified in a > > > different way in the initramfs (on the kernel command line, or > > > automatically discovered through GPT), and in the real fs (in > > > /etc/fstab). > > > Even if we didn't need systemd-fsck-root.service as a synchronization > > > point, it would be hard to ensure the same instance parameter is > > > provided for systemd-fsck@.service in the initrams and the real > > > system. > > > > > > Let's use a "side channel" to pass this information. > > > /run/systemd/fsck-root-done is touched after fsck in the initramfs > > > succeeds, through an ExecStartPost line in a drop-in for > > > systemd-fsck@sysroot.service. > > > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1201979 > > > --- > > > src/shared/generator.c | 7 +++++++ > > > units/systemd-fsck-root.service.in | 1 + > > > 2 files changed, 8 insertions(+) > > > > > > diff --git a/src/shared/generator.c b/src/shared/generator.c > > > index 7b2f846175..a71222d1cb 100644 > > > --- a/src/shared/generator.c > > > +++ b/src/shared/generator.c > > > @@ -78,6 +78,13 @@ int generator_write_fsck_deps( > > > "RequiresOverridable=%1$s\n" > > > "After=%1$s\n", > > > fsck); > > > + > > > + if (in_initrd() && path_equal(where, "/sysroot")) > > > + return write_drop_in_format(dir, fsck, 50, > > > "stamp", > > > + "# Automatically > > > generated by %s\n\n" > > > + "[Service]\n" > > > + > > > "ExecStartPost=-/bin/touch /run/systemd/fsck-root-done\n", > > > + > > > program_invocation_short_name); > > > } > > > > > > return 0; > > > diff --git a/units/systemd-fsck-root.service.in > > > b/units/systemd-fsck-root.service.in > > > index 3617abf04a..48dacc841c 100644 > > > --- a/units/systemd-fsck-root.service.in > > > +++ b/units/systemd-fsck-root.service.in > > > @@ -11,6 +11,7 @@ Documentation=man:systemd-fsck-root.service(8) > > > DefaultDependencies=no > > > Before=local-fs.target shutdown.target > > > ConditionPathIsReadWrite=!/ > > > +ConditionPathExists=!/run/systemd/fsck-root-done > > > > > > [Service] > > > Type=oneshot > > > -- > > > 2.3.5 > > > > > > _______________________________________________ > > > systemd-devel mailing list > > > systemd-devel@lists.freedesktop.org > > > http://lists.freedesktop.org/mailman/listinfo/systemd-devel > > > > > > Lennart > > > > _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel