public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* NFS file locking?
@ 2001-10-14 18:11 Larry McVoy
  2001-10-14 23:52 ` Neil Brown
  2001-10-15  1:43 ` Alan Cox
  0 siblings, 2 replies; 5+ messages in thread
From: Larry McVoy @ 2001-10-14 18:11 UTC (permalink / raw)
  To: linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]

Hi, the open(2) man page says:

       O_EXCL When  used with O_CREAT, if the file already exists
              it is an error and the open will fail.   O_EXCL  is
              broken  on NFS file systems, programs which rely on
              it for performing locking tasks will contain a race
              condition.  The solution for performing atomic file
              locking using a lockfile is to create a unique file
              on  the  same  fs (e.g., incorporating hostname and
              pid), use link(2) to make a link to  the  lockfile.
              If  link() returns 0, the lock is successful.  Oth­
              erwise, use stat(2) on the unique file to check  if
              its  link  count  has increased to 2, in which case
              the lock is also successful.

I coded this up and tried it here on a cluster of different operating
systems (Linux 2.4.5 server, linux, freebsd, solaris, aix, hpux, irix
clients) and it doesn't work.

2 questions:

a) is it the belief of folks here that this should work?

b) if performance isn't a big issue, is there any portable way to do
   locking over NFS with just files?


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-17 11:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-14 18:11 NFS file locking? Larry McVoy
2001-10-14 23:52 ` Neil Brown
2001-10-15  2:38   ` Larry McVoy
2001-10-17 11:15     ` Miquel van Smoorenburg
2001-10-15  1:43 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox