Re: NFS in 2.1.130??

Linus Torvalds (torvalds@transmeta.com)
29 Nov 1998 19:09:06 GMT


In article <Pine.BSI.4.05.9811291120280.4767-100000@leroy.surfsouth.com>,
James Puckett <jpuckett@surfsouth.com> wrote:
>
>In man open(2), O_EXCL is said to be broken under NFS.
>
>From open(2):
> 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 perform-
> ing 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
> and use stat(2) on the unique file to check if its link count has increased to 2.
> Do not use the return value of the link() call.
>
>Is this still the case?? What exactly is broken?

This is still the case.

O_CREAT | O_EXCL is fundamentally broken in NFSv2 - this is not a linux
issue, it's simply how NFS works. There's no way to work around it: NFS v2
is so stateless that you simply cannot do locking with a O_CREAT.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/