Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 May 2008 11:02:23 +0400
From:      Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To:        pluknet <pluknet@gmail.com>, Josh Carroll <josh.carroll@gmail.com>
Cc:        freebsd-current@freebsd.org, Coleman Kane <cokane@freebsd.org>
Subject:   Re: panic mounting ntfs
Message-ID:  <TfxE9AYpsGcM2odJJk%2B2PzF/RR4@tuQFyl9pqXYkbrygWcrojXcyvbA>
In-Reply-To: <8cb6106e0805070841p12d95c2k6e76a5ce5d8b512e@mail.gmail.com> <a31046fc0805070821i742a0065i9f938e9964bb144e@mail.gmail.com>
References:  <1210163153.2043.11.camel@localhost> <8cb6106e0805070800m46101f21sa8298b33e82bbfbd@mail.gmail.com> <1210172870.2043.17.camel@localhost> <a31046fc0805070821i742a0065i9f938e9964bb144e@mail.gmail.com> <8cb6106e0805070841p12d95c2k6e76a5ce5d8b512e@mail.gmail.com> <8cb6106e0805062004r681045b5ge2981ae73e777a49@mail.gmail.com> <1210163153.2043.11.camel@localhost> <8cb6106e0805070800m46101f21sa8298b33e82bbfbd@mail.gmail.com> <1210172870.2043.17.camel@localhost> <a31046fc0805070821i742a0065i9f938e9964bb144e@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/file.h>
>  #include <sys/malloc.h>
>  #include <sys/lock.h>
> +#include <sys/sx.h>
>  #include <sys/iconv.h>
>  
>  /* #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 <sys/_sx.h>
> +
>  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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?TfxE9AYpsGcM2odJJk%2B2PzF/RR4>