[Gluster-devel] posix-locks problem

Vincent Régnard vregnard at tbs-internet.com
Mon Oct 22 14:29:10 UTC 2007


Kevan Benson a écrit :
> Vincent Régnard wrote:
>> Anand Avati a écrit :
>>> Kevan,
>>>  I just submitted a patch to fuse-devel which adds flock() support to 
>>> fuse.
>>> You could either wait for the next fuse release, or install glusterfs's
>>> patched fuse (2.7.0-glfs3) which has that patch included.
>>>
>>> thanks,
>>> avati
>>
>> I run a small application that uses flock on a clustereds FS (glusterfs
>> 1.3.7 with fuse 2.7.0-glfs5), it clearly shows that flock locking is not
>> working in that situation. Are you sure flock trouble has been solved ?
> 
> Works fine for me.  You may want to post your configs in case there's a 
> problem there.
> 
> For testing flock support, I used this perl script that I wrote.  The 
> only arguments are an optional file to lock and the length in seconds to 
> lock it for.  Something like this: ./testlock.pl /mnt/glusterfs/lockfile 10
> 
> If you run this from multiple clients or mutliple connections to the 
> same client, it should be fairly obvious whether locking is working or not.
> 
> #!/usr/bin/perl
> 
> $| = 1;
> use Fcntl ':flock';
> 
> my $file = shift || "./testlockfile";
> my $delay = shift || 10;
> my $hostname = `hostname`;
> chomp($hostname);
> print "testing flock on lockfile $file with $delay second delay on 
> $hostname\n";
> print localtime(time())." :: opening file\n";
> open(my $testfile, '>>', $file) or die("$!\n");
> print localtime(time())." :: opened file\n";
> print localtime(time())." :: locking file\n";
> flock($testfile, LOCK_EX) or die("Error locking :: $!\n");
> print localtime(time())." :: locked file\n";
> print $testfile "$hostname start ".localtime(time())."\n";
> sleep $delay;
> print $testfile "$hostname end ".localtime(time())."\n";
> flock($testfile, LOCK_UN) or die("Error locking :: $!\n");
> print localtime(time())." :: unlocked file\n";
> print localtime(time())." :: closing file\n";
> close($testfile) or die("$!\n");
> print localtime(time())." :: closed file\n";
> exit 0;
> 

Using this latter script reveals that locking is working fine :)). Using
my program properly also works. I was actually removing the lock file
when it was locked by another instance ! So my programm was misbehaving
after that. But the question is "why is it possible to remove a file
when it is locked?". I can imagine the answer is that system call is not
the same. Should'nt glusterfs translator forbid or delay unlink() on a
file when it knows a file is locked ?

-- 
Vincent Régnard
vregnard at tbs-internet.com
TBS-internet.com
027 630 5902






More information about the Gluster-devel mailing list