Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ntfs pass the lock flags in the NetBSD version of VN_LOC...
details: https://anonhg.NetBSD.org/src/rev/d76da0954310
branches: trunk
changeset: 477634:d76da0954310
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Mon Oct 25 19:08:26 1999 +0000
description:
pass the lock flags in the NetBSD version of VN_LOCK(), VGET(),
VOP__UNLOCK() macros, g/c VOP__LOCK()
add some comments
use LK_RETRY flag as appropriate
g/c the FreeBSD vnode_pager_uncache() staff, as was done in FreeBSD tree a while
ago (actually, when they merged the first round of NetBSD patches)
use VN_LOCK() & VOP__UNLOCK() consistently throughout the code instead
of vn_lock() and VOP_UNLOCK()
minor whitespace changes
diffstat:
sys/ntfs/ntfs.h | 16 +++++++++-------
sys/ntfs/ntfs_subr.c | 18 +++++++++---------
sys/ntfs/ntfs_vfsops.c | 29 ++++++++++++++---------------
sys/ntfs/ntfs_vnops.c | 14 ++++----------
4 files changed, 36 insertions(+), 41 deletions(-)
diffs (217 lines):
diff -r 368d78ff25ec -r d76da0954310 sys/ntfs/ntfs.h
--- a/sys/ntfs/ntfs.h Mon Oct 25 17:26:05 1999 +0000
+++ b/sys/ntfs/ntfs.h Mon Oct 25 19:08:26 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs.h,v 1.7 1999/09/11 15:55:12 jdolecek Exp $ */
+/* $NetBSD: ntfs.h,v 1.8 1999/10/25 19:08:26 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -305,17 +305,19 @@
typedef int (vop_t) __P((void *));
#define HASHINIT(a, b, c, d) hashinit((a), (b), (c), (d))
#define bqrelse(bp) brelse(bp)
-#define VOP__LOCK(a, b, c) VOP_LOCK((a), (b) ? LK_EXCLUSIVE : LK_SHARED)
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), 0)
-#define VGET(a, b, c) vget((a), LK_EXCLUSIVE)
-#define VN_LOCK(a, b, c) vn_lock((a), LK_EXCLUSIVE)
-#else
+#define VGET(a, b, c) vget((a), (b))
+#define VN_LOCK(a, b, c) vn_lock((a), (b))
+#else /* !NetBSD */
#define HASHINIT(a, b, c, d) hashinit((a), (b), (d))
-#define VOP__LOCK(a, b, c) VOP_LOCK((a), (b), (c))
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b), (c))
#define VGET(a, b, c) vget((a), (b), (c))
#define VN_LOCK(a, b, c) vn_lock((a), (b), (c))
-#endif
+
+/* PDIRUNLOCK is used by NetBSD to mark if vfs_lookup() unlocked parent dir;
+ * on FreeBSD, it's not defined and nothing similar exists */
+#define PDIRUNLOCK 0
+#endif /* NetBSD */
#if defined(NTFS_DEBUG)
#define dprintf(a) printf a
diff -r 368d78ff25ec -r d76da0954310 sys/ntfs/ntfs_subr.c
--- a/sys/ntfs/ntfs_subr.c Mon Oct 25 17:26:05 1999 +0000
+++ b/sys/ntfs/ntfs_subr.c Mon Oct 25 19:08:26 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_subr.c,v 1.20 1999/10/10 14:48:37 jdolecek Exp $ */
+/* $NetBSD: ntfs_subr.c,v 1.21 1999/10/25 19:08:26 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -225,12 +225,11 @@
dprintf(("ntfs_ntvattrget: attribute in ino: %d\n",
aalp->al_inumber));
-/*
- error = VFS_VGET(ntmp->ntm_mountp, aalp->al_inumber, &newvp);
-*/
+ /* this is not a main record, so we can't use just plain
+ vget() */
error = ntfs_vgetex(ntmp->ntm_mountp, aalp->al_inumber,
- NTFS_A_DATA, NULL, LK_EXCLUSIVE,
- VG_EXT, curproc, &newvp);
+ NTFS_A_DATA, NULL, LK_EXCLUSIVE | LK_RETRY,
+ VG_EXT, curproc, &newvp);
if (error) {
printf("ntfs_ntvattrget: CAN'T VGET INO: %d\n",
aalp->al_inumber);
@@ -364,7 +363,7 @@
simple_lock(&ip->i_interlock);
ip->i_usecount++;
- lockmgr(&ip->i_lock, LK_EXCLUSIVE|LK_INTERLOCK, &ip->i_interlock);
+ lockmgr(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock);
return 0;
}
@@ -394,7 +393,7 @@
*ipp = ip;
return (0);
}
- } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, NULL));
+ } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL));
MALLOC(ip, struct ntnode *, sizeof(struct ntnode),
M_NTFSNTNODE, M_WAITOK);
@@ -957,7 +956,8 @@
/* vget node, but don't load it */
error = ntfs_vgetex(ntmp->ntm_mountp,
iep->ie_number, attrtype, attrname,
- LK_EXCLUSIVE, VG_DONTLOADIN | VG_DONTVALIDFN,
+ LK_EXCLUSIVE | LK_RETRY,
+ VG_DONTLOADIN | VG_DONTVALIDFN,
curproc, &nvp);
if (error)
goto fail;
diff -r 368d78ff25ec -r d76da0954310 sys/ntfs/ntfs_vfsops.c
--- a/sys/ntfs/ntfs_vfsops.c Mon Oct 25 17:26:05 1999 +0000
+++ b/sys/ntfs/ntfs_vfsops.c Mon Oct 25 19:08:26 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vfsops.c,v 1.20 1999/10/20 14:32:10 enami Exp $ */
+/* $NetBSD: ntfs_vfsops.c,v 1.21 1999/10/25 19:08:26 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -438,9 +438,9 @@
if (ncount > 1 && devvp != rootvp)
return (EBUSY);
#if defined(__FreeBSD__)
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
+ VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
- VOP_UNLOCK(devvp, 0, p);
+ VOP__UNLOCK(devvp, 0, p);
#else
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
#endif
@@ -607,9 +607,9 @@
#if defined __NetBSD__
/* lock the device vnode before calling VOP_CLOSE() */
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
+ VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
(void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
- VOP_UNLOCK(devvp, 0);
+ VOP__UNLOCK(devvp, 0, p);
#else
(void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
#endif
@@ -665,11 +665,11 @@
#if defined(__FreeBSD__)
ntmp->ntm_devvp->v_specmountpoint = NULL;
-
- VOP_LOCK(ntmp->ntm_devvp);
- vnode_pager_uncache(ntmp->ntm_devvp);
- VOP_UNLOCK(ntmp->ntm_devvp);
#else
+ /* Check if the type of device node isn't VBAD before
+ * touching v_specinfo. If the device vnode is revoked, the
+ * field is NULL and touching it causes null pointer derefercence.
+ */
if (ntmp->ntm_devvp->v_type != VBAD)
ntmp->ntm_devvp->v_specflags &= ~SI_MOUNTEDON;
#endif
@@ -681,7 +681,7 @@
VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
NOCRED, p);
- VOP_UNLOCK(ntmp->ntm_devvp, 0);
+ VOP__UNLOCK(ntmp->ntm_devvp, 0, p);
#else
error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
NOCRED, p);
@@ -928,12 +928,11 @@
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_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
f_type = VDIR;
- } else if(flags & VG_EXT) {
+ } else if (flags & VG_EXT) {
f_type = VNON;
-
- fp->f_size =fp->f_allocated = 0;
+ fp->f_size = fp->f_allocated = 0;
} else {
f_type = VREG;
@@ -996,7 +995,7 @@
struct vnode **vpp)
{
return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
- LK_EXCLUSIVE, 0, curproc, vpp);
+ LK_EXCLUSIVE | LK_RETRY, 0, curproc, vpp);
}
#if defined(__FreeBSD__)
diff -r 368d78ff25ec -r d76da0954310 sys/ntfs/ntfs_vnops.c
--- a/sys/ntfs/ntfs_vnops.c Mon Oct 25 17:26:05 1999 +0000
+++ b/sys/ntfs/ntfs_vnops.c Mon Oct 25 19:08:26 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vnops.c,v 1.19 1999/10/10 14:19:54 jdolecek Exp $ */
+/* $NetBSD: ntfs_vnops.c,v 1.20 1999/10/25 19:08:26 jdolecek Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -789,9 +789,7 @@
return (error);
VOP__UNLOCK(dvp,0,cnp->cn_proc);
-#ifdef __NetBSD__
cnp->cn_flags |= PDIRUNLOCK;
-#endif
dprintf(("ntfs_lookup: parentdir: %d\n",
vap->va_a_name->n_pnumber));
@@ -799,22 +797,18 @@
vap->va_a_name->n_pnumber,ap->a_vpp);
ntfs_ntvattrrele(vap);
if (error) {
- if (vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY) == 0) {
-#ifdef __NetBSD__
+ if (VN_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, curproc) == 0)
cnp->cn_flags &= ~PDIRUNLOCK;
-#endif
- }
return(error);
}
if (lockparent && (cnp->cn_flags & ISLASTCN)) {
- if ((error = vn_lock(dvp, LK_EXCLUSIVE))) {
+ error = VN_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, curproc);
+ if (error) {
vput( *(ap->a_vpp) );
return (error);
}
-#ifdef __NetBSD__
cnp->cn_flags &= ~PDIRUNLOCK;
-#endif
}
} else {
error = ntfs_ntlookupfile(ntmp, dvp, cnp, ap->a_vpp);
Home |
Main Index |
Thread Index |
Old Index