Messages in this thread | | | From | Glynn Clements <> | Date | Wed, 2 Dec 1998 00:14:45 +0000 (GMT) | Subject | Re: NFS in 2.1.130?? |
| |
Alan Cox wrote:
> > This will not work. No kind of dot-locking will work with an NFS client > > that caches data, which includes Linux 2.0.x and Linux 2.1.x, unless you > > procmail style dot locking works over NFS. NFS has an atomic rename, > even though they screwed everything else up in NFSv2. Rename is the only > real NFS safe operation to use.
I was under the impression that it's link() which is atomic. All of the dot-locking code which I've seen uses link(), and my open(2) manpage 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 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.
-- Glynn Clements <glynn@sensei.co.uk>
- 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/
| |