diff options
author | kib <kib@FreeBSD.org> | 2012-08-04 18:16:43 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-08-04 18:16:43 +0000 |
commit | 4259905d3171a4cdd087436ff1c17eed74830b60 (patch) | |
tree | 6ac153a747b185932191fda117e5d5ee749c7fd6 /sys/vm/vm_page.c | |
parent | 92640c3632022e41b9cbf19c91dc943056036413 (diff) | |
download | FreeBSD-src-4259905d3171a4cdd087436ff1c17eed74830b60.zip FreeBSD-src-4259905d3171a4cdd087436ff1c17eed74830b60.tar.gz |
Reduce code duplication and exposure of direct access to struct
vm_page oflags by providing helper function
vm_page_readahead_finish(), which handles completed reads for pages
with indexes other then the requested one, for VOP_GETPAGES().
Reviewed by: alc
MFC after: 1 week
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r-- | sys/vm/vm_page.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 53353e9..b679290 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -695,6 +695,39 @@ vm_page_free_zero(vm_page_t m) } /* + * Unbusy and handle the page queueing for a page from the VOP_GETPAGES() + * array which is not the request page. + */ +void +vm_page_readahead_finish(vm_page_t m, int error) +{ + + if (error == 0) { + /* + * Since the page is not the requested page, whether + * it should be activated or deactivated is not + * obvious. Empirical results have shown that + * deactivating the page is usually the best choice, + * unless the page is wanted by another thread. + */ + if (m->oflags & VPO_WANTED) { + vm_page_lock(m); + vm_page_activate(m); + vm_page_unlock(m); + } else { + vm_page_lock(m); + vm_page_deactivate(m); + vm_page_unlock(m); + } + vm_page_wakeup(m); + } else { + vm_page_lock(m); + vm_page_free(m); + vm_page_unlock(m); + } +} + +/* * vm_page_sleep: * * Sleep and release the page and page queues locks. |