🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.unix
Article #235

Re: File Locking across NFS mounts

#235
From: John R. Levine
Date: Fri, 11 Sep 1992 20:36
45 lines
2331 bytes
Submitted-by: johnl@iecc.cambridge.ma.us (John R. Levine)

>>Submitted-by: johnl@iecc.cambridge.ma.us (John R. Levine)
>>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...

>Submitted-by: henry@zoo.toronto.edu (Henry Spencer)
>It isn't reliable, however.  The crucial point is that NFS does not provide
>a sufficiently good imitation of Unix filesystem semantics.  I'm told -- I
>have not seen details and don't have a reference -- that if you look hard
>enough at the problem, and consider things like finite cache sizes, you
>can prove that there is *no way* to do reliable locking through the NFS
>protocol.

Yeah.  The problem is that although the NFS calls are all individually
idempotent, they aren't in combination, and there is no way to enforce
exactly-once semantics in NFS.  Here's the classic example:

client					server

creat("foo")          ---------->	truncates "foo"
		      +----------       ack creat
		      | slow network
creat("foo)" retry ---|------+
receive ack       <---+      |
write data		-----|--->      writes data
receive ack             <----|---   	ack write
			     +--->	truncates file again
discard dup response         <---	ack creat

So all of the requests were executed and acked, but the repeated creat()
threw away the data.  Oops.

This apparently was a real problem, according to a paper at Usenix a few
years ago.  Sun has added a request cache and discards any request that is
a duplicate of one in the cache, but you can only keep requests for a few
seconds in a reasonable sized cache, and long-haul networks can easily
have delays longer than that. 

Regards,
John Levine, johnl@iecc.cambridge.ma.us, {spdcc|ima|world}!iecc!johnl


Volume-Number: Volume 29, Number 32
Technical Details
Message-ID: <18r014INN3ec@ftp.UU.NET>
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet!not-for-mail
References: <18omcgINN8tm@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
Subject: Re: File Locking across NFS mounts
Date: 11 Sep 1992 13:36:52 -0700
Organization: I.E.C.C.
Lines: 45
Sender: sef@ftp.UU.NET
Approved: sef@ftp.uucp (Moderator, Sean Eric Fagan)
Message-ID: <18r014INN3ec@ftp.UU.NET>
References: <18omcgINN8tm@ftp.UU.NET>
NNTP-Posting-Host: ftp.uu.net
X-Submissions: std-unix@uunet.uu.net