summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/ntfs/ntfs_ihash.c7
-rw-r--r--sys/ntfs/ntfs_subr.c85
-rw-r--r--sys/ntfs/ntfs_subr.h6
-rw-r--r--sys/ntfs/ntfs_vfsops.c17
4 files changed, 24 insertions, 91 deletions
diff --git a/sys/ntfs/ntfs_ihash.c b/sys/ntfs/ntfs_ihash.c
index db7be3f0173..714b60b912a 100644
--- a/sys/ntfs/ntfs_ihash.c
+++ b/sys/ntfs/ntfs_ihash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_ihash.c,v 1.8 2010/08/12 04:05:03 tedu Exp $ */
+/* $OpenBSD: ntfs_ihash.c,v 1.9 2010/08/22 21:23:07 tedu Exp $ */
/* $NetBSD: ntfs_ihash.c,v 1.1 2002/12/23 17:38:32 jdolecek Exp $ */
/*
@@ -39,17 +39,12 @@
#include <sys/rwlock.h>
#include <sys/vnode.h>
#include <sys/malloc.h>
-#include <sys/proc.h>
#include <sys/mount.h>
#include <ntfs/ntfs.h>
#include <ntfs/ntfs_inode.h>
#include <ntfs/ntfs_ihash.h>
-#ifdef MALLOC_DEFINE
-MALLOC_DEFINE(M_NTFSNTHASH, "NTFS nthash", "NTFS ntnode hash tables");
-#endif
-
/*
* Structures associated with inode cacheing.
*/
diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c
index 01ff3f8ac5f..75396c01f47 100644
--- a/sys/ntfs/ntfs_subr.c
+++ b/sys/ntfs/ntfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_subr.c,v 1.20 2010/08/12 04:05:03 tedu Exp $ */
+/* $OpenBSD: ntfs_subr.c,v 1.21 2010/08/22 21:23:07 tedu Exp $ */
/* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */
/*-
@@ -32,7 +32,6 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/namei.h>
-#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/mount.h>
@@ -56,13 +55,6 @@
int ntfs_debug = NTFS_DEBUG;
#endif
-#ifdef MALLOC_DEFINE
-MALLOC_DEFINE(M_NTFSNTVATTR, "NTFS vattr", "NTFS file attribute information");
-MALLOC_DEFINE(M_NTFSRDATA, "NTFS res data", "NTFS resident data");
-MALLOC_DEFINE(M_NTFSRUN, "NTFS vrun", "NTFS vrun storage");
-MALLOC_DEFINE(M_NTFSDECOMP, "NTFS decomp", "NTFS decompression temporary");
-#endif
-
/* Local struct used in ntfs_ntlookupfile() */
struct ntfs_lookup_ctx {
u_int32_t aoff;
@@ -76,13 +68,10 @@ static int ntfs_findvattr(struct ntfsmount *, struct ntnode *, struct ntvattr **
static int ntfs_uastricmp(struct ntfsmount *, const wchar *, size_t, const char *, size_t);
static int ntfs_uastrcmp(struct ntfsmount *, const wchar *, size_t, const char *, size_t);
-/* table for mapping Unicode chars into uppercase; it's filled upon first
- * ntfs mount, freed upon last ntfs umount */
+/* table for mapping Unicode chars into uppercase */
static wchar *ntfs_toupper_tab;
#define NTFS_U28(ch) ((((ch) & 0xE0) == 0) ? '_' : (ch) & 0xFF)
#define NTFS_TOUPPER(ch) (ntfs_toupper_tab[(unsigned char)(ch)])
-struct rwlock ntfs_toupper_lock = RWLOCK_INITIALIZER("ntfs_toupper");
-static signed int ntfs_toupper_usecount;
/* support macro for ntfs_ntvattrget() */
#define NTFS_AALPCMP(aalp,type,name,namelen) ( \
@@ -1976,32 +1965,16 @@ ntfs_runtocn(
#endif
/*
- * this initializes toupper table & dependant variables to be ready for
- * later work
- */
-void
-ntfs_toupper_init()
-{
- ntfs_toupper_tab = (wchar *) NULL;
- ntfs_toupper_usecount = 0;
-}
-
-/*
- * if the ntfs_toupper_tab[] is filled already, just raise use count;
- * otherwise read the data from the filesystem we are currently mounting
+ * if the ntfs_toupper_tab[] is not filled already
+ * read the data from the filesystem we are currently mounting
*/
int
-ntfs_toupper_use(mp, ntmp, p)
- struct mount *mp;
- struct ntfsmount *ntmp;
- struct proc *p;
+ntfs_load_toupper(struct mount *mp, struct ntfsmount *ntmp)
{
int error = 0;
+ wchar *buf = NULL;
struct vnode *vp;
- /* get exclusive access */
- rw_enter_write(&ntfs_toupper_lock);
-
/* only read the translation data from a file if it hasn't been
* read already */
if (ntfs_toupper_tab)
@@ -2012,45 +1985,23 @@ ntfs_toupper_use(mp, ntmp, p)
* XXX for now, just the first 256 entries are used anyway,
* so don't bother reading more
*/
- ntfs_toupper_tab = malloc(256 * 256 * sizeof(wchar), M_NTFSRDATA,
- M_WAITOK);
+ buf = malloc(256 * sizeof(wchar), M_NTFSRDATA, M_WAITOK);
if ((error = VFS_VGET(mp, NTFS_UPCASEINO, &vp)))
goto out;
- error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
- 0, 256*256*sizeof(wchar), (char *) ntfs_toupper_tab,
- NULL);
+ error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL, 0,
+ 256 * sizeof(wchar), ntfs_toupper_tab, NULL);
vput(vp);
- out:
- ntfs_toupper_usecount++;
- rw_exit_write(&ntfs_toupper_lock);
- return (error);
-}
+ /* check we didn't lose a race */
+ if (!ntfs_toupper_tab) {
+ ntfs_toupper_tab = buf;
+ buf = NULL;
+ }
-/*
- * lower the use count and if it reaches zero, free the memory
- * tied by toupper table
- */
-void
-ntfs_toupper_unuse(p)
- struct proc *p;
-{
- /* get exclusive access */
- rw_enter_write(&ntfs_toupper_lock);
+out:
+ if (buf)
+ free(buf, M_NTFSRDATA);
- ntfs_toupper_usecount--;
- if (ntfs_toupper_usecount == 0) {
- free(ntfs_toupper_tab, M_NTFSRDATA);
- ntfs_toupper_tab = NULL;
- }
-#ifdef DIAGNOSTIC
- else if (ntfs_toupper_usecount < 0) {
- panic("ntfs_toupper_unuse(): use count negative: %d",
- ntfs_toupper_usecount);
- }
-#endif
-
- /* release the lock */
- rw_exit_write(&ntfs_toupper_lock);
+ return (error);
}
diff --git a/sys/ntfs/ntfs_subr.h b/sys/ntfs/ntfs_subr.h
index 00296cdf16e..589848da1c8 100644
--- a/sys/ntfs/ntfs_subr.h
+++ b/sys/ntfs/ntfs_subr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_subr.h,v 1.4 2009/08/13 16:00:53 jasper Exp $ */
+/* $OpenBSD: ntfs_subr.h,v 1.5 2010/08/22 21:23:07 tedu Exp $ */
/* $NetBSD: ntfs_subr.h,v 1.1 2002/12/23 17:38:33 jdolecek Exp $ */
/*-
@@ -93,7 +93,6 @@ void ntfs_ntrele(struct ntnode *);
int ntfs_loadntnode( struct ntfsmount *, struct ntnode * );
int ntfs_writentvattr_plain(struct ntfsmount *, struct ntnode *, struct ntvattr *, off_t, size_t, void *, size_t *, struct uio *);
int ntfs_writeattr_plain(struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *, size_t *, struct uio *);
-void ntfs_toupper_init(void);
int ntfs_fget(struct ntfsmount *, struct ntnode *, int, char *, struct fnode **);
void ntfs_frele(struct fnode *);
int ntfs_ntreaddir(struct ntfsmount *, struct fnode *, u_int32_t, struct attr_indexentry **, struct proc *);
@@ -101,8 +100,7 @@ int ntfs_ntlookupfile(struct ntfsmount *, struct vnode *, struct componentname *
int ntfs_ntlookup(struct ntfsmount *, ino_t, struct ntnode **, struct proc *);
int ntfs_ntget(struct ntnode *, struct proc *);
void ntfs_ntput(struct ntnode *, struct proc *);
-int ntfs_toupper_use(struct mount *, struct ntfsmount *, struct proc *);
-void ntfs_toupper_unuse(struct proc *);
+int ntfs_load_toupper(struct mount *, struct ntfsmount *);
/* ntfs_conv.c stuff */
ntfs_wget_func_t ntfs_utf8_wget;
diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c
index 459d8d7a9fe..a23f681402c 100644
--- a/sys/ntfs/ntfs_vfsops.c
+++ b/sys/ntfs/ntfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntfs_vfsops.c,v 1.19 2010/08/12 04:05:03 tedu Exp $ */
+/* $OpenBSD: ntfs_vfsops.c,v 1.20 2010/08/22 21:23:07 tedu Exp $ */
/* $NetBSD: ntfs_vfsops.c,v 1.7 2003/04/24 07:50:19 christos Exp $ */
/*-
@@ -68,13 +68,6 @@
#include <ntfs/ntfsmount.h>
#endif
-#ifdef MALLOC_DEFINE
-MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
-MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
-MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
-MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
-#endif
-
#if defined(__FreeBSD__)
static int ntfs_mount(struct mount *, char *, caddr_t,
struct nameidata *, struct proc *);
@@ -150,7 +143,6 @@ ntfs_init (
struct vfsconf *vcp )
{
ntfs_nthashinit();
- ntfs_toupper_init();
return 0;
}
@@ -412,14 +404,14 @@ ntfs_mountfs(devvp, mp, argsp, p)
/* read the Unicode lowercase --> uppercase translation table,
* if necessary */
- if ((error = ntfs_toupper_use(mp, ntmp, p)))
+ if ((error = ntfs_load_toupper(mp, ntmp)))
goto out1;
/*
* Scan $BitMap and count free clusters
*/
error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
- if(error)
+ if (error)
goto out1;
/*
@@ -569,9 +561,6 @@ ntfs_unmount(
vput(ntmp->ntm_devvp);
- /* free the toupper table, if this has been last mounted ntfs volume */
- ntfs_toupper_unuse(p);
-
dprintf(("ntfs_umount: freeing memory...\n"));
mp->mnt_data = NULL;
mp->mnt_flag &= ~MNT_LOCAL;