diff options
author | Patrick Latifi <pat@cvs.openbsd.org> | 2005-03-08 15:45:21 +0000 |
---|---|---|
committer | Patrick Latifi <pat@cvs.openbsd.org> | 2005-03-08 15:45:21 +0000 |
commit | dc221260f4faebb6e04ad8c8f245e9dd6ec6bc54 (patch) | |
tree | 788d6cfc58616d2b6bc276538598a421b05b1766 | |
parent | a31a4e07626bf10eecbcff55d136fd3e7550e65f (diff) |
fix a page fault that occurs when a reclaimed vnode is then reused.
from FreeBSD
ok pedro tedu miod, tested by millert and myself
-rw-r--r-- | sys/ntfs/ntfs_subr.c | 34 | ||||
-rw-r--r-- | sys/ntfs/ntfs_vfsops.c | 3 | ||||
-rw-r--r-- | sys/ntfs/ntfs_vnops.c | 6 |
3 files changed, 20 insertions, 23 deletions
diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index 029dcf8dc2b..8589f4f786a 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_subr.c,v 1.3 2003/05/20 03:36:42 tedu Exp $ */ +/* $OpenBSD: ntfs_subr.c,v 1.4 2005/03/08 15:45:20 pat Exp $ */ /* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */ /*- @@ -376,7 +376,7 @@ out: free(mfrp, M_TEMP); return (error); } - + /* * Routine locks ntnode and increase usecount, just opposite of * ntfs_ntput(). @@ -455,6 +455,7 @@ ntfs_ntlookup( ip->i_mp = ntmp; LIST_INIT(&ip->i_fnlist); + VREF(ip->i_devvp); /* init lock and lock the newborn ntnode */ lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE); @@ -510,28 +511,29 @@ ntfs_ntput( } #endif + if (ip->i_usecount > 0) { #ifndef __OpenBSD__ - lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock); + lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock); #else - lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock, p); + lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock, p); #endif + return; + } - if (ip->i_usecount == 0) { - dprintf(("ntfs_ntput: deallocating ntnode: %d\n", - ip->i_number)); + dprintf(("ntfs_ntput: deallocating ntnode: %d\n", ip->i_number)); - if (ip->i_fnlist.lh_first) - panic("ntfs_ntput: ntnode has fnodes"); + if (LIST_FIRST(&ip->i_fnlist)) + panic("ntfs_ntput: ntnode has fnodes"); - ntfs_nthashrem(ip); + ntfs_nthashrem(ip); - while (ip->i_valist.lh_first != NULL) { - vap = ip->i_valist.lh_first; - LIST_REMOVE(vap,va_list); - ntfs_freentvattr(vap); - } - FREE(ip, M_NTFSNTNODE); + while ((vap = LIST_FIRST(&ip->i_valist)) != NULL) { + LIST_REMOVE(vap, va_list); + ntfs_freentvattr(vap); } + + vrele(ip->i_devvp); + FREE(ip, M_NTFSNTNODE); } /* diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c index dd3a025b337..5423e75c0d1 100644 --- a/sys/ntfs/ntfs_vfsops.c +++ b/sys/ntfs/ntfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_vfsops.c,v 1.7 2005/02/01 11:29:59 pedro Exp $ */ +/* $OpenBSD: ntfs_vfsops.c,v 1.8 2005/03/08 15:45:20 pat Exp $ */ /* $NetBSD: ntfs_vfsops.c,v 1.7 2003/04/24 07:50:19 christos Exp $ */ /*- @@ -1122,7 +1122,6 @@ ntfs_vgetex( #if defined(__FreeBSD__) || defined(__NetBSD__) genfs_node_init(vp, &ntfs_genfsops); #endif - VREF(ip->i_devvp); *vpp = vp; return (0); } diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c index 597077b286a..90fdd225bfb 100644 --- a/sys/ntfs/ntfs_vnops.c +++ b/sys/ntfs/ntfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_vnops.c,v 1.4 2003/06/02 23:28:20 millert Exp $ */ +/* $OpenBSD: ntfs_vnops.c,v 1.5 2005/03/08 15:45:20 pat Exp $ */ /* $NetBSD: ntfs_vnops.c,v 1.6 2003/04/10 21:57:26 jdolecek Exp $ */ /* @@ -310,10 +310,6 @@ ntfs_reclaim(ap) /* Purge old data structures associated with the inode. */ cache_purge(vp); - if (ip->i_devvp) { - vrele(ip->i_devvp); - ip->i_devvp = NULL; - } ntfs_frele(fp); #ifndef __OpenBSD__ |