Date: Sun, 4 Apr 2004 14:39:47 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: herrier <herrier@herrier.com> Cc: freebsd-questions@freebsd.org Subject: Re: NFS File Locking & fcntl Message-ID: <20040404133947.GA49645@happy-idiot-talk.infracaninophile.co.uk> In-Reply-To: <003201c41a43$d18e2020$c8bbdc51@ely09> References: <003201c41a43$d18e2020$c8bbdc51@ely09>
next in thread | previous in thread | raw e-mail | index | archive | help
--huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 04, 2004 at 02:53:24PM +0200, herrier wrote: > Hello, >=20 > First of all I a very happy using FreeBSD and I have a question regarding= Locking of files over NFS. >=20 > Here is my configuration: >=20 > I have an apache server running with FreeBSD 4.8 Stable (server 1) > I have a NFS server where I put all my website files running FreeBSD 4.8= Stable. (server 2) >=20 > Both server are linked using Ethernet cards. >=20 > rpc.lockd is not activated: neither on server 1 nor on server 2 Which means that there's no chance of file locking happening. =20 > On server 1, I have concurrent CGI processes accessing files on server 2 = using the locking api: >=20 > fcntl(m_hdlFile,F_SETLKW, &objLock); >=20 > to lock part of the accessed files. >=20 > Question: Despite lockd is missing, does this invokation works well i.e d= o we have the expected locking behavior ? Afraid not. FreeBSD 4.9 doesn't provide the client side functionality for locking over NFS -- as the rpc.lockd(8) man page says: The current implementation provides only the server side of the protoc= ol (ie. clients running other OS types can establish locks on a FreeBSD fileserver, but there is currently no means for a FreeBSD client to establish locks). In fact, what happens with FreeBSD clients is that the kernel lies to the process requesting the lock, and just anyswers "yes, lock achieved" to every request. You should take care that your CGI doesn't depend critically on being able to achieve an exclusive lock on a file shared over a network, especially if that file is going to be accessed from several machines. You can use the technique of 'dot locking' (as often used by mail delivery agents) where the process accessing the file creates a lock file to signal that it is accessing the shared resource, and removes the lock file when it's done. So long as everything that accesses the shared resource can be rewritten to abide by this protocol, then it should work pretty well. This is not a problem with 5.x -- the full functionality of rpc.lockd is supported. Cheers, Matthew=09 --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --huq684BweRXVnRxX Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAcBAjdtESqEQa7a0RAkpqAJ4ing/GP+HC5vLxdx6xzQb0cI4YrQCcDq5a zdvvpvlduhg9XhOXP8FcdRI= =Pzdg -----END PGP SIGNATURE----- --huq684BweRXVnRxX--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040404133947.GA49645>