[RndTbl] NFSv4 locking problem

Trevor Cordes trevor at tecnopolis.ca
Fri Mar 30 08:14:51 CDT 2012


A recent update (kernel, or something else) seems to have messed up file 
locking over NFSv4 on my system (yes, v4 allows for locking).

I use locking in perl scripts over NFS and it's always worked until now.  
I checked and lockd is running on the server still.

A test case is at the bottom of this email.  The problem hits on line 13 
where the open-for-write happens.  It dies with "Input/output error".

The client's /v/l/messages says:
[156474.509107] nfs4_reclaim_open_state: Lock reclaim failed!

If I run this on a local file, not over NFS, it works fine.

I'm using the lock functions as the sample code in the perl docs 
instructs.  My goal is to lock a file, read it, do things, and write it 
out, all atomically.  Mostly I want to protect against another instance of 
the same program doing the same thing at the same time and screwing up the 
file.

My NFS server is a an older linux (Fedora 14) than the client (Fedora 16), 
but the NFSv4 spec hasn't really changed in that span.

#!/usr/bin/perl -w
#
use Fcntl ':flock';

$file='/data/Tmp/locktest';

open(LOCK,$file) or die;
flock(LOCK,LOCK_EX);

open(IN,$file) or die;
# read from file
close(IN);

open(ORI,">$file") or die $!;	# dies here!!!!!!!!!!!!1
# write to file
close(ORI);

flock(LOCK,LOCK_UN);


More information about the Roundtable mailing list