diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-01 20:34:11 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-11-01 20:34:11 +0000 |
commit | 46c89706e243f21bc846a7e496ab5ce4db1768e8 (patch) | |
tree | e102318d5e077ab6ae6ec4102c459808f99728e7 /sys | |
parent | 55ec2536ce6c0d635a791013b3a21bd430cfb4c9 (diff) |
change vrele() to return an int. if it returns 0, it can gaurantee that
it did not sleep. this is used to avoid checkdirs() to avoid having
to restart the allproc walk every time through
idea from tedu, ok thib pedro
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_subr.c | 10 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 13 | ||||
-rw-r--r-- | sys/sys/vnode.h | 4 |
3 files changed, 16 insertions, 11 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 34451d2e95f..e0a3e816d4c 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.173 2008/07/05 12:48:03 thib Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.174 2008/11/01 20:34:09 deraadt Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -690,8 +690,9 @@ vput(struct vnode *vp) /* * Vnode release - use for active VNODES. * If count drops to zero, call inactive routine and return to freelist. + * Returns 0 if it did not sleep. */ -void +int vrele(struct vnode *vp) { struct proc *p = curproc; @@ -708,7 +709,7 @@ vrele(struct vnode *vp) #endif vp->v_usecount--; if (vp->v_usecount > 0) { - return; + return (0); } #ifdef DIAGNOSTIC @@ -722,13 +723,14 @@ vrele(struct vnode *vp) #ifdef DIAGNOSTIC vprint("vrele: cannot lock", vp); #endif - return; + return (1); } VOP_INACTIVE(vp, p); if (vp->v_usecount == 0 && !(vp->v_bioflag & VBIOONFREELIST)) vputonfreelist(vp); + return (1); } /* Page or buffer structure gets a reference. */ diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 021bd8414f9..5f53eaeefdc 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.150 2008/10/31 16:49:17 deraadt Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.151 2008/11/01 20:34:09 deraadt Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -325,6 +325,7 @@ checkdirs(struct vnode *olddp) struct filedesc *fdp; struct vnode *newdp; struct proc *p; + int slept; if (olddp->v_usecount == 1) return; @@ -334,16 +335,18 @@ again: LIST_FOREACH(p, &allproc, p_list) { fdp = p->p_fd; if (fdp->fd_cdir == olddp) { - vrele(fdp->fd_cdir); + slept = vrele(fdp->fd_cdir); VREF(newdp); fdp->fd_cdir = newdp; - goto again; + if (slept) + goto again; } if (fdp->fd_rdir == olddp) { - vrele(fdp->fd_rdir); + slept = vrele(fdp->fd_rdir); VREF(newdp); fdp->fd_rdir = newdp; - goto again; + if (slept) + goto again; } } if (rootvnode == olddp) { diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 018aa166d95..59a4d2ff7a4 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.95 2008/06/09 23:38:37 millert Exp $ */ +/* $OpenBSD: vnode.h,v 1.96 2008/11/01 20:33:34 deraadt Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -365,7 +365,7 @@ int vwaitforio(struct vnode *, int, char *, int); void vwakeup(struct vnode *); void vput(struct vnode *); int vrecycle(struct vnode *, struct proc *); -void vrele(struct vnode *); +int vrele(struct vnode *); void vref(struct vnode *); void vprint(char *, struct vnode *); void copy_statfs_info(struct statfs *, const struct mount *); |