From owner-freebsd-current@FreeBSD.ORG Thu May 8 07:02:16 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E75311065671 for ; Thu, 8 May 2008 07:02:16 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id 7E39D8FC16 for ; Thu, 8 May 2008 07:02:16 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=one; d=codelabs.ru; h=Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender; b=QlKfdsHgmF6uZkSl/TjdiUqra+KyQqDxTj2dMLjxmBdrvs4nAac8UZe+KS6VxtZFzRgqJQuC6Y5zqnNuBsy/ePeBR2/XRsWRsc/VWWoHQAYTQPUWvIPteTuZwk1QGBNRdDRnlGs+NsoNUr5xmuazXMhgzSE+IT/mfHjHo6zRIDk=; Received: from amnesiac.at.no.dns ([144.206.182.200]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1Ju08r-0008Gy-Je; Thu, 08 May 2008 11:02:13 +0400 Date: Thu, 8 May 2008 11:02:23 +0400 From: Eygene Ryabinkin To: pluknet , Josh Carroll Message-ID: References: <1210163153.2043.11.camel@localhost> <8cb6106e0805070800m46101f21sa8298b33e82bbfbd@mail.gmail.com> <1210172870.2043.17.camel@localhost> <8cb6106e0805070841p12d95c2k6e76a5ce5d8b512e@mail.gmail.com> <8cb6106e0805062004r681045b5ge2981ae73e777a49@mail.gmail.com> <1210163153.2043.11.camel@localhost> <8cb6106e0805070800m46101f21sa8298b33e82bbfbd@mail.gmail.com> <1210172870.2043.17.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <8cb6106e0805070841p12d95c2k6e76a5ce5d8b512e@mail.gmail.com> Sender: rea-fbsd@codelabs.ru Cc: freebsd-current@freebsd.org, Coleman Kane Subject: Re: panic mounting ntfs 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, 08 May 2008 07:02:17 -0000 Josh, pluknet, good day. Wed, May 07, 2008 at 07:21:18PM +0400, pluknet wrote: > >In doing some data recovery for my brother-in-law, I tried to mount > >his win2k partition (NTFS), and the box immediately panic'd. > > What about this (maybe not very clean) patch? > It helped me to mount ntfs volume without a panic. > I guess ntfs was not modified after some lockmgr changes in feb/march. Wed, May 07, 2008 at 11:41:43AM -0400, Josh Carroll wrote: > Worked like a charm here. Thanks! I am a bit late, but could you please try the patch from the http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/120483 It was ported from NetBSD and seems like it is a bit more complete than the one proposed by pluknet. I was promised to test this myself, but had no time yet to see if it works well, so can I ask you to do it? I will extensively test it myself when time will permit. Thank you both! > --- ntfs_subr.c.orig 2008-05-07 18:17:01.000000000 +0400 > +++ ntfs_subr.c 2008-05-07 18:11:05.000000000 +0400 > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > #include > > /* #define NTFS_DEBUG 1 */ > @@ -358,7 +359,8 @@ ntfs_ntget(ip) > > mtx_lock(&ip->i_interlock); > ip->i_usecount++; > - lockmgr(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock); > + mtx_unlock(&ip->i_interlock); > + sx_xlock(&ip->i_lock); > > return 0; > } > @@ -405,7 +407,7 @@ ntfs_ntlookup( > VREF(ip->i_devvp); > > /* init lock and lock the newborn ntnode */ > - lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE); > + sx_init(&ip->i_lock, "ntnode"); > mtx_init(&ip->i_interlock, "ntnode interlock", NULL, MTX_DEF); > ntfs_ntget(ip); > > @@ -447,7 +449,8 @@ ntfs_ntput(ip) > #endif > > if (ip->i_usecount > 0) { > - lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock); > + mtx_unlock(&ip->i_interlock); > + sx_xunlock(&ip->i_lock); > return; > } > > @@ -462,9 +465,10 @@ ntfs_ntput(ip) > LIST_REMOVE(vap,va_list); > ntfs_freentvattr(vap); > } > - lockmgr(&ip->i_lock, LK_RELEASE | LK_INTERLOCK, &ip->i_interlock); > + mtx_unlock(&ip->i_interlock); > + sx_xunlock(&ip->i_lock); > mtx_destroy(&ip->i_interlock); > - lockdestroy(&ip->i_lock); > + sx_destroy(&ip->i_lock); > vrele(ip->i_devvp); > FREE(ip, M_NTFSNTNODE); > } > --- ntfs_inode.h.orig 2008-05-07 18:14:59.000000000 +0400 > +++ ntfs_inode.h 2008-05-07 15:10:59.000000000 +0400 > @@ -41,6 +41,8 @@ > #define IN_LOADED 0x8000 /* ntvattrs loaded */ > #define IN_PRELOADED 0x4000 /* loaded from directory entry */ > > +#include > + > struct ntnode { > struct vnode *i_devvp; /* vnode of blk dev we live on */ > struct cdev *i_dev; /* Device associated with the inode. */ > @@ -53,7 +55,7 @@ struct ntnode { > u_int32_t i_flag; > > /* locking */ > - struct lock i_lock; > + struct sx i_lock; > struct mtx i_interlock; > int i_usecount; -- Eygene