Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Dec 1995 15:02:51 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        current@freebsd.org
Subject:   Amusing vfs_cache bug
Message-ID:  <199512132202.PAA00508@phaeton.artisoft.com>

next in thread | raw e-mail | index | archive | help

In the process of some stress testing, I discovered an interesting
vcache bug.  It has to do with the first vnode allocated after the
nextvnodeid rolls over and the cache is purged.

As you can imagine, the stress involves more than 4 billion vnode
allocations.  Unlikely to happen unless you are me, or you are
running a news spool.  8-).


The v_id of the vnode after the rollover will be 1, which will match
the v_id of the nchENOENT.v_id (the negative cahe hit entry).

In the case of a rename of that file into a directory where a negative
cache entry had occurred (access/open/etc. failed), the dvp, dvpid,
vpid, v_vid, and the hash and name will match.

But the vnode returned will be the negative hit.  It has to be a rename,
since a create checks for MAKEENTRY and a rename won't unset it.

Kludgy patch follows.  I really wanted to fix this by moving the cache
lookup and entry and providing a purge by dvp function, but don't have
time for that right this second. 8-(.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
==========================================================================
*** vfs_cache.c.org	Wed Dec 13 14:43:29 1995
--- vfs_cache.c	Wed Dec 13 14:44:50 1995
***************
*** 253,258 ****
--- 253,259 ----
  	TAILQ_INIT(&nclruhead);
  	nchashtbl = phashinit(desiredvnodes, M_CACHE, &nchash);
  	nchENOENT.v_id = 1;
+ 	nextvnode = 1;
  }
  
  /*
***************
*** 278,284 ****
  		while(ncpp->lh_first)
  			PURGE(ncpp->lh_first);
  	}
! 	vp->v_id = ++nextvnodeid;
  }
  
  /*
--- 279,285 ----
  		while(ncpp->lh_first)
  			PURGE(ncpp->lh_first);
  	}
! 	vp->v_id = nextvnodeid = 2;
  }
  
  /*
==========================================================================



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