Date: Thu, 11 Nov 1999 14:55:01 -0800 (PST) From: Doug Barton <Doug@gorean.org> To: freebsd-hackers@freebsd.org Subject: Serious locking problem over NFS Message-ID: <Pine.BSF.4.20.9911111429310.37830-100000@dt054n7c.san.rr.com>
next in thread | raw e-mail | index | archive | help
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 <unistd.h> #include <fcntl.h> #include <sys/time.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.20.9911111429310.37830-100000>