All of lore.kernel.org
 help / color / mirror / Atom feed
* Linux' NFS locking b0rken?
@ 2004-05-25 12:23 Jeffrey Layton
  2004-05-25 12:34 ` Olaf Kirch
  0 siblings, 1 reply; 17+ messages in thread
From: Jeffrey Layton @ 2004-05-25 12:23 UTC (permalink / raw)
  To: nfs

I've been doing a little testing of lock handling. My findings seem to
indicate that Linux does not handle NFS locking at all, but I want to
sanity check what I'm doing against the knowledgeable people on this
list.

I wrote a small perl script to do an exclusive lock on a file:

----------------------------------------------
#!/usr/bin/perl
 
use Fcntl qw(:DEFAULT :flock);
 
$file=$ARGV[0];
 
open (FH, "+< $file") or die "Can't open $file: $!\n";
if ( flock(FH, LOCK_EX|LOCK_NB) ) {
    print "Lock acquired! Sleeping for 5 mins...\n";
    sleep 300;
} else {
    print "Unable to acquire lock! Exiting...\n";
    exit 1;
}
 
close FH;
 
exit 0;
-----------------------------------------------

The fileserver is Linux (and I've tried both 2.4 and 2.6 kernels and
seem to get the same result), and for clients, I've tested Solaris 8,
and Linux 2.4 and 2.6. The Linux boxes are Debian machines using 1.0.6
nfs-kernel-server and nfs-common packages.

I then touched a file on the NFS-shared directory and ran this script to
lock it using different clients.

Locking seems to work with 2 Solaris 8 clients. If I run this script
against the same file, then the second one gets the 'Unable to acquire
lock' message.

However, when I try this with 2 Linux clients, or with a Linux and
Solaris client, they both claim to acquire the lock. When I run the test
in 2 terminals on the same Linux client the second one is unable to
acquire the lock, so the problem seems to be in dealing with locks as
registered by the NFS server. 

I've tried several things to work around this problem:

Kernel version does not seem to matter here, at least I see this with
recent versions of both the 2.4 and 2.6 kernel tree, on both clients and
servers.

My mount options for the Linux side are:

nosuid,soft,bg,udp

I've tried other options too, in particular, both NFSv2 and v3, as well
as v3 over TCP. None of that seems to help.

Has anyone successfully been able to get Linux to respect fcntl locking
over NFS? If so, do you have any ideas what I'm doing wrong?

Thanks,
Jeff




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-05-28 13:28 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-25 12:23 Linux' NFS locking b0rken? Jeffrey Layton
2004-05-25 12:34 ` Olaf Kirch
2004-05-25 16:42   ` Jeffrey Layton
2004-05-25 17:47     ` Trond Myklebust
2004-05-25 18:56       ` Dan Stromberg
2004-05-25 19:03         ` Trond Myklebust
2004-05-25 19:08         ` Ara.T.Howard
2004-05-25 19:12           ` Trond Myklebust
2004-05-25 21:09             ` Ara.T.Howard
2004-05-25 22:11               ` Trond Myklebust
2004-05-26  7:50                 ` Olaf Kirch
2004-05-26 16:04                   ` Trond Myklebust
2004-05-27 16:14                     ` Olaf Kirch
2004-05-27 16:24                       ` Jeffrey Layton
2004-05-27 16:31                       ` Trond Myklebust
2004-05-27 17:04                         ` Olaf Kirch
2004-05-28 13:28                         ` Ara.T.Howard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.