rump: handle error case in vm_vfs rump layer

Fixes #2677
This commit is contained in:
Alexander Boettcher 2018-02-12 15:24:26 +01:00 committed by Norman Feske
parent ff7e8086d7
commit 21b2b7e1ea
3 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,68 @@
--- src/lib/dde_rump/src/sys/rump/librump/rumpvfs/vm_vfs.c
+++ src/lib/dde_rump/src/sys/rump/librump/rumpvfs/vm_vfs.c
@@ -49,6 +49,7 @@
struct vm_page **pgs;
vaddr_t va;
int pageout = 0;
+ bool const write = BUF_ISWRITE(bp);
KASSERT(npages > 0);
pgs = kmem_alloc(npages * sizeof(*pgs), KM_SLEEP);
@@ -64,8 +65,47 @@
KASSERT(uobj == pgs[i]->uobject);
}
+ if (bp->b_error) {
+ if (!write) {
+ pgs[i]->flags |= PG_RELEASED;
+ continue;
+ } else if (bp->b_error == ENOMEM) {
+ if (pgs[i]->flags & PG_PAGEOUT) {
+ pageout++;
+ pgs[i]->flags &= ~PG_PAGEOUT;
+ }
+ pgs[i]->flags &= ~PG_CLEAN;
+
+ mutex_enter(&uvm_pageqlock);
+ uvm_pageactivate(pgs[i]);
+ mutex_exit(&uvm_pageqlock);
+ }
+ }
+
+ /*
+ * if the page is PG_FAKE, this must have been a read to
+ * initialize the page. clear PG_FAKE and activate the page.
+ * we must also clear the pmap "modified" flag since it may
+ * still be set from the page's previous identity.
+ */
+
+ if ((pgs[i]->flags & PG_FAKE)) {
+ KASSERT(!write);
+ pgs[i]->flags &= ~PG_FAKE;
+ KASSERT((pgs[i]->flags & PG_CLEAN) != 0);
+
+#if defined(READAHEAD_STATS)
+ pgs[i]->pqflags |= PQ_READAHEAD;
+ uvm_ra_total.ev_count++;
+#endif /* defined(READAHEAD_STATS) */
+
+ mutex_enter(&uvm_pageqlock);
+ uvm_pageenqueue(pgs[i]);
+ pmap_clear_modify(pgs[i]);
+ mutex_exit(&uvm_pageqlock);
+ }
+
if (pgs[i]->flags & PG_PAGEOUT) {
- KASSERT((pgs[i]->flags & PG_FAKE) == 0);
pageout++;
pgs[i]->flags &= ~PG_PAGEOUT;
pgs[i]->flags |= PG_RELEASED;
@@ -81,7 +121,7 @@
uvm_pagermapout((vaddr_t)bp->b_data, npages);
uvm_pageout_done(pageout);
- if (BUF_ISWRITE(bp) && (bp->b_cflags & BC_AGE) != 0) {
+ if (write && (bp->b_cflags & BC_AGE) != 0) {
mutex_enter(bp->b_objlock);
vwakeup(bp);
mutex_exit(bp->b_objlock);

View File

@ -1 +1 @@
88651ddaf056424fee8354603d57c8fd34ef4e05
e82aa761750a0a1e76e886fa7ad37da043afe931

View File

@ -4,3 +4,5 @@ DOWNLOADS := rump.git
URL(rump) := https://github.com/ssumpf/rump.git
DIR(rump) := src/lib/dde_rump
REV(rump) := 206ffa06cedd0779af0043997fd182b00ff4688c
PATCHES := patches/vm_vfs.patch