Unix questions - NFS locking, remove -vs- local files?

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > September 2006 > NFS locking, remove -vs- local files?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author NFS locking, remove -vs- local files?
Jamie

2006-09-16, 1:43 pm

How are NFS locks "supposed to" work?

I've run this test script, runs fine if both instances are on the
same machine, however, if I run it on two machines with one machine
having the filesystem local, the other having it NFS, both claim to
have a lock.


Here's the setup:

nfs.example.com exports /home

clienta.example.com NFS mounts /home
clientb.example.com NFS mounts /home

If two instances of the below script are run on clienta.example.com, the
lock works. However, if the same instance is run across different hosts,
the lock totally breaks.

(I've tried one machine that exports the data and two NFS client machines)


Are NFS locks still broken?


---------------------------| test script, run to see if two machines can lock a file|-------
use Fcntl qw(:flock);
main(shift());
sub main {
my($fn) = shift();
$fn || die "Usage: $0 filename";
print "Testing locks on $fn\n";
while(1){
print "Press key to lock again\n";
getc();
print "Opening $fn\n";
open(FH,$fn) || die "$fn: $!";
print "Attempting to lock $fn\n";
while(! flock(FH,LOCK_EX)){
print "Failed to lock $fn : $!\n";
}
print "Locked.. Press key to close\n";
getc();
print "Closing: $fn\n";
close(FH);
}
}




--
http://www.geniegate.com Custom web programming
guhzo_42@lnubb.pbz (rot13) User Management Solutions
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com