summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_swap.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-11-07 02:55:52 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-11-07 02:55:52 +0000
commitcc211db56384036a7e588d635b51f11a921dd54e (patch)
tree901408843f90b295b4287da701ff27afbb5c876c /sys/uvm/uvm_swap.c
parent253f31ab10d5b90c1d64de9c7dec0385fa0c9f7c (diff)
Another sync of uvm to NetBSD. Just minor fiddling, no major changes.
Diffstat (limited to 'sys/uvm/uvm_swap.c')
-rw-r--r--sys/uvm/uvm_swap.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index ada8eee8464..e4bd678b122 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvm_swap.c,v 1.37 2001/11/06 01:35:04 art Exp $ */
-/* $NetBSD: uvm_swap.c,v 1.38 2000/06/27 17:29:35 mrg Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.38 2001/11/07 02:55:50 art Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -783,6 +783,7 @@ sys_swapctl(p, v, retval)
error = 0; /* assume no error */
switch(SCARG(uap, cmd)) {
+
case SWAP_DUMPDEV:
if (vp->v_type != VBLK) {
error = ENOTBLK;
@@ -869,12 +870,6 @@ sys_swapctl(p, v, retval)
free(sdp, M_VMSWAP);
break;
}
-
- /*
- * got it! now add a second reference to vp so that
- * we keep a reference to the vnode after we return.
- */
- vref(vp);
break;
case SWAP_OFF:
@@ -908,9 +903,10 @@ sys_swapctl(p, v, retval)
}
/*
- * done! use vput to drop our reference and unlock
+ * done! release the ref gained by namei() and unlock.
*/
vput(vp);
+
out:
lockmgr(&swap_syscall_lock, LK_RELEASE, NULL, p);
@@ -1092,6 +1088,11 @@ swap_on(p, sdp)
printf("leaving %d pages of swap\n", size);
}
+ /*
+ * add a ref to vp to reflect usage as a swap device.
+ */
+ vref(vp);
+
/*
* add anons to reflect the new swap space
*/
@@ -1109,9 +1110,8 @@ swap_on(p, sdp)
sdp->swd_npages = size;
sdp->swd_flags &= ~SWF_FAKE; /* going live */
sdp->swd_flags |= (SWF_INUSE|SWF_ENABLE);
- simple_unlock(&uvm.swap_data_lock);
uvmexp.swpages += size;
-
+ simple_unlock(&uvm.swap_data_lock);
return (0);
bad:
@@ -1167,17 +1167,17 @@ swap_off(p, sdp)
#endif
/*
- * done with the vnode.
+ * done with the vnode and saved creds.
+ * drop our ref on the vnode before calling VOP_CLOSE()
+ * so that spec_close() can tell if this is the last close.
*/
if (sdp->swd_vp->v_type == VREG) {
crfree(sdp->swd_cred);
}
+ vrele(sdp->swd_vp);
if (sdp->swd_vp != rootvp) {
(void) VOP_CLOSE(sdp->swd_vp, FREAD|FWRITE, p->p_ucred, p);
}
- if (sdp->swd_vp) {
- vrele(sdp->swd_vp);
- }
/* remove anons from the system */
uvm_anon_remove(sdp->swd_npages);