Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm in swap_off(), reverse the order of vrele() and VOP_...



details:   https://anonhg.NetBSD.org/src/rev/1b88432602df
branches:  trunk
changeset: 499151:1b88432602df
user:      chs <chs%NetBSD.org@localhost>
date:      Mon Nov 13 14:50:55 2000 +0000

description:
in swap_off(), reverse the order of vrele() and VOP_CLOSE() so that
devices will actually be notified if this is the last close.
this allows raidframe swap devices to be marked clean.
also, move the corresponding vref() into swap_on() for symmetry
and improve some comments.

diffstat:

 sys/uvm/uvm_swap.c |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (68 lines):

diff -r 4eb5433f9fa0 -r 1b88432602df sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c        Mon Nov 13 14:47:14 2000 +0000
+++ b/sys/uvm/uvm_swap.c        Mon Nov 13 14:50:55 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_swap.c,v 1.38 2000/06/27 17:29:35 mrg Exp $        */
+/*     $NetBSD: uvm_swap.c,v 1.39 2000/11/13 14:50:55 chs Exp $        */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -729,12 +729,6 @@
                        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:
@@ -768,9 +762,10 @@
        }
 
        /*
-        * 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);
 
@@ -952,6 +947,11 @@
                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
         */
@@ -1022,17 +1022,17 @@
 #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);



Home | Main Index | Thread Index | Old Index