From owner-svn-src-all@FreeBSD.ORG Mon Nov 19 20:55:29 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 50F388DC; Mon, 19 Nov 2012 20:55:29 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2E1728FC08; Mon, 19 Nov 2012 20:55:27 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id go10so2408878lbb.13 for ; Mon, 19 Nov 2012 12:55:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=MPfODKjIuUnBOiG8joOUyrcV6DZh79pQHtxFarqO+YM=; b=bU6ccUiSrMB0C2mcqFYAYm3Y0z+KkE0V32BoPcPEvd6vB0K2RBPj2vGbeqkDi7dpU1 mKc0K9qNK1P39s7501HioSXckeavvGH6g1ILyBcAMRXyINCnkyKKCGxWiCAXMyzx3Y2z 8V8pD7JnMwgygjA+qT1jkYZ6K/hyHxxljASISKsIsT5RIRmR5KVJIfQ86wD4mBYgYUFW iHTvnr1m0mtYiR7TXtxEGuZKd62fZkp20osS/tLQ+BAZxtPOg1tGLSOV+9RvzFo3njUS Tj2mhC3GUlOVYEbDa3LdJ2iugODp/8tlRNCKNlTMECcBeh95KiPhyhnY1l9BLUxcEWEN Qr1A== MIME-Version: 1.0 Received: by 10.112.98.37 with SMTP id ef5mr5654949lbb.84.1353358526574; Mon, 19 Nov 2012 12:55:26 -0800 (PST) Sender: asmrookie@gmail.com Received: by 10.112.134.5 with HTTP; Mon, 19 Nov 2012 12:55:26 -0800 (PST) In-Reply-To: References: <201211192043.qAJKhJ9i038016@svn.freebsd.org> Date: Mon, 19 Nov 2012 20:55:26 +0000 X-Google-Sender-Auth: Ji_sQmmbQe6pB8AteK4S5o0iZnE Message-ID: Subject: Re: svn commit: r243307 - head/sys/kern From: Attilio Rao To: Davide Italiano Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: attilio@FreeBSD.org List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 20:55:29 -0000 On Mon, Nov 19, 2012 at 8:53 PM, Davide Italiano wrote: > On Mon, Nov 19, 2012 at 9:43 PM, Attilio Rao wrote: >> Author: attilio >> Date: Mon Nov 19 20:43:19 2012 >> New Revision: 243307 >> URL: http://svnweb.freebsd.org/changeset/base/243307 >> >> Log: >> insmntque() is always called with the lock held in exclusive mode, >> then: >> - assume the lock is held in exclusive mode and remove a moot check >> about the lock acquisition. >> - in the destructor remove !MPSAFE specific chunk. >> >> Reviewed by: kib >> MFC after: 2 weeks >> >> Modified: >> head/sys/kern/vfs_subr.c >> >> Modified: head/sys/kern/vfs_subr.c >> ============================================================================== >> --- head/sys/kern/vfs_subr.c Mon Nov 19 19:31:55 2012 (r243306) >> +++ head/sys/kern/vfs_subr.c Mon Nov 19 20:43:19 2012 (r243307) >> @@ -1111,10 +1111,6 @@ insmntque_stddtr(struct vnode *vp, void >> >> vp->v_data = NULL; >> vp->v_op = &dead_vnodeops; >> - /* XXX non mp-safe fs may still call insmntque with vnode >> - unlocked */ >> - if (!VOP_ISLOCKED(vp)) >> - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); >> vgone(vp); >> vput(vp); >> } >> @@ -1126,7 +1122,6 @@ int >> insmntque1(struct vnode *vp, struct mount *mp, >> void (*dtr)(struct vnode *, void *), void *dtr_arg) >> { >> - int locked; >> >> KASSERT(vp->v_mount == NULL, >> ("insmntque: vnode already on per mount vnode list")); >> @@ -1144,18 +1139,15 @@ insmntque1(struct vnode *vp, struct moun >> */ >> MNT_ILOCK(mp); >> VI_LOCK(vp); >> - if ((mp->mnt_kern_flag & MNTK_NOINSMNTQ) != 0 && >> + if (((mp->mnt_kern_flag & MNTK_NOINSMNTQ) != 0 && >> ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0 || >> - mp->mnt_nvnodelistsize == 0)) { >> - locked = VOP_ISLOCKED(vp); >> - if (!locked || (locked == LK_EXCLUSIVE && >> - (vp->v_vflag & VV_FORCEINSMQ) == 0)) { >> - VI_UNLOCK(vp); >> - MNT_IUNLOCK(mp); >> - if (dtr != NULL) >> - dtr(vp, dtr_arg); >> - return (EBUSY); >> - } >> + mp->mnt_nvnodelistsize == 0)) && >> + (vp->v_vflag & VV_FORCEINSMQ) == 0) { >> + VI_UNLOCK(vp);s >> + MNT_IUNLOCK(mp); >> + if (dtr != NULL) >> + dtr(vp, dtr_arg); >> + return (EBUSY); >> } >> vp->v_mount = mp; >> MNT_REF(mp); > > Thanks for doing this. > Attilio, I don't know if this really could help, but what do you think > about adding an assertion to check if the vnode is locked? > This could help in some cases, e.g. it might be useful to discover the > violation of this assumption for a developer which wants to port a new > fs into the source tree. Exactly where? insmntque1() already has this. Attilio -- Peace can only be achieved by understanding - A. Einstein