- /*
- * We check every vector target but if it is physically
- * contiguous space, we skip the sanity checks.
- */
- if (upl_flags & UPL_PHYS_CONTIG) {
- retval = cluster_phys_read(vp, uio, filesize);
- }
- else if (uio_resid(uio) < PAGE_SIZE) {
- /*
- * we're here because we're don't have a physically contiguous target buffer
- * go do a read through the cache if
- * the total xfer size is less than a page...
- */
- return (cluster_read_x(vp, uio, filesize, flags));
- }
- // LP64todo - fix this!
- else if (((int)uio->uio_offset & PAGE_MASK) || (CAST_DOWN(int, iov_base) & PAGE_MASK)) {
- if (((int)uio->uio_offset & PAGE_MASK) == (CAST_DOWN(int, iov_base) & PAGE_MASK)) {
- /*
- * Bring the file offset read up to a pagesize boundary
- * this will also bring the base address to a page boundary
- * since they both are currently on the same offset within a page
- * note: if we get here, uio->uio_resid is greater than PAGE_SIZE
- * so the computed clip_size must always be less than the current uio_resid
- */
- clip_size = (PAGE_SIZE - (int)(uio->uio_offset & PAGE_MASK_64));
-
- /*
- * Fake the resid going into the cluster_read_x call
- * and restore it on the way out.
- */
- prev_resid = uio_resid(uio);
- // LP64todo - fix this
- uio_setresid(uio, clip_size);
-
- retval = cluster_read_x(vp, uio, filesize, flags);
-
- uio_setresid(uio, prev_resid - (clip_size - uio_resid(uio)));
- } else {
- /*
- * can't get both the file offset and the buffer offset aligned to a page boundary
- * so fire an I/O through the cache for this entire vector
- */
- // LP64todo - fix this!
- clip_size = iov_len;
- prev_resid = uio_resid(uio);
- uio_setresid(uio, clip_size);
-
- retval = cluster_read_x(vp, uio, filesize, flags);
-
- uio_setresid(uio, prev_resid - (clip_size - uio_resid(uio)));
- }
- } else {
- /*
- * If we come in here, we know the offset into
- * the file is on a pagesize boundary
- */
- max_io_size = filesize - uio->uio_offset;
- // LP64todo - fix this
- clip_size = uio_resid(uio);
- if (iov_len < clip_size)
- clip_size = iov_len;
- if (max_io_size < clip_size)
- clip_size = (int)max_io_size;
-
- if (clip_size < PAGE_SIZE) {
- /*
- * Take care of the tail end of the read in this vector.
- */
- // LP64todo - fix this
- prev_resid = uio_resid(uio);
- uio_setresid(uio, clip_size);