[dm-devel] [PATCH] improve atomicity of device creation

Kay Sievers kay.sievers at vrfy.org
Tue Dec 11 18:03:09 UTC 2007


On Dec 11, 2007 6:40 PM, Scott James Remnant <scott at ubuntu.com> wrote:
>
> On Tue, 2007-12-11 at 18:35 +0100, Kay Sievers wrote:
>
> > On Dec 11, 2007 5:08 PM, Scott James Remnant <scott at ubuntu.com> wrote:
> > > This is a patch we've written and applied in Ubuntu to improve the
> > > atomicity of devmapper device creation somewhat, and avoid races with
> > > udev.
> >
> > Without synchronization between libdevmapper and udev, you can't
> > predict which one will win in creating the node, right?
> > So this patch makes is more likely to create a valid device node, but
> > it can still happen, that libdevmapper replaces the udev nodes, which
> > is not what we want, right?
> >
> No, the patch is slightly skewed so that udev always wins.  udev will
> always adopt an existing device node, adjusting permissions as
> necessary.  The patch makes devmapper "back off" if the device node
> exists.
>
> So you end up with either:
>
>  1) devmapper creates device node
>  2) udev adopts device node and sets permissions
>
> or:
>
>  1) udev creates device node and sets permissions
>  2) devmapper no-ops since it already exists

There is a  window between stat() and rename() in libdevmapper,
how can you konw that "udev always wins"?

Kay




More information about the dm-devel mailing list