<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Required units are not started in certain setups"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=85746">85746</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Required units are not started in certain setups
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>systemd
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>general
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lethalman88@gmail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With a certain setup some required units may not be started. It is always
reproducible.

S1.service requires/after D.device and S2.service
S1 is activating, thus starts D and S2
S2 starts, which activates D and deactivates D
S1 "can" now start because D has no job running [1] and the device is not asked
to start. Hence D is not there and the service fails to run.

The steps to reproduce are really simple.

Setup some helper files in e.g. /root/tests:

- Create a disk, truncate -s 1M disk
- mkfs.ext4 disk
- mkdir mnt

Add the following two services.

s1.service:

[Unit]
Requires=s2.service dev-loop0.device
After=s2.service dev-loop0.device
[Service]
ExecStart=/bin/mount /dev/loop0 /root/tests/mnt
Type=oneshot

s2.service:

[Service]
ExecStart=/sbin/losetup /dev/loop0 /root/tests/disk
ExecStart=/sbin/losetup -d /dev/loop0
Type=oneshot
RemainAfterExit=true

systemctl start s1

It fails, because /dev/loop0 has been unmounted. I expect instead s1 to hang
waiting for the device, i.e. add back the start job for the device.

[1] <a href="http://lxr.devzen.net/source/xref/systemd/src/core/job.c#429">http://lxr.devzen.net/source/xref/systemd/src/core/job.c#429</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>