Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/uvm Pull up revision 1.43 (requested by chs):



details:   https://anonhg.NetBSD.org/src/rev/07a8a12592de
branches:  netbsd-1-5
changeset: 492773:07a8a12592de
user:      he <he%NetBSD.org@localhost>
date:      Thu Feb 14 19:53:13 2002 +0000

description:
Pull up revision 1.43 (requested by chs):
  Make memory allocation failures during ``swapctl -a'' return an error
  instead of causing a panic.

diffstat:

 sys/uvm/uvm_swap.c |  29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diffs (57 lines):

diff -r 7d8af21d3ec1 -r 07a8a12592de sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c        Thu Feb 14 19:53:00 2002 +0000
+++ b/sys/uvm/uvm_swap.c        Thu Feb 14 19:53:13 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_swap.c,v 1.37.4.1 2000/11/13 20:55:38 tv Exp $     */
+/*     $NetBSD: uvm_swap.c,v 1.37.4.2 2002/02/14 19:53:13 he Exp $     */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -948,16 +948,20 @@
                printf("leaving %d pages of swap\n", size);
        }
 
+       /*
+        * try to add anons to reflect the new swap space.
+        */
+
+       error = uvm_anon_add(size);
+       if (error) {
+               goto bad;
+       }
+
        /*
         * add a ref to vp to reflect usage as a swap device.
         */
        vref(vp);
 
-       /*
-        * add anons to reflect the new swap space
-        */
-       uvm_anon_add(size);
-
        /*
         * now add the new swapdev to the drum and enable.
         */
@@ -970,12 +974,17 @@
        simple_unlock(&uvm.swap_data_lock);
        return (0);
 
+       /*
+        * failure: clean up and return error.
+        */
+
 bad:
-       /*
-        * failure: close device if necessary and return error.
-        */
-       if (vp != rootvp)
+       if (sdp->swd_ex) {
+               extent_destroy(sdp->swd_ex);
+       }
+       if (vp != rootvp) {
                (void)VOP_CLOSE(vp, FREAD|FWRITE, p->p_ucred, p);
+       }
        return (error);
 }
 



Home | Main Index | Thread Index | Old Index