Before invoking vnode operations on cache vnodes, acquire the vnode
locks of those vnodes. Probably, Coda should do the same lock sharing/ pass-through that is done for nullfs, but in the mean time this ensures that locks are adequately held to prevent corruption of data structures in the cache file system. Assuming most operations came from the top layer of Coda and weren't performed directly on the cache vnodes, in practice this corruption was relatively unlikely as the Coda vnode locks were ensuring exclusive access for most consumers. This causes WITNESS to squeal like a pig immediately when Coda is used, rather than waiting until file close; I noticed these problems because of the lack of said squealing. MFC after: 1 month
This commit is contained in:
parent
99a2317ed3
commit
efeac2fb25
@ -234,13 +234,16 @@ coda_open(struct vop_open_args *ap)
|
||||
}
|
||||
|
||||
/* Open the cache file. */
|
||||
vn_lock(vp, LK_EXCLUSIVE);
|
||||
error = VOP_OPEN(vp, flag, cred, td, NULL);
|
||||
if (error) {
|
||||
VOP_UNLOCK(vp, 0);
|
||||
printf("coda_open: VOP_OPEN on container failed %d\n", error);
|
||||
return (error);
|
||||
} else {
|
||||
(*vpp)->v_object = vp->v_object;
|
||||
}
|
||||
VOP_UNLOCK(vp, 0);
|
||||
/* grab (above) does this when it calls newvnode unless it's in the cache*/
|
||||
|
||||
return(error);
|
||||
@ -270,8 +273,9 @@ coda_close(struct vop_close_args *ap)
|
||||
}
|
||||
|
||||
if (cp->c_ovp) {
|
||||
vn_lock(cp->c_ovp, LK_EXCLUSIVE);
|
||||
VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
|
||||
vrele(cp->c_ovp);
|
||||
vput(cp->c_ovp);
|
||||
}
|
||||
#ifdef CODA_VERBOSE
|
||||
else printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
|
||||
@ -354,6 +358,7 @@ coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, int ioflag,
|
||||
/* Have UFS handle the call. */
|
||||
CODADEBUG(CODA_RDWR, myprintf(("indirect rdwr: fid = %s, refcnt = %d\n",
|
||||
coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount)); )
|
||||
vn_lock(cfvp, LK_EXCLUSIVE);
|
||||
if (rw == UIO_READ) {
|
||||
error = VOP_READ(cfvp, uiop, ioflag, cred);
|
||||
} else {
|
||||
@ -367,6 +372,7 @@ coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw, int ioflag,
|
||||
}
|
||||
}
|
||||
}
|
||||
VOP_UNLOCK(cfvp, 0);
|
||||
|
||||
if (error)
|
||||
MARK_INT_FAIL(CODA_RDWR_STATS);
|
||||
@ -1457,8 +1463,10 @@ coda_readdir(struct vop_readdir_args *ap)
|
||||
|
||||
/* Have UFS handle the call. */
|
||||
CODADEBUG(CODA_READDIR, myprintf(("indirect readdir: fid = %s, refcnt = %d\n", coda_f2s(&cp->c_fid), vp->v_usecount)); )
|
||||
vn_lock(cp->c_ovp, LK_EXCLUSIVE);
|
||||
error = VOP_READDIR(cp->c_ovp, uiop, cred, eofflag, ncookies,
|
||||
cookies);
|
||||
VOP_UNLOCK(cp->c_ovp, 0);
|
||||
|
||||
if (error)
|
||||
MARK_INT_FAIL(CODA_READDIR_STATS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user