[systemd-devel] [PATCH v3] device: Fix overzealous unmounting of tentative device mounts

Martin Pitt martin.pitt at ubuntu.com
Tue May 19 01:23:46 PDT 2015


Hello all,

I have a better fix now.

Martin Pitt [2015-05-19  8:59 +0200]:
>  - Boot, dev-foo.device becomes DEVICE_FOUND_MOUNT/tentative
> 
>  - Do some more mounts from /dev/foo, e. g.
> 
>    mkdir /tmp/etc /tmp/boot
>    mount -o bind /etc /tmp/etc
>    mount -o bind /boot /tmp/boot
> 
>    (In practice, you'd probably do such bind mounts with nspawn --bind
>    or lxc.mount.entry)
> 
>    tmp-etc.mount and tmp-boot.mount will be BindsTo=dev-foo.device,
>    and dev-foo.device's status is still unchanged
>    (DEVICE_FOUND_MOUNT/tentative)
> 
>  - Now do umount /tmp/boot. This *also* umounts /tmp/etc!

With this patch, the unit states are now as expected:

  Id=dev-foo.device
  BindsTo=
  BoundBy=tmp-boot.mount
  ActiveState=activating
  SubState=tentative

  Id=tmp-boot.mount
  BindsTo=dev-foo.device
  BoundBy=
  ActiveState=active
  SubState=mounted

And /tmp/etc stays around. After manually unmounting /tmp/mount, the
device state properly goes to "dead":

  Id=dev-foo.device
  BindsTo=
  BoundBy=
  ActiveState=inactive
  SubState=dead

> So the problem is that this tentative → dead transition only works if
> a device is referenced once, but causes overzealous unmounts if there
> are more references.
> 
> We need a reference count, or check if the device is bound by other
> device still. Come to think of it now, we actually already have that:
> 
>   Id=dev-foo.device
>   BoundBy=tmp-boot.mount tmp-etc.mount
> 
> But my patch doesn't take that into account yet.

This one does now. I left a fairly comprehensive commit log as this
isn't that easy to explain/understand. If it's too verbose for you I
can also trim it back a bit.

Thanks,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-device-Fix-overzealous-unmounting-of-tentative-devic.patch
Type: text/x-diff
Size: 3940 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150519/ea477bff/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150519/ea477bff/attachment.sig>


More information about the systemd-devel mailing list