[Gluster-devel] Problems with flock functionality with fuse-2.7.0-gls3 and tls 450

Harris Landgarten harrisl at lhjonline.com
Fri Aug 10 02:13:03 UTC 2007


I ran the following ruby program named testlock.rb:

#!/usr/bin/ruby

class File
  def File.open_locked(*args)
    File.open(*args) do |f|
      begin
        f.flock(File::LOCK_EX)
        result = yield f
      ensure
        f.flock(File::LOCK_UN)
        return result
      end
    end
  end
end

file = ARGV.shift || "./testlockfile"
delay = ARGV.shift || 10
hostname = `hostname`
hostname.chomp!
puts "opening #{file} and locking"
File.open_locked(file, "w"){ |f| f.puts "test"; puts "#{Time.now} : locking file"; sleep delay.to_i; f.puts "finished" }
puts "#{file} #{hostname} end #{Time.now}"
puts "#{file} #{hostname} unlocked"

When run on the local file system as:

$ ruby ./testlock.rb testfile 60

I ran another instance on the same client and it blocked until the first instance released the LOCK_EX and then completed.

The same test was run on gluster as:

$ ruby ./testlock.rb /mnt/glusterfs/testfile 60

When another instance was started:

$ ruby ./testlock.rb /mnt/glusterfs/test/testfile
opening /mnt/glusterfs/test/testfile and locking
./testlock.rb:6:in `initialize': No such file or directory - /mnt/glusterfs/test/testfile (Errno::ENOENT)
        from ./testlock.rb:6:in `open'
        from ./testlock.rb:6:in `open_locked'
        from ./testlock.rb:24

Glusterfs is reporting the LOCK_EX file as ENOENT when another LOCK_EX is requested instead of blocking.

Harris





More information about the Gluster-devel mailing list