From: Matthew Dillon Date: Mon, 2 Apr 2012 17:16:21 +0000 (-0700) Subject: kernel - Add max I/O size cap to vmaxiosize() X-Git-Tag: v3.4.0rc~1146^2 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/201cd6122f10d34494e93bdd304d21f94f3d0a29 kernel - Add max I/O size cap to vmaxiosize() * Cap the returned value at MAXPHYS, allowing VCHR devices to set a higher max-IO limit (according to DMA limitations) without blowing out the pbuf's that the frontend uses to build clustered I/O. --- diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ec42fe6f2d..ca17cfe1e8 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1366,15 +1366,23 @@ vrecycle(struct vnode *vp) * * If vp is VCHR or VBLK we dive the device, otherwise we use * the vp's mount info. + * + * The returned value is clamped at MAXPHYS as most callers cannot use + * buffers larger than that size. */ int vmaxiosize(struct vnode *vp) { - if (vp->v_type == VBLK || vp->v_type == VCHR) { - return(vp->v_rdev->si_iosize_max); - } else { - return(vp->v_mount->mnt_iosize_max); - } + int maxiosize; + + if (vp->v_type == VBLK || vp->v_type == VCHR) + maxiosize = vp->v_rdev->si_iosize_max; + else + maxiosize = vp->v_mount->mnt_iosize_max; + + if (maxiosize > MAXPHYS) + maxiosize = MAXPHYS; + return (maxiosize); } /*