From: Larry McVoy <lm@bitmover.com>
To: linux-kernel@vger.kernel.org
Subject: NFS file locking?
Date: Sun, 14 Oct 2001 11:11:04 -0700 [thread overview]
Message-ID: <200110141811.f9EIB4823631@work.bitmover.com> (raw)
[-- 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?
next reply other threads:[~2001-10-14 18:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-14 18:11 Larry McVoy [this message]
2001-10-14 23:52 ` NFS file locking? Neil Brown
2001-10-15 2:38 ` Larry McVoy
2001-10-17 11:15 ` Miquel van Smoorenburg
2001-10-15 1:43 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200110141811.f9EIB4823631@work.bitmover.com \
--to=lm@bitmover.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox