Hi,
Could all people who enable ntfs support in generic please test this
diff. It changes ntfs over from the deprecated lockmgr to the shiny
new(er) rwlock. It cleans things up a bit and lets us remove some stuff
elsewhere, may speed things up a little bit. So please test it and let
me know how it works for you.
Cheers,
-0-
--
A new dramatist of the absurd
Has a voice that will shortly be heard.
I learn from my spies
He's about to devise
An unprintable three-letter word.
Index: ntfs/ntfs_conv.c
===================================================================
RCS file: /cvs/src/sys/ntfs/ntfs_conv.c,v
retrieving revision 1.5
diff -u -p -r1.5 ntfs_conv.c
--- ntfs/ntfs_conv.c 26 Jun 2008 05:42:20 -0000 1.5
+++ ntfs/ntfs_conv.c 25 Mar 2009 02:03:58 -0000
@@ -43,7 +43,6 @@
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/malloc.h>
-#include <sys/lock.h>
#if defined(__FreeBSD__)
#include <machine/clock.h>
#endif
Index: ntfs/ntfs_ihash.c
===================================================================
RCS file: /cvs/src/sys/ntfs/ntfs_ihash.c,v
retrieving revision 1.4
diff -u -p -r1.4 ntfs_ihash.c
--- ntfs/ntfs_ihash.c 13 May 2008 02:24:08 -0000 1.4
+++ ntfs/ntfs_ihash.c 25 Mar 2009 02:06:04 -0000
@@ -37,6 +37,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
+#include <sys/rwlock.h>
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <sys/proc.h>
@@ -65,7 +66,7 @@ static u_long ntfs_nthash; /* size of h
#ifndef NULL_SIMPLELOCKS
static struct simplelock ntfs_nthash_slock;
#endif
-struct lock ntfs_hashlock;
+struct rwlock ntfs_hashlock = RWLOCK_INITIALIZER("ntfs_nthashlock");
/*
* Initialize inode hash table.
@@ -73,7 +74,6 @@ struct lock ntfs_hashlock;
void
ntfs_nthashinit()
{
- lockinit(&ntfs_hashlock, PINOD, "ntfs_nthashlock", 0, 0);
ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
&ntfs_nthash);
simple_lock_init(&ntfs_nthash_slock);
Index: ntfs/ntfs_ihash.h
===================================================================
RCS file: /cvs/src/sys/ntfs/ntfs_ihash.h,v
retrieving revision 1.3
diff -u -p -r1.3 ntfs_ihash.h
--- ntfs/ntfs_ihash.h 20 May 2003 03:36:42 -0000 1.3
+++ ntfs/ntfs_ihash.h 25 Mar 2009 02:03:00 -0000
@@ -29,7 +29,7 @@
* Id: ntfs_ihash.h,v 1.3 1999/05/12 09:42:59 semenu Exp
*/
-extern struct lock ntfs_hashlock;
+extern struct rwlock ntfs_hashlock;
void ntfs_nthashinit(void);
void ntfs_nthashreinit(void);
void ntfs_nthashdone(void);
Index: ntfs/ntfs_inode.h
===================================================================
RCS file: /cvs/src/sys/ntfs/ntfs_inode.h,v
retrieving revision 1.3
diff -u -p -r1.3 ntfs_inode.h
--- ntfs/ntfs_inode.h 12 Apr 2007 22:02:57 -0000 1.3
+++ ntfs/ntfs_inode.h 25 Mar 2009 02:11:54 -0000
@@ -73,7 +73,7 @@ struct ntnode {
u_int32_t i_flag;
/* locking */
- struct lock i_lock;
+ struct rwlock i_lock;
int i_usecount;
LIST_HEAD(,fnode) i_fnlist;
Index: ntfs/ntfs_subr.c
===================================================================
RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v
retrieving revision 1.15
diff -u -p -r1.15 ntfs_subr.c
--- ntfs/ntfs_subr.c 13 May 2008 02:24:08 -0000 1.15
+++ ntfs/ntfs_subr.c 25 Mar 2009 02:12:38 -0000
@@ -39,7 +39,7 @@
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/malloc.h>
-#include <sys/lock.h>
+#include <sys/rwlock.h>
#if defined(__FreeBSD__)
#include <machine/clock.h>
#endif
@@ -94,7 +94,7 @@ static int ntfs_uastrcmp(struct ntfsmoun
static wchar *ntfs_toupper_tab;
#define NTFS_U28(ch) ((((ch) & 0xE0) == 0) ? '_' : (ch) & 0xFF)
#define NTFS_TOUPPER(ch) (ntfs_toupper_tab[(unsigned char)(ch)])
-static struct lock ntfs_toupper_lock;
+struct rwlock ntfs_toupper_lock = RWLOCK_INITIALIZER("ntfs_toupper");
static signed int ntfs_toupper_usecount;
/* support macro for ntfs_ntvattrget() */
@@ -389,7 +389,7 @@ ntfs_ntget(
ip->i_usecount++;
- lockmgr(&ip->i_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&ip->i_lock);
return 0;
}
@@ -428,7 +428,7 @@ ntfs_ntlookup(
*ipp = ip;
return (0);
}
- } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL));
+ } while (rw_enter(&ntfs_hashlock, RW_WRITE | RW_SLEEPFAIL));
ip = malloc(sizeof(*ip), M_NTFSNTNODE, M_WAITOK | M_ZERO);
ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip));
@@ -443,7 +443,7 @@ ntfs_ntlookup(
VREF(ip->i_devvp);
/* init lock and lock the newborn ntnode */
- lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE);
+ rw_init(&ip->i_lock, "ntnode");
#ifndef __OpenBSD__
ntfs_ntget(ip);
#else
@@ -452,7 +452,7 @@ ntfs_ntlookup(
ntfs_nthashins(ip);
- lockmgr(&ntfs_hashlock, LK_RELEASE, NULL);
+ rw_exit(&ntfs_hashlock);
*ipp = ip;
@@ -491,7 +491,7 @@ ntfs_ntput(
#endif
if (ip->i_usecount > 0) {
- lockmgr(&ip->i_lock, LK_RELEASE, NULL);
+ rw_exit_write(&ip->i_lock);
return;
}
@@ -2054,7 +2054,6 @@ void
ntfs_toupper_init()
{
ntfs_toupper_tab = (wchar *) NULL;
- lockinit(&ntfs_toupper_lock, PVFS, "ntfs_toupper", 0, 0);
ntfs_toupper_usecount = 0;
}
@@ -2078,7 +2077,7 @@ ntfs_toupper_use(mp, ntmp, p)
struct vnode *vp;
/* get exclusive access */
- lockmgr(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&ntfs_toupper_lock);
/* only read the translation data from a file if it hasn't been
* read already */
@@ -2102,7 +2101,7 @@ ntfs_toupper_use(mp, ntmp, p)
out:
ntfs_toupper_usecount++;
- lockmgr(&ntfs_toupper_lock, LK_RELEASE, NULL);
+ rw_exit_write(&ntfs_toupper_lock);
return (error);
}
@@ -2119,7 +2118,7 @@ ntfs_toupper_unuse(p)
#endif
{
/* get exclusive access */
- lockmgr(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&ntfs_toupper_lock);
ntfs_toupper_usecount--;
if (ntfs_toupper_usecount == 0) {
@@ -2134,5 +2133,5 @@ ntfs_toupper_unuse(p)
#endif
/* release the lock */
- lockmgr(&ntfs_toupper_lock, LK_RELEASE, NULL);
+ rw_exit_write(&ntfs_toupper_lock);
}