summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_page_array.c
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2020-05-26 21:52:12 +0000
committerad <ad@NetBSD.org>2020-05-26 21:52:12 +0000
commit131eeedab3f65efaee3da79adcb32376f89bb160 (patch)
tree4c1605955345140b635c88b646f5f02f7a86f05f /sys/uvm/uvm_page_array.c
parent4c810be2fa2c412c9ccbf362d7147f2509d6388d (diff)
uvm_page_array_fill(): return ENOENT in all cases when nothing's left.
Diffstat (limited to 'sys/uvm/uvm_page_array.c')
-rw-r--r--sys/uvm/uvm_page_array.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/uvm/uvm_page_array.c b/sys/uvm/uvm_page_array.c
index bc0b5b332c2..b1a920bc2f1 100644
--- a/sys/uvm/uvm_page_array.c
+++ b/sys/uvm/uvm_page_array.c
@@ -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 @@ uvm_page_array_fill(struct uvm_page_array *ar, voff_t off, unsigned int nwant)
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 @@ uvm_page_array_fill(struct uvm_page_array *ar, voff_t off, unsigned int nwant)
* 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 @@ uvm_page_array_fill(struct uvm_page_array *ar, voff_t off, unsigned int nwant)
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 @@ uvm_page_array_fill(struct uvm_page_array *ar, voff_t off, unsigned int nwant)
}
}
#endif /* defined(DEBUG) */
- return 0;
+ return error;
}
/*