From owner-freebsd-hackers Thu Nov 7 14:47:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA24107 for hackers-outgoing; Thu, 7 Nov 1996 14:47:31 -0800 (PST) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id OAA24072 for ; Thu, 7 Nov 1996 14:47:25 -0800 (PST) Received: from root.com (implode.root.com [198.145.90.17]) by who.cdrom.com (8.7.5/8.6.11) with ESMTP id FAA16281 for ; Thu, 7 Nov 1996 05:42:39 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by root.com (8.7.6/8.6.5) with SMTP id FAA03376; Thu, 7 Nov 1996 05:40:59 -0800 (PST) Message-Id: <199611071340.FAA03376@root.com> X-Authentication-Warning: implode.root.com: Host localhost [127.0.0.1] didn't use HELO protocol To: Thomas David Rivers cc: freebsd-hackers@freebsd.org Subject: Re: More info on the daily panics... In-reply-to: Your message of "Thu, 07 Nov 1996 07:54:29 EST." <199611071254.HAA02561@lakes.water.net> From: David Greenman Reply-To: dg@root.com Date: Thu, 07 Nov 1996 05:40:59 -0800 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > Also, if v_usecount went negative - wouldn't that only loose >one, or a few vnodes (assuming it went to -1), as v_usecount >was incremented, wouldn't it return to being positive? Also, >since -1 != 0, would that vnode ever be available to be used again? >I'm just thinking out loud... v_usecount is a mechanism for reference counting in-use vnodes. When it drops to 0, it is considered "currently unused" and is placed on the freelist. It's not _completely_ free, however, as there are still references to it from the namecache. If there is a namecache hit, the vnode can be removed from the freelist and used...so vnodes on the freelist form a second chance cache for vnodes. In order for a vnode to be considered not-stale, a match must also occur with the vnode's generation count which is called v_id (which is stored in the namecache along with the pointer to the vnode). If the generation count comparison fails, then the vnode is considered not in the cache and a completely new one is allocated. A vnode is removed from the freelist whenever a reference is gained to it. There is only one case algorithmically that a vnode can be on the freelist and have a non-zero usecount. This is the case where the usecount was once zero (and thus was inserted onto the freelist), and was then later decremented again - causing it to become negative. Later, when a vnode needs to be reclaimed from the freelist, the system does a consistency check on the vnode and if the usecount is not zero, it panics with "free vnode isn't". One potential hack-fix would be, in vrele(), to decrement the v_usecount only if v_usecount != 0. This would prevent it from ever becoming negative and thus duplicate vrele()s would be eaten. The problem with this is that it covers up a potentially serious problem. One can't determine if the extra vrele() may lose a reference that it shouldn't be losing and thus prematurely insert an in-use vnode onto the freelist. Most of the time this probably won't cause your system to die a horrible death, but it could. ...which is why we have consistency checks in the first place. :-) -DG David Greenman Core-team/Principal Architect, The FreeBSD Project