[systemd-devel] Race condition for service dependent on mount

Lennart Poettering lennart at poettering.net
Tue Oct 23 12:00:39 PDT 2012


On Thu, 18.10.12 21:03, Mirco Tischler (mt-ml at gmx.de) wrote:

> 
> 2012/10/18 David Strauss <david at davidstrauss.net>:
> > If a service depends on a mount, systemd doesn't properly wait for the
> > mount to complete before starting the service. This creates bad race
> > conditions where the service may write to the mount directory before
> > the mount is active, which can stop the mount from even completing
> > successfully because the mount directory isn't empty. We might be able
> > to stop the writes through permissions on the mount directory, but the
> > writes would still fail.
> >
> > The cleanest solution to this seems to be "notify" integration into
> > the mount utility so it tells systemd that the mount is complete or
> > waiting for the mount request to complete in some other way.
> >
> > Part of why we use this dependency is to perform the mount before
> > "forking" the file system namespace for the dependent service. This
> > allows the dependent service file system namespace to not propagate
> > further mounts from the main file system.
> >
> > Has anyone else looked into this?
> >
> I was under the impression that systemd waits for mount to exit before
> it marks the unit as started. And mount itself may either mount the fs
> and exit or wait for a fs specific helper to exit, which then does the
> actual mounting and exits only after the mount is complete. So systemd
> should never mark a mount unit as mounted before it actually is ready.
> At least that's how I think it's supposed to work. Every deviation I
> would count as a bug. Or is my logic flawed?

Mirco is right, systemd does wait for mount(8) to finish before going to
the next unit. If this doesn't work this is most likely a bug in the
respective fs? (which one is it?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list