Is NFS Locking Reliable?

Andrew Wright ahamiltonwright at mta.ca
Tue Mar 10 06:19:31 PDT 2009




On Tue, 10 Mar 2009, Konrad Heuer wrote:

>
> I'd like to ask for your experiences with NFS locking in larger environments.
>
> Our experiences are not so satisfying. Our NFS servers for user home

This matches my historical experience, especially if you add in
periodically "wedged" and "ignored" lock state.


First, it is useful to realize that locking over NFS has, until
version 4, been done "outside of" NFS itself.  That is, there
are a pair of daemon (usually called statd and lockd) processes
that negotiate the lock outside of the stateless mechanism that
is the NFS data access method up to v3.

My past v3 experience has been that only in the case where you have
exactly the same version of statd and lockd on both sides (on the
client and on the server) is it possible that you _may_ experience
truly reliable locking.  Note that this is only possible with the
same OS at the same revision/patch on both client and server.

NFS v4 is no longer stateless, and manages locks internally, which
I would guess would make things much better, though my experience
on mixed environments under v4 is much more limited.


What version of the NFS protocol are you using?  You can find this
out via /usr/sbin/nfsstat


If you are stuck with a v3 client, my recommendation would be to
turn locking off altogether for that client, as I have found that
this works in general better, as the applications desiring the
lock are then at least aware that the lock won't work, rather than
being "led up the garden path" by a successful return from a call
to lockd that later is not honoured.

If upgrading all to v4 is possible, it is probably worth a try,
and good luck!


Andrew.



More information about the freebsd-questions mailing list