From owner-freebsd-current@FreeBSD.ORG Wed Jun 16 03:38:28 2004 Return-Path: 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 7AB0416A4CE for ; Wed, 16 Jun 2004 03:38:28 +0000 (GMT) Received: from black3.imgsrc.co.jp (black3.imgsrc.co.jp [210.226.20.147]) by mx1.FreeBSD.org (Postfix) with ESMTP id B3DE643D49 for ; Wed, 16 Jun 2004 03:38:27 +0000 (GMT) (envelope-from kuriyama@imgsrc.co.jp) Received: from localhost (localhost [127.0.0.1]) by black3.imgsrc.co.jp (Postfix) with ESMTP id B361A50B39; Wed, 16 Jun 2004 12:38:22 +0900 (JST) Received: from black3.imgsrc.co.jp (black3.imgsrc.co.jp [IPv6:2001:218:422:2::9999]) by black3.imgsrc.co.jp (Postfix) with ESMTP id 3459A50B2B; Wed, 16 Jun 2004 12:38:19 +0900 (JST) Date: Wed, 16 Jun 2004 12:38:18 +0900 Message-ID: <7moenk9npx.wl@black3.imgsrc.co.jp> From: Jun Kuriyama To: Frode Nordahl In-Reply-To: References: User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386--freebsd) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd 0.1 cc: freebsd-current@freebsd.org cc: Kirk McKusick Subject: Re: UFS snapshot deadlocks X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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: Wed, 16 Jun 2004 03:38:28 -0000 At Fri, 4 Jun 2004 15:06:55 +0000 (UTC), Frode Nordahl wrote: > tty1: > while (1) > ls -la /usr/.snap > end > > tty2: > dump -0af /some/where -C 32 -L /dev/ad0s1f I did diagnose about this. L1. ls(1) issues lstat(2) during walking inside directory. L2. lstat(2) calls namei(). L3. namei() tries to lock VREG /usr/.snap/dump_snapshot after locking VDIR /usr/.snap. D1. dump(8) calls mount(2) via mksnap_ffs(8). D2. mount(2) calls ffs_snapshot(). D3. ffs_snapshot() locks /usr/.snap/dump_snapshot after VOP_CREATE(). D4. ffs_snapshot() searches active but unlinked files from mnt_nvnodelist. D5. when it founds /usr/.snap vnode, tries to lock it. My question is: 1. should ordering of such locks be parent dir vnode first, and file in that dir vnode second? 2. is comparing vnode pointer like this to skip /usr/.snap safe? Index: ffs_snapshot.c =================================================================== RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_snapshot.c,v retrieving revision 1.81 diff -u -r1.81 ffs_snapshot.c --- ffs_snapshot.c 16 Jun 2004 00:26:30 -0000 1.81 +++ ffs_snapshot.c 16 Jun 2004 03:34:44 -0000 @@ -424,6 +424,11 @@ MNT_ILOCK(mp); continue; } + if (xvp == nd.ni_dvp) { + VI_UNLOCK(xvp); + MNT_ILOCK(mp); + continue; + } if (vn_lock(xvp, LK_EXCLUSIVE | LK_INTERLOCK, td) != 0) { MNT_ILOCK(mp); goto loop; I did repeated test like as Frode did, but I cannot see any deadlocks after this patch. -- Jun Kuriyama // IMG SRC, Inc. // FreeBSD Project