[lockdev-devel] Current status

Roger Leigh rleigh at codelibre.net
Mon May 3 15:36:14 UTC 2010


Hi,

I've applied (I think) all outstanding patches and pushed them.  Is
there anything I missed that still needs applying?

Testing with the lockdev (sample.c) helper, "lockdev -l /dev/ttyS0",
we're creating these files:

-rw-rw-r-- 3 rleigh rleigh   11 May  3 16:15 LCK...16672
-rw-rw-r-- 3 rleigh rleigh   11 May  3 16:15 LCK..ttyS0
-rw-rw-r-- 3 rleigh rleigh   11 May  3 16:15 LK.000.004.064

"lockdev -l /dev/mapper/ravenclaw-home"
-rw-rw-r-- 5 rleigh rleigh   11 May  3 16:18 LCK...16672
-rw-rw-r-- 5 rleigh rleigh   11 May  3 16:18 LCK..mapper:ravenclaw-home
-rw-rw-r-- 5 rleigh rleigh   11 May  3 16:18 LK.b.000.253.004

Since we're writing the PID into the lockfile, what's the
purpose of the "LCK...<pid>" lock?  It's broken if a program takes
out multiple locks (quite possible, if not typical).  Do we have any
active users of this lockfile?

The FHS wants us to use the basename for the lockfile name.  This
really only works for the case of a flat /dev namespace and/or where
there aren't multiple names with the same device number (or symlinks).
Both of these assumptions are invalid once we need to deal with things
like the device mapper or alternative naming schemes (/dev/tts/0 in
place of /dev/ttyS0, since the "0" basename conficts with other names
which could have other device numbers).

Using : as a surrogate path separator mitigates this, but I'm concerned
that this is not useful.  It means you can't use /var/lock/LCK..<device>
without doing some [non-standard] name mangling.  It also still doesn't
allow for symlinks or alternative names which could break locking by
allowing multiple locks for the same device.

For this reason alone, I'm wondering if we shouldn't restrict the
LCK..<devname> to serial devices where we can use ttyname(3) to obtain
the canonical name when creating the lock.  For other devices we can
just use the completely reliable device number.

Since we're creating multiple lock files, could we also add a variant
on LK.<devmajor>.<major>.<minor>. which drops the pointless devmajor?
This just makes it totally reliable in the face of device nodes outside
/dev or on mounts under /dev e.g. /dev/pts where the filesystem is on
a different device (or under /sys).  Doing both keeps backward
compatibility with the SVr4 naming and fixes the buggy behaviour.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/lockdev-devel/attachments/20100503/fcdab9b4/attachment.pgp>


More information about the lockdev-devel mailing list