open() and ESTALE error

Terry Lambert tlambert2 at mindspring.com
Thu Jun 19 22:24:58 PDT 2003


Andrey Alekseyev wrote:
> I've been trying lately to develop a solution for the problem with
> open() that manifests itself in ESTALE error in the following situation:
> 
> 1. NFS server: echo "1111" > file01
> 2. NFS client: cat file01
> 3. NFS server: echo "2222" > file02 && mv file02 file01
> 4. NFS client: cat file01 (either old file01 contents or ESTALE)
> 
> My study shows that actually the problem appears to be in VOP_ACCESS()
> which is called from vn_open(). If nfs_access() decides to "go to the wire"
> in #4, it then uses a cached file handle which is indeed stale. Thus,
> open() eventually fails with ESTALE too (ESTALE comes from underlying
> nfs_request()).

The real problem here is that you know you did an operation
on the file which would break the name/nfsnode relationship,
but did not flush the cached name and nfsnode data.

A more correct solution would resync the nfsnode.

The main problem with your solution is that it doesn't work
in the case that you don't know the name of the remote file
(in which case, all you really have is a stale file handle,
with no way to unstale it).

I think this is a corner case that's probably not really
very interesting to solve.  Now if you remembered the rename,
and applied your knowledge of the rename semantics to the
problem, you could replace the handle in the local nfsnode
for the file.  This would not be as expensive as traversing
all of the nfsnodes, since you could use the same hash that's
used to translate a fh to a vp to get the vp.

This would fix a lot more cases than the single failure you
are fixing.

In general, though, you can't fix *any* of the cases without
introducing a vnode alias for an nfsnode that may have a local
alias already: there's no way to handle the hash collision in
that case, nor would you want to, since there's no way to deal
with the different vnodes that point to the different nfsnodes,
and have their own vmobject_t's: no matter how you look at it,
you can replace the vnode address in the open file(s) that
point to it, so you have to ESTALE.

-- Terry


More information about the freebsd-hackers mailing list