]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
More gracefully handle stale file handles and attributes when opening a
authorJohn Baldwin <jhb@FreeBSD.org>
Thu, 27 May 2010 18:07:20 +0000 (18:07 +0000)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 27 May 2010 18:07:20 +0000 (18:07 +0000)
commitb367632ec210dfa1299497abf89c8a24634409a7
tree137d460c6cb6c42aa09e95a90b33d2325e39fae3
parent1e4bf1e35f52e6302300e9552de38519a916517a
More gracefully handle stale file handles and attributes when opening a
file via NFS.  Specifically, to satisfy close-to-open-consistency, the NFS
client always performs at least one RPC on a file during an open(2) to see
if the file has changed.  Normally this RPC is an ACCESS or GETATTR RPC
that is forced by flushing a file's attribute cache during nfs_open() and
then requesting new attributes.  However, if the file is noticed to be
stale during nfs_open(), the only recourse is to fail the open(2) call
with ESTALE.  On the other hand, if the ACCESS or GETATTR RPC is sent
during nfs_lookup(), then the NFS client can fall back to a LOOKUP RPC to
obtain the new file handle in the case that a file has been replaced.

This change causes the NFS client to flush the attribute cache during
nfs_lookup() when validating a name cache hit if the attributes fetched
during nfs_lookup() can be reused in nfs_open().  This allows the client
to open a replaced file via the new file handle the first time that it
notices a replaced file rather than failing with ESTALE in some cases.

Reviewed by: rmacklem, bde
Reviewed by: mohans (older version)
MFC after: 1 week
sys/nfsclient/nfs_vnops.c