Re: flock gives EIO on NFSv4, works on NFSv3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2011-01-04 at 15:49 -0800, Simon Kirby wrote: 
> Hello,
> 
> In testing NFSv4, I found that this lock test script fails with EIO:
> 
> #!/usr/bin/perl
> 
> $|=1;
> use Fcntl qw(:DEFAULT :flock);
> open(IN, "< locktest.pl") or die "open: $!";
> print "Locking...\n";
> flock(IN,LOCK_EX) or die "flock $filename: $!";
> print "Locked.\n";
> sleep(4);
> print "Unlocking...\n";
> close(IN);
> exit(0);
> 
> This just locks itself (assuming it's called locktest.pl).  This works
> fine over NFSv3, but with NFSv4, I'm seeing:
> 
> flock(3, LOCK_EX)                       = -1 EIO (Input/output error)
> 
> tcpdump and NFS debugging shows status "10038", which as far as I can
> tell is "NFS4ERR_OPENMODE".

That is known and expected behaviour. We have to map flock() onto byte
range locks (i.e. POSIX locks), and since LOCK_EX has to map to a write
lock in order to give exclusive semantics, the server will not allow it
when you only have the file open for reading.

Cheers
   Trond
-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@xxxxxxxxxx
www.netapp.com

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux