diff options
| author | Chuck Silvers <chs@FreeBSD.org> | 2020-07-17 23:10:35 +0000 |
|---|---|---|
| committer | Chuck Silvers <chs@FreeBSD.org> | 2020-07-17 23:10:35 +0000 |
| commit | 1bd12a3bb2be72a7d360402f489000dd337f6f3b (patch) | |
| tree | 1c1f80f0a0fe6fe4f868c393d47a0d93eb79bbba /sys/vm/vnode_pager.c | |
| parent | 4dfa06e114ed4332f8ea3b86f9963f475714da1e (diff) | |
Notes
Diffstat (limited to 'sys/vm/vnode_pager.c')
| -rw-r--r-- | sys/vm/vnode_pager.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 0f3ea7300654..fa9f4cab16f9 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -1139,6 +1139,21 @@ vnode_pager_generic_getpages_done(struct buf *bp) bp->b_data = unmapped_buf; } + /* + * If the read failed, we must free any read ahead/behind pages here. + * The requested pages are freed by the caller (for sync requests) + * or by the bp->b_pgiodone callback (for async requests). + */ + if (error != 0) { + VM_OBJECT_WLOCK(object); + for (i = 0; i < bp->b_pgbefore; i++) + vm_page_free_invalid(bp->b_pages[i]); + for (i = bp->b_npages - bp->b_pgafter; i < bp->b_npages; i++) + vm_page_free_invalid(bp->b_pages[i]); + VM_OBJECT_WUNLOCK(object); + return (error); + } + /* Read lock to protect size. */ VM_OBJECT_RLOCK(object); for (i = 0, tfoff = IDX_TO_OFF(bp->b_pages[0]->pindex); |
