Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Oct 2009 15:51:35 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        src-committers@freebsd.org
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org
Subject:   Re: svn commit: r198174 - head/sys/nfsclient
Message-ID:  <200910161551.35583.jhb@freebsd.org>
In-Reply-To: <200910161930.n9GJUnHD011723@svn.freebsd.org>
References:  <200910161930.n9GJUnHD011723@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 16 October 2009 3:30:49 pm John Baldwin wrote:
> Author: jhb
> Date: Fri Oct 16 19:30:48 2009
> New Revision: 198174
> URL: http://svn.freebsd.org/changeset/base/198174
> 
> Log:
>   Close a race with caching of -ve name lookups in the NFS client.
>   Specifically, clients only trust -ve cache entries while the directory
>   remains unchanged and discard any -ve cache entries for a directory when
>   they notice that the modification time of a directory entry changes.  The
>   race involves two concurrent lookups as follows:
>   - Thread A does a lookup for file 'foo' which sends a lookup RPC to the
>     server.  The lookup fails and the server replies.
>   - The 'foo' file is created (either by the same client or a different
>     client) updating the modification time on the parent directory of 'foo'.
>   - Thread B does a lookup for a different file 'bar' which updates the
>     cached attributes of the parent directory of 'foo' to reflect the new
>     modification time after 'foo' was created.
>   - Thread A finally resumes execution to parse the reply from the NFS
>     server.  It adds a -ve cache entry and sets the cached value of the
>     directory's modification time that is used for invalidating -ve cached
>     lookups to the new modification time set by thread B.

Slight correction, the file has to be created on a different client since the 
local client would exclusively lock the directory vnode while it created the 
file avoiding this race.  I created the file on a separate client when I 
reproduced this during testing (I used a hack to force a 5 second sleep when 
adding -ve cache entries to let thread B do its lookup and update the mtime 
before thread A tried to add its -ve cache entry to "force" the race).

I have seen this in practice in a couple of cases at work where an ls of a 
directory would show a file that was added, but attempting to open the file 
itself or even ls the individual file would fail with ENOENT.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910161551.35583.jhb>