From owner-freebsd-current@FreeBSD.ORG Wed Jun 16 04:34:48 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 3399616A4CE for ; Wed, 16 Jun 2004 04:34:48 +0000 (GMT) Received: from beastie.mckusick.com (dsl081-247-227.sfo1.dsl.speakeasy.net [64.81.247.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id C630743D45 for ; Wed, 16 Jun 2004 04:34:47 +0000 (GMT) (envelope-from mckusick@mckusick.com) Received: from beastie.mckusick.com (localhost [127.0.0.1]) by beastie.mckusick.com (8.12.8/8.12.9) with ESMTP id i5G4YgDa034545; Tue, 15 Jun 2004 21:34:42 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Message-Id: <200406160434.i5G4YgDa034545@beastie.mckusick.com> To: Jun Kuriyama In-Reply-To: Your message of "Wed, 16 Jun 2004 12:38:18 +0900." <7moenk9npx.wl@black3.imgsrc.co.jp> Date: Tue, 15 Jun 2004 21:34:42 -0700 From: Kirk McKusick X-Mailman-Approved-At: Wed, 16 Jun 2004 11:49:41 +0000 cc: Ian Dowse cc: freebsd-current@freebsd.org cc: Frode Nordahl 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 04:34:48 -0000 Good sleuthing job. You have correctly analyzed the problem and your fix is correct. You have my blessing to check it in. And thanks for taking the time to figure this out when I did not have the time to do so. Kirk McKusick =-=-=-=-=-= Date: Wed, 16 Jun 2004 12:38:18 +0900 From: Jun Kuriyama To: Frode Nordahl Cc: Kirk McKusick , freebsd-current@freebsd.org Subject: Re: UFS snapshot deadlocks X-ASK-Info: Whitelist match 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