Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm When retiring a swap device with marked bad blocks o...



details:   https://anonhg.NetBSD.org/src/rev/f1c3124c3316
branches:  trunk
changeset: 551059:f1c3124c3316
user:      pk <pk%NetBSD.org@localhost>
date:      Thu Aug 28 13:12:17 2003 +0000

description:
When retiring a swap device with marked bad blocks on it we should update
the `# swap page in use' and `# swap page only' counters.  However, at the
time of swap device removal we can no longer figure out how many of the
bad swap pages are actually also `swap only' pages.

So, on swap I/O errors arrange things to not include the bad swap pages in
the `swpgonly' counter as follows: uvm_swap_markbad() decrements `swpgonly'
by the number of bad pages, and the various VM object deallocation routines
do not decrement `swpgonly' for swap slots marked as SWSLOT_BAD.

diffstat:

 sys/uvm/uvm_anon.c    |   6 +++---
 sys/uvm/uvm_aobj.c    |   8 ++++----
 sys/uvm/uvm_km.c      |   6 +++---
 sys/uvm/uvm_pager.c   |  28 ++++++++++++++++++++++++----
 sys/uvm/uvm_pdaemon.c |  22 +++++++++++++++-------
 sys/uvm/uvm_swap.c    |   8 ++++++--
 6 files changed, 55 insertions(+), 23 deletions(-)

diffs (252 lines):

diff -r 12398b4a65b4 -r f1c3124c3316 sys/uvm/uvm_anon.c
--- a/sys/uvm/uvm_anon.c        Thu Aug 28 12:28:34 2003 +0000
+++ b/sys/uvm/uvm_anon.c        Thu Aug 28 13:12:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_anon.c,v 1.25 2003/08/11 16:54:10 pk Exp $ */
+/*     $NetBSD: uvm_anon.c,v 1.26 2003/08/28 13:12:17 pk Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.25 2003/08/11 16:54:10 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.26 2003/08/28 13:12:17 pk Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -261,7 +261,7 @@
                                    "freed now!", anon, pg, 0, 0);
                }
        }
-       if (pg == NULL && anon->an_swslot != 0) {
+       if (pg == NULL && anon->an_swslot > 0) {
                /* this page is no longer only in swap. */
                simple_lock(&uvm.swap_data_lock);
                KASSERT(uvmexp.swpgonly > 0);
diff -r 12398b4a65b4 -r f1c3124c3316 sys/uvm/uvm_aobj.c
--- a/sys/uvm/uvm_aobj.c        Thu Aug 28 12:28:34 2003 +0000
+++ b/sys/uvm/uvm_aobj.c        Thu Aug 28 13:12:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_aobj.c,v 1.59 2003/08/11 16:54:11 pk Exp $ */
+/*     $NetBSD: uvm_aobj.c,v 1.60 2003/08/28 13:12:18 pk Exp $ */
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.59 2003/08/11 16:54:11 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.60 2003/08/28 13:12:18 pk Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -417,7 +417,7 @@
                                for (j = 0; j < UAO_SWHASH_CLUSTER_SIZE; j++) {
                                        int slot = elt->slots[j];
 
-                                       if (slot == 0) {
+                                       if (slot > 0) {
                                                continue;
                                        }
                                        uvm_swap_free(slot, 1);
@@ -439,7 +439,7 @@
                for (i = 0; i < aobj->u_pages; i++) {
                        int slot = aobj->u_swslots[i];
 
-                       if (slot) {
+                       if (slot > 0) {
                                uvm_swap_free(slot, 1);
                                swpgonlydelta++;
                        }
diff -r 12398b4a65b4 -r f1c3124c3316 sys/uvm/uvm_km.c
--- a/sys/uvm/uvm_km.c  Thu Aug 28 12:28:34 2003 +0000
+++ b/sys/uvm/uvm_km.c  Thu Aug 28 13:12:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_km.c,v 1.63 2003/08/11 16:33:31 pk Exp $   */
+/*     $NetBSD: uvm_km.c,v 1.64 2003/08/28 13:12:18 pk Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -134,7 +134,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.63 2003/08/11 16:33:31 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.64 2003/08/28 13:12:18 pk Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -301,7 +301,7 @@
                 */
 
                if (pg == NULL &&
-                   uao_find_swslot(uobj, curoff >> PAGE_SHIFT) != 0) {
+                   uao_find_swslot(uobj, curoff >> PAGE_SHIFT) > 0) {
                        swpgonlydelta++;
                }
                uao_dropswap(uobj, curoff >> PAGE_SHIFT);
diff -r 12398b4a65b4 -r f1c3124c3316 sys/uvm/uvm_pager.c
--- a/sys/uvm/uvm_pager.c       Thu Aug 28 12:28:34 2003 +0000
+++ b/sys/uvm/uvm_pager.c       Thu Aug 28 13:12:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_pager.c,v 1.60 2003/04/23 00:55:22 tls Exp $       */
+/*     $NetBSD: uvm_pager.c,v 1.61 2003/08/28 13:12:19 pk Exp $        */
 
 /*
  *
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.60 2003/04/23 00:55:22 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pager.c,v 1.61 2003/08/28 13:12:19 pk Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -363,6 +363,7 @@
                 */
 
                if (error) {
+                       int slot;
                        if (!write) {
                                pg->flags |= PG_RELEASED;
                                continue;
@@ -373,6 +374,20 @@
                                }
                                pg->flags &= ~PG_CLEAN;
                                uvm_pageactivate(pg);
+                               slot = 0;
+                       } else
+                               slot = SWSLOT_BAD;
+
+                       if (swap) {
+                               if (pg->uobject != NULL) {
+                                       KASSERT(uao_set_swslot(pg->uobject,
+                                               pg->offset >> PAGE_SHIFT,
+                                               slot) == swslot + i);
+                               } else {
+                                       KASSERT(pg->uanon->an_swslot ==
+                                               swslot + i);
+                                       pg->uanon->an_swslot = slot;
+                               }
                        }
                }
 
@@ -421,11 +436,16 @@
                /* these pages are now only in swap. */
                simple_lock(&uvm.swap_data_lock);
                KASSERT(uvmexp.swpgonly + npages <= uvmexp.swpginuse);
-               uvmexp.swpgonly += npages;
+               if (error != ENOMEM)
+                       uvmexp.swpgonly += npages;
                simple_unlock(&uvm.swap_data_lock);
                if (error) {
-                       uvm_swap_markbad(swslot, npages);
+                       if (error != ENOMEM)
+                               uvm_swap_markbad(swslot, npages);
+                       else
+                               uvm_swap_free(swslot, npages);
                }
+               uvmexp.pdpending--;
        }
        s = splbio();
        if (write && (bp->b_flags & B_AGE) != 0) {
diff -r 12398b4a65b4 -r f1c3124c3316 sys/uvm/uvm_pdaemon.c
--- a/sys/uvm/uvm_pdaemon.c     Thu Aug 28 12:28:34 2003 +0000
+++ b/sys/uvm/uvm_pdaemon.c     Thu Aug 28 13:12:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_pdaemon.c,v 1.52 2003/08/11 16:33:32 pk Exp $      */
+/*     $NetBSD: uvm_pdaemon.c,v 1.53 2003/08/28 13:12:19 pk Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.52 2003/08/11 16:33:32 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.53 2003/08/28 13:12:19 pk Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -554,6 +554,7 @@
                                p->flags &= ~(PG_CLEAN);
                        }
                        if (p->flags & PG_CLEAN) {
+                               int slot;
                                uvm_pagefree(p);
                                uvmexp.pdfreed++;
 
@@ -566,14 +567,21 @@
                                if (anon) {
                                        KASSERT(anon->an_swslot != 0);
                                        anon->u.an_page = NULL;
+                                       slot = anon->an_swslot;
+                               } else {
+                                       slot = uao_find_swslot(uobj,
+                                               p->offset >> PAGE_SHIFT);
                                }
                                simple_unlock(slock);
 
-                               /* this page is now only in swap. */
-                               simple_lock(&uvm.swap_data_lock);
-                               KASSERT(uvmexp.swpgonly < uvmexp.swpginuse);
-                               uvmexp.swpgonly++;
-                               simple_unlock(&uvm.swap_data_lock);
+                               if (slot > 0) {
+                                       /* this page is now only in swap. */
+                                       simple_lock(&uvm.swap_data_lock);
+                                       KASSERT(uvmexp.swpgonly <
+                                               uvmexp.swpginuse);
+                                       uvmexp.swpgonly++;
+                                       simple_unlock(&uvm.swap_data_lock);
+                               }
                                continue;
                        }
 
diff -r 12398b4a65b4 -r f1c3124c3316 sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c        Thu Aug 28 12:28:34 2003 +0000
+++ b/sys/uvm/uvm_swap.c        Thu Aug 28 13:12:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_swap.c,v 1.81 2003/08/11 16:33:30 pk Exp $ */
+/*     $NetBSD: uvm_swap.c,v 1.82 2003/08/28 13:12:20 pk Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.81 2003/08/11 16:33:30 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.82 2003/08/28 13:12:20 pk Exp $");
 
 #include "fs_nfs.h"
 #include "opt_uvmhist.h"
@@ -1051,6 +1051,7 @@
 
        simple_lock(&uvm.swap_data_lock);
        uvmexp.swpages -= npages;
+       uvmexp.swpginuse -= sdp->swd_npgbad;
 
        if (swaplist_find(sdp->swd_vp, 1) == NULL)
                panic("swap_off: swapdev not in list");
@@ -1553,6 +1554,7 @@
 
        simple_lock(&uvm.swap_data_lock);
        sdp = swapdrum_getsdp(startslot);
+       KASSERT(sdp != NULL);
 
        /*
         * we just keep track of how many pages have been marked bad
@@ -1561,6 +1563,8 @@
         * one swap device.
         */
 
+       KASSERT(uvmexp.swpgonly >= nslots);
+       uvmexp.swpgonly -= nslots;
        sdp->swd_npgbad += nslots;
        UVMHIST_LOG(pdhist, "now %d bad", sdp->swd_npgbad, 0,0,0);
        simple_unlock(&uvm.swap_data_lock);



Home | Main Index | Thread Index | Old Index