FreeBSD/sys/kern/vfs_bio.c
/*
 * Page-granular truncation of an existing VMIO buffer.
 */
Page-granular truncation of an existing VMIO buffer.
Page - granular truncation of an existing VMIO buffer .
static void
vfs_vmio_truncate(struct buf *bp, int desiredpages)
{
	vm_object_t obj;
	vm_page_t m;
	int i;
	if (bp->b_npages == desiredpages)
		return;
	if (buf_mapped(bp)) {
		BUF_CHECK_MAPPED(bp);
		pmap_qremove((vm_offset_t)trunc_page((vm_offset_t)bp->b_data) +
		    (desiredpages << PAGE_SHIFT), bp->b_npages - desiredpages);
	} else
		BUF_CHECK_UNMAPPED(bp);
	obj = bp->b_bufobj->bo_object;
	if (obj != NULL)
		VM_OBJECT_WLOCK(obj);
	for (i = desiredpages; i < bp->b_npages; i++) {
		m = bp->b_pages[i];
		KASSERT(m != bogus_page, ("allocbuf: bogus page found"));
		bp->b_pages[i] = NULL;
		vfs_vmio_unwire(bp, m);
	}
	if (obj != NULL)
		VM_OBJECT_WUNLOCK(obj);
	bp->b_npages = desiredpages;
}
static void vfs_vmio_truncate ( struct buf * bp , int desiredpages ) { vm_object_t obj ; vm_page_t m ; int i ; if ( bp -> b_npages == desiredpages ) return ; if ( buf_mapped ( bp ) ) { BUF_CHECK_MAPPED ( bp ) ; pmap_qremove ( ( vm_offset_t ) trunc_page ( ( vm_offset_t ) bp -> b_data ) + ( desiredpages << PAGE_SHIFT ) , bp -> b_npages - desiredpages ) ; } else BUF_CHECK_UNMAPPED ( bp ) ; obj = bp -> b_bufobj -> bo_object ; if ( obj != NULL ) VM_OBJECT_WLOCK ( obj ) ; for ( i = desiredpages ; i < bp -> b_npages ; i ++ ) { m = bp -> b_pages [ i ] ; KASSERT ( m != bogus_page , ( " " ) ) ; bp -> b_pages [ i ] = NULL ; vfs_vmio_unwire ( bp , m ) ; } if ( obj != NULL ) VM_OBJECT_WUNLOCK ( obj ) ; bp -> b_npages = desiredpages ; }
Page-granular truncation of an existing VMIO buffer.
Page - granular truncation of an existing VMIO buffer .