Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys change vflushbuf() to take the full FSYNC_* flags.



details:   https://anonhg.NetBSD.org/src/rev/c9b5e63a4712
branches:  trunk
changeset: 779068:c9b5e63a4712
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Apr 29 22:53:59 2012 +0000

description:
change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.

diffstat:

 sys/fs/msdosfs/msdosfs_vnops.c    |   9 ++++---
 sys/fs/ntfs/ntfs_vnops.c          |   8 ++----
 sys/fs/sysvbfs/sysvbfs_vnops.c    |   6 ++--
 sys/fs/udf/udf_subr.c             |  12 ++++-----
 sys/fs/udf/udf_vnops.c            |  10 ++++----
 sys/fs/v7fs/v7fs_vnops.c          |   7 ++---
 sys/kern/vfs_subr.c               |  23 ++++++++++++------
 sys/miscfs/genfs/genfs_io.c       |   7 +++--
 sys/miscfs/specfs/spec_vnops.c    |   6 ++--
 sys/ufs/chfs/chfs_vnops.c         |   6 +---
 sys/ufs/ext2fs/ext2fs_readwrite.c |   7 +++--
 sys/ufs/ext2fs/ext2fs_vnops.c     |   6 ++--
 sys/ufs/ffs/ffs_vfsops.c          |   6 ++--
 sys/ufs/ffs/ffs_vnops.c           |  46 ++++++++++++++++++++------------------
 sys/ufs/ufs/ufs_readwrite.c       |   6 ++--
 sys/uvm/uvm_pager.h               |   3 +-
 16 files changed, 87 insertions(+), 81 deletions(-)

diffs (truncated from 588 to 300 lines):

diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c    Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c    Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vnops.c,v 1.82 2012/04/03 14:58:55 njoly Exp $ */
+/*     $NetBSD: msdosfs_vnops.c,v 1.83 2012/04/29 22:53:59 chs Exp $   */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.82 2012/04/03 14:58:55 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.83 2012/04/29 22:53:59 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -656,7 +656,8 @@
                if (!async && oldoff >> 16 != uio->uio_offset >> 16) {
                        mutex_enter(vp->v_interlock);
                        error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16,
-                           (uio->uio_offset >> 16) << 16, PGO_CLEANIT);
+                           (uio->uio_offset >> 16) << 16,
+                           PGO_CLEANIT | PGO_LAZY);
                }
        } while (error == 0 && uio->uio_resid > 0);
 
@@ -1808,7 +1809,7 @@
 
        fstrans_start(vp->v_mount, FSTRANS_LAZY);
        wait = (ap->a_flags & FSYNC_WAIT) != 0;
-       error = vflushbuf(vp, wait);
+       error = vflushbuf(vp, ap->a_flags);
        if (error == 0 && (ap->a_flags & FSYNC_DATAONLY) == 0)
                error = msdosfs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
 
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/fs/ntfs/ntfs_vnops.c
--- a/sys/fs/ntfs/ntfs_vnops.c  Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/fs/ntfs/ntfs_vnops.c  Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vnops.c,v 1.50 2012/03/13 18:40:49 elad Exp $     */
+/*     $NetBSD: ntfs_vnops.c,v 1.51 2012/04/29 22:53:59 chs Exp $      */
 
 /*
  * Copyright (c) 1992, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vnops.c,v 1.50 2012/03/13 18:40:49 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vnops.c,v 1.51 2012/04/29 22:53:59 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -748,14 +748,12 @@
                off_t offhi;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
-       int wait;
 
        if (ap->a_flags & FSYNC_CACHE) {
                return EOPNOTSUPP;
        }
 
-       wait = (ap->a_flags & FSYNC_WAIT) != 0;
-       return vflushbuf(vp, wait);
+       return vflushbuf(vp, ap->a_flags);
 }
 
 /*
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/fs/sysvbfs/sysvbfs_vnops.c
--- a/sys/fs/sysvbfs/sysvbfs_vnops.c    Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/fs/sysvbfs/sysvbfs_vnops.c    Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysvbfs_vnops.c,v 1.43 2012/03/30 18:27:55 njoly Exp $ */
+/*     $NetBSD: sysvbfs_vnops.c,v 1.44 2012/04/29 22:53:59 chs Exp $   */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.43 2012/03/30 18:27:55 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.44 2012/04/29 22:53:59 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -861,7 +861,7 @@
        }
 
        wait = (ap->a_flags & FSYNC_WAIT) != 0;
-       error = vflushbuf(vp, wait);
+       error = vflushbuf(vp, ap->a_flags);
        if (error == 0 && (ap->a_flags & FSYNC_DATAONLY) == 0)
                error = sysvbfs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
 
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c     Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/fs/udf/udf_subr.c     Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.118 2011/11/13 23:08:47 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.119 2012/04/29 22:53:59 chs Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.118 2011/11/13 23:08:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.119 2012/04/29 22:53:59 chs Exp $");
 #endif /* not lint */
 
 
@@ -1830,7 +1830,7 @@
                        NULL, NULL);
 
        bitmap_node->i_flags |= IN_MODIFIED;
-       error = vflushbuf(bitmap_node->vnode, 1 /* sync */);
+       error = vflushbuf(bitmap_node->vnode, FSYNC_WAIT);
        if (error == 0)
                error = VOP_FSYNC(bitmap_node->vnode,
                                FSCRED, FSYNC_WAIT, 0, 0);
@@ -2834,7 +2834,7 @@
 
 //     mutex_exit(&ump->allocate_mutex);
 
