summaryrefslogtreecommitdiffstats
path: root/sys/fs/msdosfs
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2002-09-25 02:32:42 +0000
committerjeff <jeff@FreeBSD.org>2002-09-25 02:32:42 +0000
commitf7e588347b3192f4351b4e27c498cc085021b6e4 (patch)
tree8197cc22dc1ce7991152741f8cdeab9111066188 /sys/fs/msdosfs
parent55a297392dfe0205c2d76aca3bd3de47ea4877b3 (diff)
downloadFreeBSD-src-f7e588347b3192f4351b4e27c498cc085021b6e4.zip
FreeBSD-src-f7e588347b3192f4351b4e27c498cc085021b6e4.tar.gz
- Use vrefcnt() where it is safe to do so instead of doing direct and
unlocked accesses to v_usecount. - Lock access to the buf lists in the various sync routines. interlock locking could be avoided almost entirely in leaf filesystems if the fsync function had a generic helper.
Diffstat (limited to 'sys/fs/msdosfs')
-rw-r--r--sys/fs/msdosfs/msdosfs_denode.c8
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c6
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c12
3 files changed, 15 insertions, 11 deletions
diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c
index 9b12552..6a141bec 100644
--- a/sys/fs/msdosfs/msdosfs_denode.c
+++ b/sys/fs/msdosfs/msdosfs_denode.c
@@ -653,7 +653,7 @@ msdosfs_reclaim(ap)
dep, dep->de_Name, dep->de_refcnt);
#endif
- if (prtactive && vp->v_usecount != 0)
+ if (prtactive && vrefcnt(vp) != 0)
vprint("msdosfs_reclaim(): pushing active", vp);
/*
* Remove the denode from its hash chain.
@@ -693,7 +693,7 @@ msdosfs_inactive(ap)
printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]);
#endif
- if (prtactive && vp->v_usecount != 0)
+ if (prtactive && vrefcnt(vp) != 0)
vprint("msdosfs_inactive(): pushing active", vp);
/*
@@ -725,8 +725,8 @@ out:
* so that it can be reused immediately.
*/
#ifdef MSDOSFS_DEBUG
- printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount,
- dep->de_Name[0]);
+ printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n",
+ vrefcnt(vp), dep->de_Name[0]);
#endif
if (dep->de_Name[0] == SLOT_DELETED)
vrecycle(vp, NULL, td);
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index bd3703d..f7994b6 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -635,6 +635,7 @@ msdosfs_unmount(mp, mntflags, td)
{
struct vnode *vp = pmp->pm_devvp;
+ VI_LOCK(vp);
printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
printf("iflag %08lx, usecount %d, writecount %d, holdcnt %ld\n",
vp->vi_flag, vp->v_usecount, vp->v_writecount,
@@ -652,6 +653,7 @@ msdosfs_unmount(mp, mntflags, td)
vp->v_socket, vp->v_tag,
((u_int *)vp->v_data)[0],
((u_int *)vp->v_data)[1]);
+ VI_UNLOCK(vp);
}
#endif
error = VOP_CLOSE(pmp->pm_devvp,
@@ -747,13 +749,13 @@ loop:
nvp = TAILQ_NEXT(vp, v_nmntvnodes);
mtx_unlock(&mntvnode_mtx);
- mtx_lock(&vp->v_interlock);
+ VI_LOCK(vp);
dep = VTODE(vp);
if (vp->v_type == VNON ||
((dep->de_flag &
(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 &&
(TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
- mtx_unlock(&vp->v_interlock);
+ VI_UNLOCK(vp);
mtx_lock(&mntvnode_mtx);
continue;
}
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index b7d4f7c..b7ef69f 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -218,12 +218,12 @@ msdosfs_close(ap)
struct denode *dep = VTODE(vp);
struct timespec ts;
- mtx_lock(&vp->v_interlock);
+ VI_LOCK(vp);
if (vp->v_usecount > 1) {
getnanotime(&ts);
DETIMES(dep, &ts, &ts, &ts);
}
- mtx_unlock(&vp->v_interlock);
+ VI_UNLOCK(vp);
return 0;
}
@@ -818,13 +818,15 @@ loop:
VI_LOCK(vp);
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT))
+ VI_UNLOCK(vp);
+ if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
+ VI_LOCK(vp);
continue;
+ }
if ((bp->b_flags & B_DELWRI) == 0)
panic("msdosfs_fsync: not dirty");
bremfree(bp);
splx(s);
- VI_UNLOCK(vp);
/* XXX Could do bawrite */
(void) bwrite(bp);
goto loop;
@@ -834,13 +836,13 @@ loop:
(void) msleep((caddr_t)&vp->v_numoutput, VI_MTX(vp),
PRIBIO + 1, "msdosfsn", 0);
}
- VI_UNLOCK(vp);
#ifdef DIAGNOSTIC
if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
vprint("msdosfs_fsync: dirty", vp);
goto loop;
}
#endif
+ VI_UNLOCK(vp);
splx(s);
return (deupdat(VTODE(vp), ap->a_waitfor == MNT_WAIT));
}
OpenPOWER on IntegriCloud