From owner-freebsd-questions@FreeBSD.ORG Sun Apr 4 06:39:54 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E8ACE16A4CE for ; Sun, 4 Apr 2004 06:39:53 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9AE9043D39 for ; Sun, 4 Apr 2004 06:39:52 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) i34DdlGQ049752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 4 Apr 2004 14:39:47 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i34DdlcC049751; Sun, 4 Apr 2004 14:39:47 +0100 (BST) (envelope-from matthew) Date: Sun, 4 Apr 2004 14:39:47 +0100 From: Matthew Seaman To: herrier Message-ID: <20040404133947.GA49645@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , herrier , freebsd-questions@freebsd.org References: <003201c41a43$d18e2020$c8bbdc51@ely09> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: <003201c41a43$d18e2020$c8bbdc51@ely09> User-Agent: Mutt/1.5.6i X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk X-Virus-Scanned: clamd / ClamAV version devel-20040323, clamav-milter version 0.70a cc: freebsd-questions@freebsd.org Subject: Re: NFS File Locking & fcntl X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Apr 2004 13:39:54 -0000 --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--