-       error = vflushbuf(ump->vat_node->vnode, 1 /* sync */);
+       error = vflushbuf(ump->vat_node->vnode, FSYNC_WAIT);
        if (error)
                goto out;
        error = VOP_FSYNC(ump->vat_node->vnode,
@@ -3781,7 +3781,7 @@
                /* write out the VAT data and all its descriptors */
                DPRINTF(VOLUMES, ("writeout vat_node\n"));
                udf_writeout_vat(ump);
-               (void) vflushbuf(ump->vat_node->vnode, 1 /* sync */);
+               (void) vflushbuf(ump->vat_node->vnode, FSYNC_WAIT);
 
                (void) VOP_FSYNC(ump->vat_node->vnode,
                                FSCRED, FSYNC_WAIT, 0, 0);
@@ -6843,5 +6843,3 @@
 }
 
 /* --------------------------------------------------------------------- */
-
-
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/fs/udf/udf_vnops.c
--- a/sys/fs/udf/udf_vnops.c    Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/fs/udf/udf_vnops.c    Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.70 2012/03/13 18:40:51 elad Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.71 2012/04/29 22:53:59 chs Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.70 2012/03/13 18:40:51 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.71 2012/04/29 22:53:59 chs Exp $");
 #endif /* not lint */
 
 
@@ -368,7 +368,8 @@
                  (old_offset >> 16 != uio->uio_offset >> 16)) {
                        mutex_enter(vp->v_interlock);
                        error = VOP_PUTPAGES(vp, (old_offset >> 16) << 16,
-                           (uio->uio_offset >> 16) << 16, PGO_CLEANIT);
+                           (uio->uio_offset >> 16) << 16,
+                           PGO_CLEANIT | PGO_LAZY);
                        old_offset = uio->uio_offset;
                }
        }
@@ -2227,7 +2228,7 @@
 
        /* flush data and wait for it when requested */
        wait = (ap->a_flags & FSYNC_WAIT) ? UPDATE_WAIT : 0;
-       error = vflushbuf(vp, wait);
+       error = vflushbuf(vp, ap->a_flags);
        if (error)
                return error;
 
@@ -2382,4 +2383,3 @@
 const struct vnodeopv_desc udf_vnodeop_opv_desc = {
        &udf_vnodeop_p, udf_vnodeop_entries
 };
-
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/fs/v7fs/v7fs_vnops.c
--- a/sys/fs/v7fs/v7fs_vnops.c  Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/fs/v7fs/v7fs_vnops.c  Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: v7fs_vnops.c,v 1.10 2012/03/31 21:44:28 njoly Exp $    */
+/*     $NetBSD: v7fs_vnops.c,v 1.11 2012/04/29 22:54:00 chs Exp $      */
 
 /*-
  * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.10 2012/03/31 21:44:28 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.11 2012/04/29 22:54:00 chs Exp $");
 #if defined _KERNEL_OPT
 #include "opt_v7fs.h"
 #endif
@@ -661,7 +661,7 @@
        }
 
        wait = (a->a_flags & FSYNC_WAIT);
-       error = vflushbuf(vp, wait);
+       error = vflushbuf(vp, a->a_flags);
 
        if (error == 0 && (a->a_flags & FSYNC_DATAONLY) == 0)
                error = v7fs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
@@ -1329,4 +1329,3 @@
 error_exit:
        return error;
 }
-
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/kern/vfs_subr.c       Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.433 2012/03/13 18:40:55 elad Exp $      */
+/*     $NetBSD: vfs_subr.c,v 1.434 2012/04/29 22:54:00 chs Exp $       */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.433 2012/03/13 18:40:55 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.434 2012/04/29 22:54:00 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -277,14 +277,21 @@
  * buffers from being queued.
  */
 int
-vflushbuf(struct vnode *vp, int sync)
+vflushbuf(struct vnode *vp, int flags)
 {
        struct buf *bp, *nbp;
-       int error, flags = PGO_CLEANIT | PGO_ALLPAGES | (sync ? PGO_SYNCIO : 0);
-       bool dirty;
+       int error, pflags;
+       bool dirty, sync;
 
+       sync = (flags & FSYNC_WAIT) != 0;
+       pflags = PGO_CLEANIT | PGO_ALLPAGES |
+               (sync ? PGO_SYNCIO : 0) |
+               ((flags & FSYNC_LAZY) ? PGO_LAZY : 0);
        mutex_enter(vp->v_interlock);
-       (void) VOP_PUTPAGES(vp, 0, 0, flags);
+       (void) VOP_PUTPAGES(vp, 0, 0, pflags);
+
+       if (LIST_EMPTY(&vp->v_dirtyblkhd) || (flags & FSYNC_DATAONLY))
+               return 0;
 
 loop:
        mutex_enter(&bufcache_lock);
@@ -301,7 +308,7 @@
                 * Wait for I/O associated with indirect blocks to complete,
                 * since there is no way to quickly wait for them below.
                 */
-               if (bp->b_vp == vp || sync == 0)
+               if (bp->b_vp == vp || !sync)
                        (void) bawrite(bp);
                else {
                        error = bwrite(bp);
@@ -312,7 +319,7 @@
        }
        mutex_exit(&bufcache_lock);
 
-       if (sync == 0)
+       if (!sync)
                return 0;
 
        mutex_enter(vp->v_interlock);
diff -r b3b20d02f4e8 -r c9b5e63a4712 sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c       Sun Apr 29 21:54:51 2012 +0000
+++ b/sys/miscfs/genfs/genfs_io.c       Sun Apr 29 22:53:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_io.c,v 1.53 2011/10/31 12:49:32 yamt Exp $       */
+/*     $NetBSD: genfs_io.c,v 1.54 2012/04/29 22:54:00 chs Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.53 2011/10/31 12:49:32 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.54 2012/04/29 22:54:00 chs Exp $");



Home | Main Index | Thread Index | Old Index