Remove de_lock field from denode structure and make msdosfs PDIRUNLOCK aware.

This commit is contained in:
Boris Popov 2000-10-22 14:22:17 +00:00
parent 0f4eed7d8b
commit e7b1ac75dd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67437
8 changed files with 54 additions and 26 deletions

View File

@ -135,7 +135,6 @@ struct fatcache {
* contained within a vnode.
*/
struct denode {
struct lock de_lock; /* denode lock >Keep this first< */
struct denode *de_next; /* Hash chain forward */
struct denode **de_prev; /* Hash chain back */
struct vnode *de_vnode; /* addr of vnode we are part of */

View File

@ -264,7 +264,8 @@ deget(pmp, dirclust, diroffset, depp)
return error;
}
bzero((caddr_t)ldep, sizeof *ldep);
lockinit(&ldep->de_lock, PINOD, "denode", 0, 0);
lockinit(&nvp->v_lock, PINOD, "denode", 0, 0);
nvp->v_vnlock = &nvp->v_lock;
nvp->v_data = ldep;
ldep->de_vnode = nvp;
ldep->de_flag = 0;
@ -280,7 +281,7 @@ deget(pmp, dirclust, diroffset, depp)
* of at the start of msdosfs_hashins() so that reinsert() can
* call msdosfs_hashins() with a locked denode.
*/
if (lockmgr(&ldep->de_lock, LK_EXCLUSIVE, (struct mtx *)0, p))
if (VOP_LOCK(nvp, LK_EXCLUSIVE, p) != 0)
panic("deget: unexpected lock failure");
/*
@ -662,7 +663,7 @@ msdosfs_reclaim(ap)
#if 0 /* XXX */
dep->de_flag = 0;
#endif
lockdestroy(&dep->de_lock);
lockdestroy(&vp->v_lock);
FREE(dep, M_MSDOSFSNODE);
vp->v_data = NULL;

View File

@ -116,6 +116,7 @@ msdosfs_lookup(ap)
int wincnt = 1;
int chksum = -1;
int olddos = 1;
cnp->cn_flags &= ~PDIRUNLOCK;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_lookup(): looking for %s\n", cnp->cn_nameptr);
@ -363,8 +364,10 @@ notfound:
* information cannot be used.
*/
cnp->cn_flags |= SAVENAME;
if (!lockparent)
if (!lockparent) {
VOP_UNLOCK(vdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
return (EJUSTRETURN);
}
/*
@ -452,8 +455,10 @@ foundroot:
if (error)
return (error);
*vpp = DETOV(tdp);
if (!lockparent)
if (!lockparent) {
VOP_UNLOCK(vdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
return (0);
}
@ -483,8 +488,10 @@ foundroot:
return (error);
*vpp = DETOV(tdp);
cnp->cn_flags |= SAVENAME;
if (!lockparent)
if (!lockparent) {
VOP_UNLOCK(vdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
return (0);
}
@ -510,15 +517,20 @@ foundroot:
pdp = vdp;
if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
error = deget(pmp, cluster, blkoff, &tdp);
if (error) {
vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
cnp->cn_flags &= ~PDIRUNLOCK;
return (error);
}
if (lockparent && (flags & ISLASTCN) &&
(error = vn_lock(pdp, LK_EXCLUSIVE, p))) {
vput(DETOV(tdp));
return (error);
if (lockparent && (flags & ISLASTCN)) {
error = vn_lock(pdp, LK_EXCLUSIVE, p);
if (error) {
vput(DETOV(tdp));
return (error);
}
cnp->cn_flags &= ~PDIRUNLOCK;
}
*vpp = DETOV(tdp);
} else if (dp->de_StartCluster == scn && isadir) {
@ -527,8 +539,10 @@ foundroot:
} else {
if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0)
return (error);
if (!lockparent || !(flags & ISLASTCN))
if (!lockparent || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
*vpp = DETOV(tdp);
}

View File

@ -1830,7 +1830,7 @@ msdosfs_print(ap)
"tag VT_MSDOSFS, startcluster %lu, dircluster %lu, diroffset %lu ",
dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
printf(" dev %d, %d", major(dep->de_dev), minor(dep->de_dev));
lockmgr_printinfo(&dep->de_lock);
lockmgr_printinfo(&ap->a_vp->v_lock);
printf("\n");
return (0);
}

View File

@ -135,7 +135,6 @@ struct fatcache {
* contained within a vnode.
*/
struct denode {
struct lock de_lock; /* denode lock >Keep this first< */
struct denode *de_next; /* Hash chain forward */
struct denode **de_prev; /* Hash chain back */
struct vnode *de_vnode; /* addr of vnode we are part of */

View File

@ -264,7 +264,8 @@ deget(pmp, dirclust, diroffset, depp)
return error;
}
bzero((caddr_t)ldep, sizeof *ldep);
lockinit(&ldep->de_lock, PINOD, "denode", 0, 0);
lockinit(&nvp->v_lock, PINOD, "denode", 0, 0);
nvp->v_vnlock = &nvp->v_lock;
nvp->v_data = ldep;
ldep->de_vnode = nvp;
ldep->de_flag = 0;
@ -280,7 +281,7 @@ deget(pmp, dirclust, diroffset, depp)
* of at the start of msdosfs_hashins() so that reinsert() can
* call msdosfs_hashins() with a locked denode.
*/
if (lockmgr(&ldep->de_lock, LK_EXCLUSIVE, (struct mtx *)0, p))
if (VOP_LOCK(nvp, LK_EXCLUSIVE, p) != 0)
panic("deget: unexpected lock failure");
/*
@ -662,7 +663,7 @@ msdosfs_reclaim(ap)
#if 0 /* XXX */
dep->de_flag = 0;
#endif
lockdestroy(&dep->de_lock);
lockdestroy(&vp->v_lock);
FREE(dep, M_MSDOSFSNODE);
vp->v_data = NULL;

View File

@ -116,6 +116,7 @@ msdosfs_lookup(ap)
int wincnt = 1;
int chksum = -1;
int olddos = 1;
cnp->cn_flags &= ~PDIRUNLOCK;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_lookup(): looking for %s\n", cnp->cn_nameptr);
@ -363,8 +364,10 @@ notfound:
* information cannot be used.
*/
cnp->cn_flags |= SAVENAME;
if (!lockparent)
if (!lockparent) {
VOP_UNLOCK(vdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
return (EJUSTRETURN);
}
/*
@ -452,8 +455,10 @@ foundroot:
if (error)
return (error);
*vpp = DETOV(tdp);
if (!lockparent)
if (!lockparent) {
VOP_UNLOCK(vdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
return (0);
}
@ -483,8 +488,10 @@ foundroot:
return (error);
*vpp = DETOV(tdp);
cnp->cn_flags |= SAVENAME;
if (!lockparent)
if (!lockparent) {
VOP_UNLOCK(vdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
return (0);
}
@ -510,15 +517,20 @@ foundroot:
pdp = vdp;
if (flags & ISDOTDOT) {
VOP_UNLOCK(pdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
error = deget(pmp, cluster, blkoff, &tdp);
if (error) {
vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
cnp->cn_flags &= ~PDIRUNLOCK;
return (error);
}
if (lockparent && (flags & ISLASTCN) &&
(error = vn_lock(pdp, LK_EXCLUSIVE, p))) {
vput(DETOV(tdp));
return (error);
if (lockparent && (flags & ISLASTCN)) {
error = vn_lock(pdp, LK_EXCLUSIVE, p);
if (error) {
vput(DETOV(tdp));
return (error);
}
cnp->cn_flags &= ~PDIRUNLOCK;
}
*vpp = DETOV(tdp);
} else if (dp->de_StartCluster == scn && isadir) {
@ -527,8 +539,10 @@ foundroot:
} else {
if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0)
return (error);
if (!lockparent || !(flags & ISLASTCN))
if (!lockparent || !(flags & ISLASTCN)) {
VOP_UNLOCK(pdp, 0, p);
cnp->cn_flags |= PDIRUNLOCK;
}
*vpp = DETOV(tdp);
}

View File

@ -1830,7 +1830,7 @@ msdosfs_print(ap)
"tag VT_MSDOSFS, startcluster %lu, dircluster %lu, diroffset %lu ",
dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
printf(" dev %d, %d", major(dep->de_dev), minor(dep->de_dev));
lockmgr_printinfo(&dep->de_lock);
lockmgr_printinfo(&ap->a_vp->v_lock);
printf("\n");
return (0);
}