Add a new NFS node flag, NREMOVED, which is set when a rmdir has been called on a directory. Check this flag in nfs_lookup and return ENOENT in response to attempts to look up paths within a directory which we removed.
This does nothing to prevent ESTALE responses in the event that a directory is removed by a *different* NFS client, but in the case where we are the only NFS client touching a particular tree it should prevent us tripping over ourselves. In particular, it unbreaks the "cleandir" stage of make buildworld -jN with an NFS-mounted /usr/obj/, wherein multiple rm -r commands race to delete each other's working directories.
NOTES FOR REVIEWERS:
- It may be necessary to add checks for NREMOVED to other vnode operations. I haven't found any way to trigger the aberrant ESTALE behaviour with this patch so I'm assuming everything I'm trying is hitting the nfs_lookup; but I don't know VFS well enough to know if this is something we can rely upon.
- In nfs_rmdir I'm picking up a lock on the nfsnode of the directory being deleted in order to set the NREMOVED flag. I'm not absolutely sure if this is necessary; is there sufficient locking in the VFS layer at this point to protect us?