From owner-svn-src-head@FreeBSD.ORG Fri Oct 16 19:51:52 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 728CD1065693; Fri, 16 Oct 2009 19:51:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 44D058FC20; Fri, 16 Oct 2009 19:51:52 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id EBA9C46B32; Fri, 16 Oct 2009 15:51:51 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 2A0638A021; Fri, 16 Oct 2009 15:51:51 -0400 (EDT) From: John Baldwin To: src-committers@freebsd.org Date: Fri, 16 Oct 2009 15:51:35 -0400 User-Agent: KMail/1.9.7 References: <200910161930.n9GJUnHD011723@svn.freebsd.org> In-Reply-To: <200910161930.n9GJUnHD011723@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200910161551.35583.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Fri, 16 Oct 2009 15:51:51 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r198174 - head/sys/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2009 19:51:52 -0000 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