From owner-freebsd-current Fri May 2 05:01:55 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA27261 for current-outgoing; Fri, 2 May 1997 05:01:55 -0700 (PDT) Received: from critter.dk.tfs.com (phk.cybercity.dk [195.8.129.17]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA27253; Fri, 2 May 1997 05:01:49 -0700 (PDT) Received: from critter (localhost [127.0.0.1]) by critter.dk.tfs.com (8.8.5/8.8.5) with ESMTP id OAA00222; Fri, 2 May 1997 14:00:39 +0200 (CEST) To: Peter Dufault cc: phk@dk.tfs.com (Poul-Henning Kamp), current@freebsd.org From: Poul-Henning Kamp Subject: Re: vnode->v_usage In-reply-to: Your message of "Fri, 02 May 1997 07:24:54 EDT." <199705021124.HAA27754@hda.hda.com> Date: Fri, 02 May 1997 14:00:39 +0200 Message-ID: <220.862574439@critter> Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In message <199705021124.HAA27754@hda.hda.com>, Peter Dufault writes: >The first unlock won't work since a second thread can come in and >decide to do the same move. Obviously you have a lock ordering issue >with the nested lock and you have to define the ordering. see below for my solution. >Moving items between two lists should be atomic - it is common >and lends itself to clean implementation. It's actually the same list in this case... >Aside: how about making the queues truly opaque while you're doing this? >Then you have a single place to enable locking hierarchy violation detection, >*CAS types of implementations, etc. I don't think that would be very easy. On the other hand, there are very few pieces of code manipulating the vnode free list, do it's hardly worth the effort. Or did I misunderstand you ? Poul-Henning void vtouch(vp) struct vnode *vp; { simple_lock(&vp->v_interlock); if (vp->v_usecount) { simple_unlock(&vp->v_interlock); return; } if (simple_lock_try(&vnode_free_list_slock)) { TAILQ_REMOVE(&vnode_free_list, vp, v_freelist); TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); simple_unlock(&vnode_free_list_slock); } simple_unlock(&vp->v_interlock); } -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@tfs.com TRW Financial Systems, Inc. Power and ignorance is a disgusting cocktail.