Change vnode_pager_generic_getpages() so that it does not panic if the
given file is sparse. Instead, it zeroes the requested page. Reviewed by: tegge PR: kern/98116 MFC after: 3 days
This commit is contained in:
parent
8ea32c5e36
commit
f4f83da02d
@ -695,7 +695,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
|
||||
vm_offset_t kva;
|
||||
off_t foff, tfoff, nextoff;
|
||||
int i, j, size, bsize, first;
|
||||
daddr_t firstaddr;
|
||||
daddr_t firstaddr, reqblock;
|
||||
struct bufobj *bo;
|
||||
int runpg;
|
||||
int runend;
|
||||
@ -724,7 +724,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
|
||||
/*
|
||||
* if we can't bmap, use old VOP code
|
||||
*/
|
||||
if (VOP_BMAP(vp, 0, &bo, 0, NULL, NULL)) {
|
||||
if (VOP_BMAP(vp, foff / bsize, &bo, &reqblock, NULL, NULL)) {
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_page_lock_queues();
|
||||
for (i = 0; i < count; i++)
|
||||
@ -770,6 +770,17 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
|
||||
vm_page_unlock_queues();
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
return VM_PAGER_OK;
|
||||
} else if (reqblock == -1) {
|
||||
pmap_zero_page(m[reqpage]);
|
||||
vm_page_undirty(m[reqpage]);
|
||||
m[reqpage]->valid = VM_PAGE_BITS_ALL;
|
||||
vm_page_lock_queues();
|
||||
for (i = 0; i < count; i++)
|
||||
if (i != reqpage)
|
||||
vm_page_free(m[i]);
|
||||
vm_page_unlock_queues();
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
return (VM_PAGER_OK);
|
||||
}
|
||||
m[reqpage]->valid = 0;
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
|
Loading…
x
Reference in New Issue
Block a user