kernels/linux-2.4.0/mm/filemap.c
/*
 * Read-ahead and flush behind for MADV_SEQUENTIAL areas.  Since we are
 * sure this is sequential access, we don't need a flexible read-ahead
 * window size -- we can always use a large fixed size window.
 */
Read-ahead and flush behind for MADV_SEQUENTIAL areas.  Since we are
sure this is sequential access, we don't need a flexible read-ahead
window size -- we can always use a large fixed size window.
Read - ahead and flush behind for MADV_SEQUENTIAL areas . Since we are sure this is sequential access we don ' t need a flexible read - ahead window size -- we can always use a large fixed size window .
static void nopage_sequential_readahead(struct vm_area_struct * vma,
	unsigned long pgoff, unsigned long filesize)
{
	unsigned long ra_window;
	ra_window = get_max_readahead(vma->vm_file->f_dentry->d_inode);
	ra_window = CLUSTER_OFFSET(ra_window + CLUSTER_PAGES - 1);
	if (vma->vm_raend == 0)
		vma->vm_raend = vma->vm_pgoff + ra_window;
	if ((pgoff + (ra_window >> 1)) == vma->vm_raend) {
		unsigned long start = vma->vm_pgoff + vma->vm_raend;
		unsigned long end = start + ra_window;
		if (end > ((vma->vm_end >> PAGE_SHIFT) + vma->vm_pgoff))
			end = (vma->vm_end >> PAGE_SHIFT) + vma->vm_pgoff;
		if (start > end)
			return;
		while ((start < end) && (start < filesize)) {
			if (read_cluster_nonblocking(vma->vm_file,
							start, filesize) < 0)
				break;
			start += CLUSTER_PAGES;
		}
		run_task_queue(&tq_disk);
		if (vma->vm_raend > (vma->vm_pgoff + ra_window + ra_window)) {
			unsigned long window = ra_window << PAGE_SHIFT;
			end = vma->vm_start + (vma->vm_raend << PAGE_SHIFT);
			end -= window + window;
			filemap_sync(vma, end - window, window, MS_INVALIDATE);
		}
		vma->vm_raend += ra_window;
	}
	return;
}
static void nopage_sequential_readahead ( struct vm_area_struct * vma , unsigned long pgoff , unsigned long filesize ) { unsigned long ra_window ; ra_window = get_max_readahead ( vma -> vm_file -> f_dentry -> d_inode ) ; ra_window = CLUSTER_OFFSET ( ra_window + CLUSTER_PAGES - 1 ) ; if ( vma -> vm_raend == 0 ) vma -> vm_raend = vma -> vm_pgoff + ra_window ; if ( ( pgoff + ( ra_window >> 1 ) ) == vma -> vm_raend ) { unsigned long start = vma -> vm_pgoff + vma -> vm_raend ; unsigned long end = start + ra_window ; if ( end > ( ( vma -> vm_end >> PAGE_SHIFT ) + vma -> vm_pgoff ) ) end = ( vma -> vm_end >> PAGE_SHIFT ) + vma -> vm_pgoff ; if ( start > end ) return ; while ( ( start < end ) && ( start < filesize ) ) { if ( read_cluster_nonblocking ( vma -> vm_file , start , filesize ) < 0 ) break ; start += CLUSTER_PAGES ; } run_task_queue ( & tq_disk ) ; if ( vma -> vm_raend > ( vma -> vm_pgoff + ra_window + ra_window ) ) { unsigned long window = ra_window << PAGE_SHIFT ; end = vma -> vm_start + ( vma -> vm_raend << PAGE_SHIFT ) ; end -= window + window ; filemap_sync ( vma , end - window , window , MS_INVALIDATE ) ; } vma -> vm_raend += ra_window ; } return ; }
Read-ahead and flush behind for MADV_SEQUENTIAL areas.
Read - ahead and flush behind for MADV_SEQUENTIAL areas .
/* vm_raend is zero if we haven't read ahead in this area yet.  */ /*
	 * If we've just faulted the page half-way through our window,
	 * then schedule reads for the next window, and release the
	 * pages in the previous window.
	 */ /* if we're far enough past the beginning of this area,
		   recycle pages that are in the previous window. */