Article View: comp.std.unix
Article #225Re: File Locking across NFS mounts
From: John R. Levine
Date: Wed, 09 Sep 1992 21:18
Date: Wed, 09 Sep 1992 21:18
32 lines
1977 bytes
1977 bytes
Submitted-by: johnl@iecc.cambridge.ma.us (John R. Levine)
>Submitted-by: lebrun@ll.mit.edu ("Steven F. LeBrun")
>I am looking for a method of file locking what works across NFS
>mounted directories and am interested on what methods other
>people are using.
You aren't likely to get very satisfactory results using record locking.
Many versions of the locking daemon don't work at all, and the crash
recovery seems to me to be hopelessly amateurish. I've worked on projects
that tried to use record locking and even after doing six backflips to try
and work around the record locking bugs, at least to get to the point that
we didn't just hang if the locking daemon wasn't working, the results
still were not great.
The time-honored technique of using a directory as a semaphore and using
mkdir() and rmdir() as lock and unlock works fairly well, although it's
rather slow. Using link() and unlink() also works, at least on systems
that use the Unix semantics that you can't link on top of an existing
file.
If you're serious about having the locks work, in the long run you'll get
much better results if you write your own daemon that listens to a TCP/IP
socket and handles reserve and release messages, or maybe even manages the
file itself and accepts requests to atomically update and read from the
file.
Regards,
John Levine, johnl@iecc.cambridge.ma.us, {spdcc|ima|world}!iecc!johnl
Volume-Number: Volume 29, Number 22
Technical Details
Message-ID:
<18lpndINN8ti@ftp.UU.NET>Path:
arc1-ca.pugleaf.net!sparky!uunet!uunet!not-for-mailReferences:
<18j4hdINNdst@ftp.UU.NET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet!not-for-mail From: johnl@iecc.cambridge.ma.us (John R. Levine) Newsgroups: comp.std.unix,comp.unix.programmer Subject: Re: File Locking across NFS mounts Followup-To: comp.unix.programmer Date: 9 Sep 1992 14:18:37 -0700 Organization: I.E.C.C. Lines: 32 Sender: sef@ftp.UU.NET Approved: sef@ftp.uucp (Moderator, Sean Eric Fagan) Message-ID: <18lpndINN8ti@ftp.UU.NET> References: <18j4hdINNdst@ftp.UU.NET> NNTP-Posting-Host: ftp.uu.net X-Submissions: std-unix@uunet.uu.net