lockf(1) non-serialization

Kris Kennaway kris at obsecurity.org
Tue Oct 4 17:42:08 PDT 2005


On an SMP machine with mpsafevfs=1:

# cat /tmp/l2.sh
mkdir foo
rmdir foo
# while true; do (lockf lock sh /tmp/l2.sh) &
  done
mkdir: foo: File exists
rmdir: foo: No such file or directory
mkdir: foo: File exists
rmdir: foo: No such file or directory
mkdir: foo: File exists
[...]

It looks like lockf(1) is not serializing requests properly, i.e. it's
handing out locks to two processes at once.  I first saw this early
this year, but then it went away for a while.

Kris

P.S. lockf(1) is also very lame in how it acquires locks..this patch
from Christian fixes that so that multiple lockf processes don't all
spin in a thundering herd trying to grab the same lock, but the above
bug appears with or without it (just more efficiently with):

  http://people.freebsd.org/~csjp/lockf.diff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20051004/1eb3c75c/attachment.bin


More information about the freebsd-current mailing list