From owner-freebsd-current@FreeBSD.ORG Thu Nov 20 22:02:31 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BBAA1065672 for ; Thu, 20 Nov 2008 22:02:31 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from gv-out-0910.google.com (gv-out-0910.google.com [216.239.58.189]) by mx1.freebsd.org (Postfix) with ESMTP id BC7958FC17 for ; Thu, 20 Nov 2008 22:02:30 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by gv-out-0910.google.com with SMTP id n8so205388gve.39 for ; Thu, 20 Nov 2008 14:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=jUgQPCMYDOC++KEgV++hjtz2sAjlbQ6FQgaCdqO3VTA=; b=wAtAIsG2hS3ASN2mZadrWE7WxhV2gtl7TVngT5fiySTvSUNKLgd8lrciiY8PMxEX03 M58xUSVGL/e1dYEFKYWHCnyNFWstqoASrYchAwWW9GQLLcRzJ7IfhiEid7bBRzPFmMMn yKVuB1+IVg8puj5K44f5ZYaMroxmJIZHAUog8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=fqltkbBa96vzq3GO6a4IKKw+FTFFYG0xsqKUafpfvfZojOj85SZQrpZvocG1/COCWT 4SqUHDVg7Yt0Bd78SOaerCtD7vqfxIBxn3z7R9SwfexmgeklhvBCwGwFcKHZ7oyuw8/b vFqftsZ5bOnRZ0gokp+thBvNoC3JZW/tXcKMo= Received: by 10.103.192.10 with SMTP id u10mr951049mup.101.1227218549175; Thu, 20 Nov 2008 14:02:29 -0800 (PST) Received: by 10.103.239.14 with HTTP; Thu, 20 Nov 2008 14:02:29 -0800 (PST) Message-ID: <3bbf2fe10811201402x4eb6fa70i398bfb1402792fef@mail.gmail.com> Date: Thu, 20 Nov 2008 23:02:29 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "John Baldwin" In-Reply-To: <200811201627.58289.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200811201627.58289.jhb@freebsd.org> X-Google-Sender-Auth: 360e1bfc0ecda57b Cc: scottl@freebsd.org, current@freebsd.org Subject: Re: [PATCH] Make udf(4) MPSAFE and use shared lookups 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: Thu, 20 Nov 2008 22:02:31 -0000 2008/11/20, John Baldwin : > So this patch is fairly minimal since udf(4) is currently read-only. The > changes include: > > * Set VV_ROOT in udf_vget() if we ever return a vnode instead of doing it only > in udf_root(). This matches the behavior of other operating systems and > correctly tags the root vnode with VV_ROOT in the unlikely case that we > create the vnode during a call to ufs_vget() that does not come from > ufs_root(). > * If the hash lookup in ufs_vget() fails, ensure an exclusive vnode lock is > used while creating the new vnode (same as UFS). > * Allow lock recursion (XXX: not really sure this is needed actually). > * Allow shared vnode locks on non-fifos. > * Honor the requested locking flags (shared vs exclusive) instead of always > using exclusive vnode locks during a lookup operation. > * Handle "." lookups the same way other filesystems do by just bumping the > reference on 'dvp' rather than calling udf_vget(). > > http://www.FreeBSD.org/~jhb/patches/udf_mpsafe.patch @@ -589,6 +582,22 @@ if (error || *vpp != NULL) return (error); + /* + * We must promote to an exclusive lock for vnode creation. This + * can happen if lookup is passed LOCKSHARED. + */ + if ((flags & LK_TYPE_MASK) == LK_SHARED) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } + On -CURRENT, operations are bitwise (differently from 7.x and such). What you want to do is just: flag = (flag & ~LK_SHARED) | LK_EXCLUSIVE; The other parts look good (except that IIRC stlye wants all multi-line comments to be preceeded by a white, empty line). Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein