Re: Union mount and lockdep design issues

From: Michal Suchanek
Date: Tue Jul 12 2011 - 05:58:59 EST


On 12 July 2011 10:30, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
> Michal Suchanek <hramrach@xxxxxxxxxx> writes:
>
>> The locking order is likely determined by the structure of the union
>> and not some system-wide order of filesystems so assuming the readonly
>> layers are locked as well you will probably get a deadlock with
>> technically correct mount:
>>
>> mount -t overlayfs overlayfs -olowerdir=/lower2,upperdir=/upper /tmpoverlay
>> mount -t overlayfs overlayfs -olowerdir=/lower1,upperdir=/tmpoverlay /overlay
>>
>> mount -t overlayfs overlayfs -olowerdir=/lower1,upperdir=/upper2 /tmpoverlay2
>> mount -t overlayfs overlayfs -olowerdir=/lower2,upperdir=/tmpoverlay2 /overlay2
>>
>> because now lower1 and lower2 are differently ordered in the two
>> overlays.
>
> Overlayfs never locks both upper and lower at the same time, which means
> there's no AB-BA locking dependency. ÂThe lock orderings are:
>
> -> /overlay
> Â-> /lower1
> Â-> /tmpoverlay
> Â Â-> /lower2
> Â Â-> /upper
> -> /overlay2
> Â-> /lower2
> Â-> /tmpoverlay2
> Â Â-> /lower1
> Â Â-> /upper2
>
> As you can see there's no nesting of lower2 and lower1 into each other.
>
> When you combine two filesystems, a completely new ordering is created
> each time, there's no possibility to make an AB-BA nesting. ÂAt least I
> cannot see one.

Except you can get in situation where overlay locks lower1 and
tmpoverlay waits for lower2 which is held by overlay2 waiting for
lower1 in tmpoverlay2.

Thanks

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/