diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2002-02-22 20:19:15 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2002-02-22 20:19:15 +0000 |
commit | 5a29bdc1be02dab7dd8662e3901f1cad8f0b7c39 (patch) | |
tree | e6e6708919c80367ebb5bbac7b42711e282415ba /sys/nfs/nfs_node.c | |
parent | fba59d7e033da21befb25cc10849261322d0f017 (diff) |
More locking in the NFS code
Diffstat (limited to 'sys/nfs/nfs_node.c')
-rw-r--r-- | sys/nfs/nfs_node.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index 9d858658dc7..ba0156fb7ab 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_node.c,v 1.21 2002/01/23 00:39:48 art Exp $ */ +/* $OpenBSD: nfs_node.c,v 1.22 2002/02/22 20:19:14 csapuntz Exp $ */ /* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */ /* @@ -145,6 +145,8 @@ loop: vp = nvp; np = pool_get(&nfs_node_pool, PR_WAITOK); bzero((caddr_t)np, sizeof *np); + lockinit(&np->n_lock, PINOD, "nfsvlock", 0, 0); + lockmgr(&np->n_lock, LK_EXCLUSIVE, 0, p); vp->v_data = np; np->n_vnode = vp; @@ -194,19 +196,32 @@ nfs_inactive(v) np->n_sillyrename = (struct sillyrename *)0; } else sp = (struct sillyrename *)0; - if (sp) { - /* - * Remove the silly file that was rename'd earlier - */ + + /* + * Remove the silly file that was rename'd earlier + */ + if (sp) (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1); - nfs_removeit(sp); + + np->n_flag &= (NMODIFIED | NFLUSHINPROG | NFLUSHWANT); + + VOP_UNLOCK(ap->a_vp, 0, ap->a_p); + + if (sp) { + /* Note: sp->s_dvp may already be locked somewhere up in + the call stack as _inactive is called from many places + in the code. Thus, this call below requires that + recursive locks be enabled in vn_lock. + */ + int error = vn_lock(sp->s_dvp, LK_EXCLUSIVE, ap->a_p); + if (error == 0) { + nfs_removeit(sp); + vput(sp->s_dvp); + } crfree(sp->s_cred); - vrele(sp->s_dvp); - FREE((caddr_t)sp, M_NFSREQ); + FREE((caddr_t)sp, M_NFSREQ); } - np->n_flag &= (NMODIFIED | NFLUSHINPROG | NFLUSHWANT); - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); return (0); } @@ -256,4 +271,3 @@ nfs_reclaim(v) vp->v_data = NULL; return (0); } - |