Date: Thu, 13 Oct 2011 14:41:32 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 200153 for review Message-ID: <201110131441.p9DEfWP4080296@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@200153?ac=10 Change 200153 by jhb@jhb_jhbbsd on 2011/10/13 14:40:35 Attempt to do fadvise() for writes. Affected files ... .. //depot/projects/fadvise/sys/kern/vfs_vnops.c#3 edit Differences ... ==== //depot/projects/fadvise/sys/kern/vfs_vnops.c#3 (text+ko) ==== @@ -605,7 +605,8 @@ struct vnode *vp; struct mount *mp; int error, ioflag, lock_flags; - int vfslocked; + struct mtx *mtxp; + int advice, vfslocked; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); @@ -639,7 +640,32 @@ vn_lock(vp, lock_flags | LK_RETRY); if ((flags & FOF_OFFSET) == 0) uio->uio_offset = fp->f_offset; - ioflag |= sequential_heuristic(uio, fp); + advice = FADV_NORMAL; + if (fp->f_advice != FADV_NORMAL) { + mtxp = mtx_pool_find(mtxpool_sleep, fp); + mtx_lock(mtxp); + if (fp->f_advice != FADV_NORMAL && + uio->uio_offset >= fp->f_advstart && + uio->uio_offset + uio->uio_resid <= fp->f_advend) + advice = fp->f_advice; + mtx_unlock(mtxp); + } + switch (advice) { + case FADV_NORMAL: + case FADV_SEQUENTIAL: + ioflag |= sequential_heuristic(uio, fp); + case FADV_RANDOM: + /* XXX: Is this correct? */ + break; + case FADV_NOREUSE: + /* + * Request the underlying FS to discard the pages + * after the I/O is complete. + */ + ioflag |= IO_DIRECT; + break; + } + #ifdef MAC error = mac_vnode_check_write(active_cred, fp->f_cred, vp); if (error == 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110131441.p9DEfWP4080296>