Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm uvm_page_array_fill(): return ENOENT in all cases wh...



details:   https://anonhg.NetBSD.org/src/rev/fe777042e1c4
branches:  trunk
changeset: 933542:fe777042e1c4
user:      ad <ad%NetBSD.org@localhost>
date:      Tue May 26 21:52:12 2020 +0000

description:
uvm_page_array_fill(): return ENOENT in all cases when nothing's left.

diffstat:

 sys/uvm/uvm_page_array.c |  17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diffs (66 lines):

diff -r 98e9a7faea29 -r fe777042e1c4 sys/uvm/uvm_page_array.c
--- a/sys/uvm/uvm_page_array.c  Tue May 26 21:49:29 2020 +0000
+++ b/sys/uvm/uvm_page_array.c  Tue May 26 21:52:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page_array.c,v 1.8 2020/05/25 22:01:26 ad Exp $    */
+/*     $NetBSD: uvm_page_array.c,v 1.9 2020/05/26 21:52:12 ad Exp $    */
 
 /*-
  * Copyright (c)2011 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page_array.c,v 1.8 2020/05/25 22:01:26 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page_array.c,v 1.9 2020/05/26 21:52:12 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -140,6 +140,7 @@
        const int flags = ar->ar_flags;
        const bool dense = (flags & UVM_PAGE_ARRAY_FILL_DENSE) != 0;
        const bool backward = (flags & UVM_PAGE_ARRAY_FILL_BACKWARD) != 0;
+       int error = 0;
 
        if (nwant != 0 && nwant < maxpages) {
                maxpages = nwant;
@@ -172,8 +173,7 @@
                         * if dense or looking for tagged entries (or
                         * working backwards), fail right away.
                         */
-                       uvm_page_array_clear(ar);
-                       return ENOENT;
+                       npages = 0;
                } else {
                        /*
                         * there's nothing else to be found with the current
@@ -187,17 +187,16 @@
                        npages = 1;
                        ar->ar_pages[0] = NULL;
                }
+               error = ENOENT;
        }
        KASSERT(npages <= maxpages);
        ar->ar_npages = npages;
        ar->ar_idx = 0;
 #if defined(DEBUG)
-       for (i = 0; i < ar->ar_npages; i++) {
+       for (i = 0; error == 0 && i < ar->ar_npages; i++) {
                struct vm_page * const pg = ar->ar_pages[i];
 
-               if (pg == NULL) {
-                       continue;
-               }
+               KASSERT(pg != NULL);
                KDASSERT(pg->uobject == uobj);
                if (backward) {
                        KDASSERT(pg->offset <= off);
@@ -210,7 +209,7 @@
                }
        }
 #endif /* defined(DEBUG) */
-       return 0;
+       return error;
 }
 
 /*



Home | Main Index | Thread Index | Old Index