lockf(1) non-serialization

From: Kris Kennaway <kris_at_obsecurity.org>
Date: Tue, 4 Oct 2005 20:42:06 -0400
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

Received on Tue Oct 04 2005 - 22:42:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:44 UTC