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

Mirco Tischler mt-ml at gmx.de
Thu Oct 18 12:03:20 PDT 2012


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?
>
> --
> David Strauss
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


More information about the systemd-devel mailing list