[Gluster-devel] posix-locks problem

Kevan Benson kbenson at a-1networks.com
Fri Oct 19 17:21:51 UTC 2007


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;

-- 

-Kevan Benson
-A-1 Networks





More information about the Gluster-devel mailing list