Fix warnings when detaching loopback devices

Once upon a time, 'umount -d' would occasionally fail to unmount a
loopback device because it was racing with udisks, which was accessing
the loopback device at the same time (chromium:337490).  To deal with
this, we introduced a workaround where we stopped using the '-d' flag
for umount and instead manually unmounted the loopback device inside a
retry loop with a 'sleep 1' to wait for udisks to finish poking at the
loopback device.  Later udisks was turned off on the bots and has been
replaced by udisks2 on developer workstations, which doesn't appear to
have the same problem.

Commit fe050bcd reintroduced the '-d' flag when it changed the unmount
code to use the fs_umount function, which uses safe_umount_tree under
the hood, which does use the '-d' flag for umount.  However at this
point there was a bug in util-linux where using the '-d' flag with the
mount point instead of the loop device would fail with "Invalid
argument" (chromium:458267).  So we put in another workaround to catch
this case and treat it as successful because the loopback device would
be cleaned up later.

That bug has been fixed in the latest version of util-linux in the
chroot (2.27.1) so now we get the following sequence of events:

- 'umount -d' unmounts both the file system and the loopback device.
- The retry loop workaround from the first issue assumes the loopback
  device still exists and doesn't check for it.
- We attempt to detach the already detached loopback device, which
  predictably fails with a "no such device" error.
- The retry loop assumes the failure is due to the race condition and
  sleeps for a bit before trying again.
- This process repeats five times before the retry loop gives up.

This CL does two things:

1) Remove the workaround for the 'umount -d' bug in util-linux since
   that has now been fixed.
2) Remove the retry loop for manually detaching loopback devices.
   Auto-detection has been turned off on the bots and udisks has been
   replaced by udisks2 on developer machines, which doesn't appear to
   have the same problem given the reliability with which the unmount
   successfully detaches the loopback device.

This saves ~15 seconds on every invocation of build_image.

BUG=chromium:337490,chromium:458267
TEST=run build_image.sh; see that there are no warnings about loopback
     devices and that an image is still properly created.

Change-Id: Ic785c9b096bf8c100e29a7a76af3a8e108d04c16
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/357190
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2 files changed