From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 27 16:10:13 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 979C316A427 for ; Mon, 27 Feb 2006 16:10:13 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0045943D4C for ; Mon, 27 Feb 2006 16:10:11 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k1RGABLp078690 for ; Mon, 27 Feb 2006 16:10:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k1RGABTD078689; Mon, 27 Feb 2006 16:10:11 GMT (envelope-from gnats) Resent-Date: Mon, 27 Feb 2006 16:10:11 GMT Resent-Message-Id: <200602271610.k1RGABTD078689@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kostik Belousov Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E776B16A423 for ; Mon, 27 Feb 2006 16:09:23 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8D44843D46 for ; Mon, 27 Feb 2006 16:09:23 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k1RG9NwD087706 for ; Mon, 27 Feb 2006 16:09:23 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k1RG9NAS087705; Mon, 27 Feb 2006 16:09:23 GMT (envelope-from nobody) Message-Id: <200602271609.k1RG9NAS087705@www.freebsd.org> Date: Mon, 27 Feb 2006 16:09:23 GMT From: Kostik Belousov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: kern/93905: [possible patch] fdescfs vop_lookup and parent vnode locking X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2006 16:10:13 -0000 >Number: 93905 >Category: kern >Synopsis: [possible patch] fdescfs vop_lookup and parent vnode locking >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Feb 27 16:10:11 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Kostik Belousov >Release: 6-STABLE >Organization: - >Environment: FreeBSD deviant.kiev.zoral.com.ua 6.1-PRERELEASE FreeBSD 6.1-PRERELEASE #3: Mon Feb 20 13:48:25 EET 2006 root@deviant.kiev.zoral.com.ua:/usr/obj/usr/src/sys/DEVIANT i386 >Description: > Is it correct that filesystem-specific vop_lookup is expected to > take the directory vnode (dvp) locked, and shall return with dvp locked ? > vnode_if.src specifies this behaviour as dependent on the flags in the cnp > arguments. My reading of the sources suggest that the statement in the first > sentence is true, and note from vnode_if.src applies to > sys/kern/vfs_lookup.c:lookup() procedure itself. > > If it is true, the fdescfs break this rule, dropping the lock on the dvp. See > sys/fs/fdescfs/fdesc_vnops.c, line 196. As result, having fdescfs mounted, > most accesses to files on it cause warning from the lockmgr, > lockmgr: thread XXX unlocking unheld lock > I did testing with the attached patch > and do not see the warnings anymore. The system does not deadlock. >How-To-Repeat: mount the fdescfs on /dev/fd and do find /dev/fd on the kernel compiled with INVARIANTS >Fix: Index: sys/fs/fdescfs/fdesc_vnops.c =================================================================== RCS file: /usr/local/arch/ncvs/src/sys/fs/fdescfs/fdesc_vnops.c,v retrieving revision 1.100 diff -u -r1.100 fdesc_vnops.c --- sys/fs/fdescfs/fdesc_vnops.c 10 Aug 2005 07:08:14 -0000 1.100 +++ sys/fs/fdescfs/fdesc_vnops.c 3 Feb 2006 14:35:11 -0000 @@ -193,11 +193,9 @@ goto bad; } - VOP_UNLOCK(dvp, 0, td); if (cnp->cn_namelen == 1 && *pname == '.') { *vpp = dvp; VREF(dvp); - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); return (0); } @@ -228,12 +226,12 @@ if (error) goto bad; VTOFDESC(fvp)->fd_fd = fd; - vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, td); + if (fvp != dvp) + vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = fvp; return (0); bad: - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td); *vpp = NULL; return (error); } >Release-Note: >Audit-Trail: >Unformatted: