FreeBSD/sys/kern/vfs_bio.c
/*
 * Returns true if no I/O is needed to access the
 * associated VM object.  This is like incore except
 * it also hunts around in the VM system for the data.
 */
Returns true if no I/O is needed to access the
associated VM object.  This is like incore except
it also hunts around in the VM system for the data.
Returns true if no I / O is needed to access the associated VM object . This is like incore except it also hunts around in the VM system for the data .
static int
inmem(struct vnode * vp, daddr_t blkno)
{
	vm_object_t obj;
	vm_offset_t toff, tinc, size;
	vm_page_t m;
	vm_ooffset_t off;
	ASSERT_VOP_LOCKED(vp, "inmem");
	if (incore(&vp->v_bufobj, blkno))
		return 1;
	if (vp->v_mount == NULL)
		return 0;
	obj = vp->v_object;
	if (obj == NULL)
		return (0);
	size = PAGE_SIZE;
	if (size > vp->v_mount->mnt_stat.f_iosize)
		size = vp->v_mount->mnt_stat.f_iosize;
	off = (vm_ooffset_t)blkno * (vm_ooffset_t)vp->v_mount->mnt_stat.f_iosize;
	VM_OBJECT_RLOCK(obj);
	for (toff = 0; toff < vp->v_mount->mnt_stat.f_iosize; toff += tinc) {
		m = vm_page_lookup(obj, OFF_TO_IDX(off + toff));
		if (!m)
			goto notinmem;
		tinc = size;
		if (tinc > PAGE_SIZE - ((toff + off) & PAGE_MASK))
			tinc = PAGE_SIZE - ((toff + off) & PAGE_MASK);
		if (vm_page_is_valid(m,
		    (vm_offset_t) ((toff + off) & PAGE_MASK), tinc) == 0)
			goto notinmem;
	}
	VM_OBJECT_RUNLOCK(obj);
	return 1;
notinmem:
	VM_OBJECT_RUNLOCK(obj);
	return (0);
}
static int inmem ( struct vnode * vp , daddr_t blkno ) { vm_object_t obj ; vm_offset_t toff , tinc , size ; vm_page_t m ; vm_ooffset_t off ; ASSERT_VOP_LOCKED ( vp , " " ) ; if ( incore ( & vp -> v_bufobj , blkno ) ) return 1 ; if ( vp -> v_mount == NULL ) return 0 ; obj = vp -> v_object ; if ( obj == NULL ) return ( 0 ) ; size = PAGE_SIZE ; if ( size > vp -> v_mount -> mnt_stat . f_iosize ) size = vp -> v_mount -> mnt_stat . f_iosize ; off = ( vm_ooffset_t ) blkno * ( vm_ooffset_t ) vp -> v_mount -> mnt_stat . f_iosize ; VM_OBJECT_RLOCK ( obj ) ; for ( toff = 0 ; toff < vp -> v_mount -> mnt_stat . f_iosize ; toff += tinc ) { m = vm_page_lookup ( obj , OFF_TO_IDX ( off + toff ) ) ; if ( ! m ) goto notinmem ; tinc = size ; if ( tinc > PAGE_SIZE - ( ( toff + off ) & PAGE_MASK ) ) tinc = PAGE_SIZE - ( ( toff + off ) & PAGE_MASK ) ; if ( vm_page_is_valid ( m , ( vm_offset_t ) ( ( toff + off ) & PAGE_MASK ) , tinc ) == 0 ) goto notinmem ; } VM_OBJECT_RUNLOCK ( obj ) ; return 1 ; notinmem : VM_OBJECT_RUNLOCK ( obj ) ; return ( 0 ) ; }
Returns true if no I/O is needed to access the
 associated VM object.
Returns true if no I / O is needed to access the associated VM object .