From owner-freebsd-current@FreeBSD.ORG Mon Jun 12 05:48:47 2006 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0CDAB16A418 for ; Mon, 12 Jun 2006 05:48:47 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7D1243D46 for ; Mon, 12 Jun 2006 05:48:44 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id 66C26170DE; Mon, 12 Jun 2006 05:48:42 +0000 (UTC) To: Kris Kennaway From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 12 Jun 2006 01:41:15 -0400." <20060612054115.GA42379@xor.obsecurity.org> Date: Mon, 12 Jun 2006 05:48:41 +0000 Message-ID: <33721.1150091321@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: current@FreeBSD.org Subject: Re: FILEDESC_LOCK() implementation X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jun 2006 05:48:47 -0000 In message <20060612054115.GA42379@xor.obsecurity.org>, Kris Kennaway writes: >I wonder if something better can be done with the funky home-grown >locking in FILEDESC_LOCK() (see ) to make it more >light-weight? It probably can. What's needed is a combined short/long lock, where you can either grab lock for sleepable locking (like for instance sxlocks) or only grab a quick version (like a mutex) for lightweight operations. See vfs_syscalls.c for examples like: FILEDESC_LOCK(fdp); if (chroot_allow_open_directories == 0 || (chroot_allow_open_directories == 1 && fdp->fd_rdir != rootvnode)) { error = chroot_refuse_vdir_fds(fdp); if (error) { FILEDESC_UNLOCK(fdp); return (error); } } oldvp = fdp->fd_rdir; fdp->fd_rdir = vp; VREF(fdp->fd_rdir); if (!fdp->fd_jdir) { fdp->fd_jdir = vp; VREF(fdp->fd_jdir); } FILEDESC_UNLOCK(fdp); and FILEDESC_LOCK_FAST(fdp); vp = fdp->fd_cdir; fdp->fd_cdir = nd.ni_vp; FILEDESC_UNLOCK_FAST(fdp); respectively -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.