From owner-freebsd-hackers Thu Nov 11 14:55:38 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from dt054n7c.san.rr.com (dt054n7c.san.rr.com [24.30.152.124]) by hub.freebsd.org (Postfix) with ESMTP id 96E1914F3E for ; Thu, 11 Nov 1999 14:55:34 -0800 (PST) (envelope-from Doug@gorean.org) Received: from gateway.gorean.org (gateway.gorean.org [10.0.0.1]) by dt054n7c.san.rr.com (8.9.3/8.8.8) with ESMTP id OAA37978 for ; Thu, 11 Nov 1999 14:55:31 -0800 (PST) (envelope-from Doug@gorean.org) Date: Thu, 11 Nov 1999 14:55:01 -0800 (PST) From: Doug Barton X-Sender: doug@dt054n7c.san.rr.com To: freebsd-hackers@freebsd.org Subject: Serious locking problem over NFS Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Greetings, The following small program illustrates an obscure problem with file locking with freebsd as an NFS client. I'm aware of the problems with NFS client side locking, but this is a slightly different problem. If you compile this program, then place it on the NFS server machine and access it twice from the same NFS client, it does what you'd expect, namely the second process hangs till the first releases the lock. However if you run this program from two different FreeBSD NFS clients, both clients get a lock, which is bad. This is true whether all 3 machines are freebsd, or if two clients are freebsd and the server is sun (which is how our machines are set up in reality). However, if two sun clients run the binary located on a sun server, it works as expected, namely the second one hangs till the first one releases the lock. Any insights into this situation are welcome, including suggestions on different ways to do the locking that will work over freebsd. Of course, if there is a bug in our NFS code fixing that would be a good thing too. I'm a bit behind on my FreeBSD mail, so my apologies if this has come up recently. Thanks in advance for any help or suggestions. Doug -- "Stop it, I'm gettin' misty." - Mel Gibson as Porter, "Payback" #include #include #include int main( int argc, char *argv[] ) { int fd; struct flock fl; fd = open( "test.lck", O_CREAT | O_TRUNC | O_WRONLY, 0644 ); fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; fcntl( fd, F_SETLKW, &fl ); printf( "Got lock\n" ); sleep( 30 ); fl.l_type = F_UNLCK; fcntl( fd, F_SETLKW, &fl ); close( fd ); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message