diff options
author | rmacklem <rmacklem@FreeBSD.org> | 2010-08-04 01:19:11 +0000 |
---|---|---|
committer | rmacklem <rmacklem@FreeBSD.org> | 2010-08-04 01:19:11 +0000 |
commit | 552daf39606c3a8c7799c7a9e57409fa4ef0a4cb (patch) | |
tree | 0275d21eb25c1fc17f0e611e98b2eb125cf3acb2 /sys/nfsclient | |
parent | d29205b57887271ee0fb431f18c333498649cf4c (diff) | |
download | FreeBSD-src-552daf39606c3a8c7799c7a9e57409fa4ef0a4cb.zip FreeBSD-src-552daf39606c3a8c7799c7a9e57409fa4ef0a4cb.tar.gz |
Add some mutex locking on the nfsnode to the regular NFS client.
Reviewed by: jhb
Diffstat (limited to 'sys/nfsclient')
-rw-r--r-- | sys/nfsclient/nfs_node.c | 4 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vnops.c | 11 |
2 files changed, 10 insertions, 5 deletions
diff --git a/sys/nfsclient/nfs_node.c b/sys/nfsclient/nfs_node.c index 522bc44..947beed 100644 --- a/sys/nfsclient/nfs_node.c +++ b/sys/nfsclient/nfs_node.c @@ -193,12 +193,14 @@ nfs_inactive(struct vop_inactive_args *ap) np = VTONFS(ap->a_vp); if (prtactive && vrefcnt(ap->a_vp) != 0) vprint("nfs_inactive: pushing active", ap->a_vp); + mtx_lock(&np->n_mtx); if (ap->a_vp->v_type != VDIR) { sp = np->n_sillyrename; np->n_sillyrename = NULL; } else sp = NULL; if (sp) { + mtx_unlock(&np->n_mtx); (void)nfs_vinvalbuf(ap->a_vp, 0, td, 1); /* * Remove the silly file that was rename'd earlier @@ -207,8 +209,10 @@ nfs_inactive(struct vop_inactive_args *ap) crfree(sp->s_cred); vrele(sp->s_dvp); free((caddr_t)sp, M_NFSREQ); + mtx_lock(&np->n_mtx); } np->n_flag &= NMODIFIED; + mtx_unlock(&np->n_mtx); return (0); } diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 015a1de..f1e173d 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -521,7 +521,7 @@ nfs_open(struct vop_open_args *ap) */ mtx_lock(&np->n_mtx); if (np->n_flag & NMODIFIED) { - mtx_unlock(&np->n_mtx); + mtx_unlock(&np->n_mtx); error = nfs_vinvalbuf(vp, V_SAVE, ap->a_td, 1); if (error == EINTR || error == EIO) return (error); @@ -536,9 +536,8 @@ nfs_open(struct vop_open_args *ap) return (error); mtx_lock(&np->n_mtx); np->n_mtime = vattr.va_mtime; - mtx_unlock(&np->n_mtx); } else { - mtx_unlock(&np->n_mtx); + mtx_unlock(&np->n_mtx); error = VOP_GETATTR(vp, &vattr, ap->a_cred); if (error) return (error); @@ -554,22 +553,22 @@ nfs_open(struct vop_open_args *ap) mtx_lock(&np->n_mtx); np->n_mtime = vattr.va_mtime; } - mtx_unlock(&np->n_mtx); } /* * If the object has >= 1 O_DIRECT active opens, we disable caching. */ if (nfs_directio_enable && (fmode & O_DIRECT) && (vp->v_type == VREG)) { if (np->n_directio_opens == 0) { + mtx_unlock(&np->n_mtx); error = nfs_vinvalbuf(vp, V_SAVE, ap->a_td, 1); if (error) return (error); mtx_lock(&np->n_mtx); np->n_flag |= NNONCACHE; - mtx_unlock(&np->n_mtx); } np->n_directio_opens++; } + mtx_unlock(&np->n_mtx); vnode_create_vobject(vp, vattr.va_size, ap->a_td); return (0); } @@ -1745,7 +1744,9 @@ nfs_remove(struct vop_remove_args *ap) error = 0; } else if (!np->n_sillyrename) error = nfs_sillyrename(dvp, vp, cnp); + mtx_lock(&np->n_mtx); np->n_attrstamp = 0; + mtx_unlock(&np->n_mtx); KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp); return (error); } |