FreeBSD/sys/kern/vfs_vnops.c
/*
 * Heuristic to detect sequential operation.
 */
Heuristic to detect sequential operation.
Heuristic to detect sequential operation .
static int
sequential_heuristic(struct uio *uio, struct file *fp)
{
	ASSERT_VOP_LOCKED(fp->f_vnode, __func__);
	if (fp->f_flag & FRDAHEAD)
		return (fp->f_seqcount << IO_SEQSHIFT);
	if ((uio->uio_offset == 0 && fp->f_seqcount > 0) ||
	    uio->uio_offset == fp->f_nextoff) {
		fp->f_seqcount += howmany(uio->uio_resid, 16384);
		if (fp->f_seqcount > IO_SEQMAX)
			fp->f_seqcount = IO_SEQMAX;
		return (fp->f_seqcount << IO_SEQSHIFT);
	}
	if (fp->f_seqcount > 1)
		fp->f_seqcount = 1;
	else
		fp->f_seqcount = 0;
	return (0);
}
static int sequential_heuristic ( struct uio * uio , struct file * fp ) { ASSERT_VOP_LOCKED ( fp -> f_vnode , __func__ ) ; if ( fp -> f_flag & FRDAHEAD ) return ( fp -> f_seqcount << IO_SEQSHIFT ) ; if ( ( uio -> uio_offset == 0 && fp -> f_seqcount > 0 ) || uio -> uio_offset == fp -> f_nextoff ) { fp -> f_seqcount += howmany ( uio -> uio_resid , 16384 ) ; if ( fp -> f_seqcount > IO_SEQMAX ) fp -> f_seqcount = IO_SEQMAX ; return ( fp -> f_seqcount << IO_SEQSHIFT ) ; } if ( fp -> f_seqcount > 1 ) fp -> f_seqcount = 1 ; else fp -> f_seqcount = 0 ; return ( 0 ) ; }
Heuristic to detect sequential operation.
Heuristic to detect sequential operation .
/*
	 * Offset 0 is handled specially.  open() sets f_seqcount to 1 so
	 * that the first I/O is normally considered to be slightly
	 * sequential.  Seeking to offset 0 doesn't change sequentiality
	 * unless previous seeks have reduced f_seqcount to 0, in which
	 * case offset 0 is not special.
	 */ /*
		 * f_seqcount is in units of fixed-size blocks so that it
		 * depends mainly on the amount of sequential I/O and not
		 * much on the number of sequential I/O's.  The fixed size
		 * of 16384 is hard-coded here since it is (not quite) just
		 * a magic size that works well here.  This size is more
		 * closely related to the best I/O size for real disks than
		 * to any block size used by software.
		 */ /* Not sequential.  Quickly draw-down sequentiality. */