From: Matthew Dillon Date: Fri, 1 Mar 2013 01:18:40 +0000 (-0800) Subject: kernel - Do not clean VM pages on fsync() for tmpfs X-Git-Tag: v3.4.0rc~179 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/6f2f854f2066ba30dc73c6d75d3c68578423fbc4 kernel - Do not clean VM pages on fsync() for tmpfs * tmpfs fsync()s are basically NOPs, but the kernel had some code to clean the VM object (flush to backing store) on fsync, which would actually cause pages to go out to swap unnecessarily. * Detect the appropriate flag and turn this off. Only effects tmpfs. * Improves poudriere and other tmpfs-related use cases. --- diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 9e53ce26ec..cb73c14296 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3659,8 +3659,12 @@ sys_fsync(struct fsync_args *uap) return (error); vp = (struct vnode *)fp->f_data; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - if ((obj = vp->v_object) != NULL) - vm_object_page_clean(obj, 0, 0, 0); + if ((obj = vp->v_object) != NULL) { + if (vp->v_mount == NULL || + (vp->v_mount->mnt_kern_flag & MNTK_NOMSYNC) == 0) { + vm_object_page_clean(obj, 0, 0, 0); + } + } error = VOP_FSYNC(vp, MNT_WAIT, VOP_FSYNC_SYSCALL); if (error == 0 && vp->v_mount) error = buf_fsync(vp);