Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ntfs * convert ntfs_nt{get|put|rele}() to lockmgr()-styl...
details: https://anonhg.NetBSD.org/src/rev/6019dd19adc8
branches: trunk
changeset: 477060:6019dd19adc8
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sat Oct 09 14:27:42 1999 +0000
description:
* convert ntfs_nt{get|put|rele}() to lockmgr()-style locking and
guard the setting and checking of i_usecount by simplelock; as
situation where there would be several users of same ntnode is
extremery rare, it's not worth the efford to change the code to
hold the (exclusive) lock only when it's needed
* in struct fnode, g/c f_dev & f_type (former is already in ntnode,
latter is in parent vnode), move f_devvp from struct fnode into
struct ntnode (no reason this should be copied in each fnode)
diffstat:
sys/ntfs/ntfs_inode.h | 15 ++++++----
sys/ntfs/ntfs_subr.c | 65 +++++++++++++++++++++++--------------------------
sys/ntfs/ntfs_vfsops.c | 13 +++++----
sys/ntfs/ntfs_vnops.c | 17 ++++++------
4 files changed, 54 insertions(+), 56 deletions(-)
diffs (truncated from 315 to 300 lines):
diff -r 41357f8ff28a -r 6019dd19adc8 sys/ntfs/ntfs_inode.h
--- a/sys/ntfs/ntfs_inode.h Sat Oct 09 12:48:12 1999 +0000
+++ b/sys/ntfs/ntfs_inode.h Sat Oct 09 14:27:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_inode.h,v 1.6 1999/09/29 15:58:28 jdolecek Exp $ */
+/* $NetBSD: ntfs_inode.h,v 1.7 1999/10/09 14:27:42 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -57,15 +57,21 @@
#define IN_PRELOADED 0x4000 /* loaded from directory entry */
struct ntnode {
+ struct vnode *i_devvp; /* vnode of blk dev we live on */
+ dev_t i_dev; /* Device associated with the inode. */
+
LIST_ENTRY(ntnode) i_hash;
struct ntnode *i_next;
struct ntnode **i_prev;
struct ntfsmount *i_mp;
ino_t i_number;
- dev_t i_dev;
u_int32_t i_flag;
- int i_lock;
+
+ /* locking */
+ struct lock i_lock;
+ struct simplelock i_interlock;
int i_usecount;
+
LIST_HEAD(,fnode) i_fnlist;
LIST_HEAD(,ntvattr) i_valist;
@@ -90,9 +96,6 @@
struct vnode *f_vp; /* Associatied vnode */
struct ntnode *f_ip; /* Associated ntnode */
u_long f_flag;
- struct vnode *f_devvp; /* vnode of blk dev we live on */
- dev_t f_dev; /* Device associated with the inode. */
- enum vtype f_type;
ntfs_times_t f_times; /* $NAME/dirinfo */
ino_t f_pnumber; /* $NAME/dirinfo */
diff -r 41357f8ff28a -r 6019dd19adc8 sys/ntfs/ntfs_subr.c
--- a/sys/ntfs/ntfs_subr.c Sat Oct 09 12:48:12 1999 +0000
+++ b/sys/ntfs/ntfs_subr.c Sat Oct 09 14:27:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_subr.c,v 1.18 1999/10/01 20:01:20 jdolecek Exp $ */
+/* $NetBSD: ntfs_subr.c,v 1.19 1999/10/09 14:27:42 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -360,17 +360,9 @@
dprintf(("ntfs_ntget: get ntnode %d: %p, usecount: %d\n",
ip->i_number, ip, ip->i_usecount));
+ simple_lock(&ip->i_interlock);
ip->i_usecount++;
-
-restart:
- if (ip->i_lock) {
- while (ip->i_lock) {
- ip->i_lock = -1;
- tsleep(&ip->i_lock, PVM, "ntnode", 0);
- }
- goto restart;
- }
- ip->i_lock = 1;
+ lockmgr(&ip->i_lock, LK_EXCLUSIVE|LK_INTERLOCK, &ip->i_interlock);
return 0;
}
@@ -400,7 +392,7 @@
ino, ip, ip->i_usecount));
return (0);
}
- } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
+ } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, NULL));
MALLOC(ip, struct ntnode *, sizeof(struct ntnode),
M_NTFSNTNODE, M_WAITOK);
@@ -408,21 +400,24 @@
bzero((caddr_t) ip, sizeof(struct ntnode));
/* Generic initialization */
+ ip->i_devvp = ntmp->ntm_devvp;
+ ip->i_dev = ntmp->ntm_dev;
ip->i_number = ino;
ip->i_mp = ntmp;
- ip->i_dev = ntmp->ntm_dev;
ip->i_uid = ntmp->ntm_uid;
ip->i_gid = ntmp->ntm_gid;
ip->i_mode = ntmp->ntm_mode;
- ip->i_usecount++;
-
- ip->i_lock = 1;
LIST_INIT(&ip->i_fnlist);
+ /* init lock and lock the newborn ntnode */
+ lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE);
+ simple_lock_init(&ip->i_interlock);
+ ntfs_ntget(ip);
+
ntfs_nthashins(ip);
- lockmgr(&ntfs_hashlock, LK_RELEASE, 0);
+ lockmgr(&ntfs_hashlock, LK_RELEASE, NULL);
*ipp = ip;
@@ -444,17 +439,20 @@
{
struct ntvattr *vap;
- if (!ip->i_lock) printf("ntfs_ntput: NOT LOCKED");
-
dprintf(("ntfs_ntput: rele ntnode %d: %p, usecount: %d\n",
ip->i_number, ip, ip->i_usecount));
+ simple_lock(&ip->i_interlock);
ip->i_usecount--;
+#ifdef DIAGNOSTIC
if (ip->i_usecount < 0) {
panic("ntfs_ntput: ino: %d usecount: %d \n",
ip->i_number,ip->i_usecount);
- } else if (ip->i_usecount == 0) {
+ }
+#endif
+
+ if (ip->i_usecount == 0) {
dprintf(("ntfs_ntput: deallocating ntnode: %d\n",
ip->i_number));
@@ -470,9 +468,7 @@
}
FREE(ip, M_NTFSNTNODE);
} else {
- if (ip->i_lock < 0)
- wakeup(&ip->i_lock);
- ip->i_lock = 0;
+ lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock);
}
}
@@ -480,26 +476,27 @@
* Decrement usecount of ntnode.
*/
void
-ntfs_ntrele(
- struct ntnode * ip)
+ntfs_ntrele(ip)
+ struct ntnode * ip;
{
dprintf(("ntfs_ntrele: rele ntnode %d: %p, usecount: %d\n",
ip->i_number, ip, ip->i_usecount));
+ simple_lock(&ip->i_interlock);
ip->i_usecount--;
if (ip->i_usecount < 0)
panic("ntfs_ntrele: ino: %d usecount: %d \n",
ip->i_number,ip->i_usecount);
+ simple_unlock(&ip->i_interlock);
}
/*
- * Deallocate all memory allocated for ntvattr by call to
- * ntfs_attrtontvattr and some other functions.
+ * Deallocate all memory allocated for ntvattr
*/
void
-ntfs_freentvattr(
- struct ntvattr * vap)
+ntfs_freentvattr(vap)
+ struct ntvattr * vap;
{
if (vap->va_flag & NTFS_AF_INRUN) {
if (vap->va_vruncn)
@@ -749,9 +746,6 @@
bzero(fp, sizeof(struct fnode));
dprintf(("ntfs_fget: allocating fnode: %p\n",fp));
- fp->f_devvp = ntmp->ntm_devvp;
- fp->f_dev = ntmp->ntm_dev;
-
fp->f_ip = ip;
fp->f_attrname = attrname;
if (fp->f_attrname) fp->f_flag |= FN_AATTRNAME;
@@ -870,6 +864,7 @@
char *attrname = NULL;
struct fnode *nfp;
struct vnode *nvp;
+ enum vtype f_type;
error = ntfs_ntget(ip);
@@ -986,11 +981,11 @@
if((nfp->f_fflag & NTFS_FFLAG_DIR) &&
(nfp->f_attrtype == NTFS_A_DATA) &&
(nfp->f_attrname == NULL))
- nfp->f_type = VDIR;
+ f_type = VDIR;
else
- nfp->f_type = VREG;
+ f_type = VREG;
- nvp->v_type = nfp->f_type;
+ nvp->v_type = f_type;
if ((nfp->f_attrtype == NTFS_A_DATA) &&
(nfp->f_attrname == NULL))
diff -r 41357f8ff28a -r 6019dd19adc8 sys/ntfs/ntfs_vfsops.c
--- a/sys/ntfs/ntfs_vfsops.c Sat Oct 09 12:48:12 1999 +0000
+++ b/sys/ntfs/ntfs_vfsops.c Sat Oct 09 14:27:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vfsops.c,v 1.15 1999/09/29 15:58:28 jdolecek Exp $ */
+/* $NetBSD: ntfs_vfsops.c,v 1.16 1999/10/09 14:27:42 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -877,6 +877,7 @@
struct ntnode *ip;
struct fnode *fp;
struct vnode *vp;
+ enum vtype f_type;
dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
ino, attrtype, attrname?attrname:"", (u_long)lkflags,
@@ -913,13 +914,13 @@
if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
(fp->f_attrtype == 0x80 && fp->f_attrname == NULL)) {
- fp->f_type = VDIR;
+ f_type = VDIR;
} else if(flags & VG_EXT) {
- fp->f_type = VNON;
+ f_type = VNON;
fp->f_size =fp->f_allocated = 0;
} else {
- fp->f_type = VREG;
+ f_type = VREG;
error = ntfs_filesize(ntmp, fp,
&fp->f_size, &fp->f_allocated);
@@ -952,7 +953,7 @@
#endif
fp->f_vp = vp;
vp->v_data = fp;
- vp->v_type = fp->f_type;
+ vp->v_type = f_type;
if (ino == NTFS_ROOTINO)
vp->v_flag |= VROOT;
@@ -967,7 +968,7 @@
}
}
- VREF(fp->f_devvp);
+ VREF(ip->i_devvp);
*vpp = vp;
return (0);
diff -r 41357f8ff28a -r 6019dd19adc8 sys/ntfs/ntfs_vnops.c
--- a/sys/ntfs/ntfs_vnops.c Sat Oct 09 12:48:12 1999 +0000
+++ b/sys/ntfs/ntfs_vnops.c Sat Oct 09 14:27:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vnops.c,v 1.17 1999/09/29 15:36:08 jdolecek Exp $ */
+/* $NetBSD: ntfs_vnops.c,v 1.18 1999/10/09 14:27:42 jdolecek Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -216,9 +216,9 @@
dprintf(("ntfs_getattr: %d, flags: %d\n",ip->i_number,ip->i_flag));
#if defined(__FreeBSD__)
- vap->va_fsid = dev2udev(fp->f_dev);
+ vap->va_fsid = dev2udev(ip->i_dev);
#else /* NetBSD */
- vap->va_fsid = fp->f_dev;
+ vap->va_fsid = ip->i_dev;
#endif
vap->va_fileid = ip->i_number;
vap->va_mode = ip->i_mode;
@@ -234,7 +234,7 @@
vap->va_flags = ip->i_flag;
vap->va_gen = 0;
vap->va_blocksize = ip->i_mp->ntm_spc * ip->i_mp->ntm_bps;
- vap->va_type = fp->f_type;
+ vap->va_type = vp->v_type;
vap->va_filerev = 0;
return (0);
}
@@ -301,15 +301,14 @@
/* Purge old data structures associated with the inode. */
cache_purge(vp);
- if (fp->f_devvp) {
Home |
Main Index |
Thread Index |
Old Index