kernel - Do not clean VM pages on fsync() for tmpfs
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 1 Mar 2013 01:18:40 +0000 (17:18 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 1 Mar 2013 01:18:40 +0000 (17:18 -0800)
* 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.

sys/kern/vfs_syscalls.c

index 9e53ce2..cb73c14 100644 (file)
@@ -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);