From owner-svn-src-head@FreeBSD.ORG Mon Mar 5 17:44:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7F3F41065670; Mon, 5 Mar 2012 17:44:57 +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 3D6908FC1B; Mon, 5 Mar 2012 17:44:57 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id E667446B0C; Mon, 5 Mar 2012 12:44:56 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 49848B924; Mon, 5 Mar 2012 12:44:56 -0500 (EST) From: John Baldwin To: Peter Holm Date: Mon, 5 Mar 2012 12:38:57 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) References: <201203021153.06614.jhb@freebsd.org> <1978600220.298005.1330754492306.JavaMail.root@erie.cs.uoguelph.ca> <20120303163843.GA72020@x2.osted.lan> In-Reply-To: <20120303163843.GA72020@x2.osted.lan> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201203051238.57501.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 05 Mar 2012 12:44:56 -0500 (EST) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Rick Macklem , src-committers@freebsd.org Subject: Re: svn commit: r226967 - head/sys/ufs/ufs 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: Mon, 05 Mar 2012 17:44:57 -0000 On Saturday, March 03, 2012 11:38:43 am Peter Holm wrote: > On Sat, Mar 03, 2012 at 01:01:32AM -0500, Rick Macklem wrote: > > John Baldwin wrote: > > > On Friday, March 02, 2012 8:29:21 am Peter Holm wrote: > > > > On Thu, Mar 01, 2012 at 04:47:41PM -0500, John Baldwin wrote: > > > > > On Monday, October 31, 2011 11:01:47 am Peter Holm wrote: > > > > > > Author: pho > > > > > > Date: Mon Oct 31 15:01:47 2011 > > > > > > New Revision: 226967 > > > > > > URL: http://svn.freebsd.org/changeset/base/226967 > > > > > > > > > > > > Log: > > > > > > The kern_renameat() looks up the fvp using the DELETE flag, > > > > > > which causes > > > > > > the removal of the name cache entry for fvp. > > > > > > > > > > > > Reported by: Anton Yuzhaninov > > > > > > In collaboration with: kib > > > > > > MFC after: 1 week > > > > > > > > > > > > Modified: > > > > > > head/sys/ufs/ufs/ufs_vnops.c > > > > > > > > > > So I ran into this at work recently, and even this fix applied I > > > > > was still > > > > > seeing rename()'s that were seemingly not taking effect. After > > > > > getting some > > > > > extra KTR traces, I figured out that the same purge needs to be > > > > > applied to the > > > > > destination vnode. Specifically, the issue I ran into was that was > > > > > renaming > > > > > 'foo' to 'bar', but lookups for 'bar' were still returning the old > > > > > file. The > > > > > reason was that a lookup after the namei(RENAME) of the > > > > > destination while > > > > > ufs_rename() had its locks dropped was readding the name cache > > > > > entry for > > > > > 'bar', and then a cache_lookup() of 'bar' would return the old > > > > > vnode as long > > > > > as that vnode was valid (e.g. if it had a link in another > > > > > location, or other > > > > > processes had an open file descriptor for it). I'm currently > > > > > testing the > > > > > patch below: > > > > > > > > > > > > > I now have a scenario that fails, but not quite the same way you > > > > describe. > > > > > > > > It looks like this: > > > > > > > > touch file1 > > > > echo xxx > file2 > > > > rename(file1, file2) > > > > > > > > A different process performs stat() on both files in a tight loop. > > > > > > > > Once in a while I observe that a stat() of file2, after the rename, > > > > returns a link count of zero. Size is zero as expected, but the > > > > inode > > > > number of file2 is unchanged. > > > > > Peter, were you doing a stat() using the file name, or an fstat()? > > (Using stat() with afile name might explain it, maybe??) > > > > Yes. Switching to open()/fstat() of the "from" file in the loop, makes > the cache problem go away. Using fstat avoids the changes of getting a stale name cache, so it just avoids the race altogether. However, there is no reason I can think of why stat() should ever give you can inconsistent view of attributes. You should always get a consistent snapshot of attributes. -- John Baldwin