PERFORCE change 200153 for review
John Baldwin
jhb at FreeBSD.org
Thu Oct 13 14:41:33 UTC 2011
http://p4web.freebsd.org/@@200153?ac=10
Change 200153 by jhb at 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)
More information about the p4-projects
mailing list