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.
This commit is contained in:
chs 2012-04-29 22:53:59 +00:00
parent 66d7693e75
commit 8306a9eddf
16 changed files with 88 additions and 82 deletions

View File

@ -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 @@ msdosfs_write(void *v)
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 @@ msdosfs_fsync(void *v)
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);

View File

@ -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 @@ ntfs_fsync(void *v)
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);
}
/*

View File

@ -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 @@ sysvbfs_fsync(void *v)
}
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);

View File

@ -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 @@ udf_write_metadata_partition_spacetable(struct udf_mount *ump, int waitfor)
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 @@ udf_writeout_vat(struct udf_mount *ump)
// 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 @@ udf_close_logvol(struct udf_mount *ump, int mntflags)
/* 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 @@ out:
}
/* --------------------------------------------------------------------- */

View File

@ -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 @@ udf_write(void *v)
(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 @@ udf_fsync(void *v)
/* 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_entry_desc udf_vnodeop_entries[] = {
const struct vnodeopv_desc udf_vnodeop_opv_desc = {
&udf_vnodeop_p, udf_vnodeop_entries
};

View File

@ -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 @@ v7fs_fsync(void *v)
}
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 @@ v7fs_readlink(void *v)
error_exit:
return error;
}

View File

@ -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 @@ restart:
* 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 @@ loop:
* 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 @@ loop:
}
mutex_exit(&bufcache_lock);
if (sync == 0)
if (!sync)
return 0;
mutex_enter(vp->v_interlock);

View File

@ -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 $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1330,6 +1330,7 @@ genfs_do_io(struct vnode *vp, off_t off, vaddr_t kva, size_t len, int flags,
size_t bytes, iobytes, skipbytes;
struct buf *mbp, *bp;
const bool async = (flags & PGO_SYNCIO) == 0;
const bool lazy = (flags & PGO_LAZY) == 0;
const bool iowrite = rw == UIO_WRITE;
const int brw = iowrite ? B_WRITE : B_READ;
UVMHIST_FUNC(__func__); UVMHIST_CALLED(ubchist);
@ -1373,7 +1374,7 @@ genfs_do_io(struct vnode *vp, off_t off, vaddr_t kva, size_t len, int flags,
}
if (curlwp == uvm.pagedaemon_lwp)
BIO_SETPRIO(mbp, BPRIO_TIMELIMITED);
else if (async)
else if (async || lazy)
BIO_SETPRIO(mbp, BPRIO_TIMENONCRITICAL);
else
BIO_SETPRIO(mbp, BPRIO_TIMECRITICAL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec_vnops.c,v 1.134 2011/06/12 03:35:58 rmind Exp $ */
/* $NetBSD: spec_vnops.c,v 1.135 2012/04/29 22:54:00 chs Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.134 2011/06/12 03:35:58 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.135 2012/04/29 22:54:00 chs Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -869,7 +869,7 @@ spec_fsync(void *v)
if (error != EOPNOTSUPP)
return error;
}
return vflushbuf(vp, (ap->a_flags & FSYNC_WAIT) != 0);
return vflushbuf(vp, ap->a_flags);
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: chfs_vnops.c,v 1.6 2012/04/18 13:31:10 joerg Exp $ */
/* $NetBSD: chfs_vnops.c,v 1.7 2012/04/29 22:54:00 chs Exp $ */
/*-
* Copyright (c) 2010 Department of Software Engineering,
@ -1022,13 +1022,11 @@ chfs_fsync(void *v)
off_t offhi;
} */ *ap = v;
struct vnode *vp = ap->a_vp;
int wait;
if (ap->a_flags & FSYNC_CACHE) {
return ENODEV;
}
wait = (ap->a_flags & FSYNC_WAIT) != 0;
vflushbuf(vp, wait);
vflushbuf(vp, ap->a_flags);
//struct chfs_inode *ip = VTOI(vp);
//chfs_set_vnode_size(vp, ip->write_size);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_readwrite.c,v 1.60 2012/04/17 19:15:16 christos Exp $ */
/* $NetBSD: ext2fs_readwrite.c,v 1.61 2012/04/29 22:54:00 chs Exp $ */
/*-
* Copyright (c) 1993
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.60 2012/04/17 19:15:16 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.61 2012/04/29 22:54:00 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -313,7 +313,8 @@ ext2fs_write(void *v)
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);
}
}
if (error == 0 && ioflag & IO_SYNC) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_vnops.c,v 1.102 2012/03/13 18:41:04 elad Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.103 2012/04/29 22:54:00 chs Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.102 2012/03/13 18:41:04 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.103 2012/04/29 22:54:00 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1387,7 +1387,7 @@ ext2fs_fsync(void *v)
if (vp->v_type == VBLK)
error = spec_fsync(v);
else
error = vflushbuf(vp, wait);
error = vflushbuf(vp, ap->a_flags);
if (error == 0 && (ap->a_flags & FSYNC_DATAONLY) == 0)
error = ext2fs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_vfsops.c,v 1.276 2012/03/13 18:41:13 elad Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.277 2012/04/29 22:54:00 chs Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.276 2012/03/13 18:41:13 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.277 2012/04/29 22:54:00 chs Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -2168,7 +2168,7 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
}
#endif /* WAPBL */
error = vflushbuf(vp, (flags & FSYNC_WAIT) != 0);
error = vflushbuf(vp, flags);
if (error == 0 && (flags & FSYNC_CACHE) != 0) {
i = 1;
(void)VOP_IOCTL(vp, DIOCCACHESYNC, &i, FWRITE,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_vnops.c,v 1.120 2011/06/27 16:34:47 manu Exp $ */
/* $NetBSD: ffs_vnops.c,v 1.121 2012/04/29 22:54:00 chs Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.120 2011/06/27 16:34:47 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.121 2012/04/29 22:54:00 chs Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -455,35 +455,35 @@ int
ffs_full_fsync(struct vnode *vp, int flags)
{
int error, i, uflags;
struct mount *mp;
KASSERT(vp->v_tag == VT_UFS);
KASSERT(VTOI(vp) != NULL);
KASSERT(vp->v_type != VCHR && vp->v_type != VBLK);
error = 0;
uflags = UPDATE_CLOSE | ((flags & FSYNC_WAIT) ? UPDATE_WAIT : 0);
mp = vp->v_mount;
/*
* Flush all dirty data associated with the vnode.
*/
if (vp->v_type == VREG) {
int pflags = PGO_ALLPAGES | PGO_CLEANIT;
if ((flags & FSYNC_WAIT))
pflags |= PGO_SYNCIO;
if (fstrans_getstate(mp) == FSTRANS_SUSPENDING)
pflags |= PGO_FREE;
mutex_enter(vp->v_interlock);
error = VOP_PUTPAGES(vp, 0, 0, pflags);
if (error)
return error;
}
#ifdef WAPBL
struct mount *mp = vp->v_mount;
if (mp && mp->mnt_wapbl) {
/*
* Flush all dirty data associated with the vnode.
*/
if (vp->v_type == VREG) {
int pflags = PGO_ALLPAGES | PGO_CLEANIT;
if ((flags & FSYNC_LAZY))
pflags |= PGO_LAZY;
if ((flags & FSYNC_WAIT))
pflags |= PGO_SYNCIO;
if (fstrans_getstate(mp) == FSTRANS_SUSPENDING)
pflags |= PGO_FREE;
mutex_enter(vp->v_interlock);
error = VOP_PUTPAGES(vp, 0, 0, pflags);
if (error)
return error;
}
/*
* Don't bother writing out metadata if the syncer is
* making the request. We will let the sync vnode
@ -500,6 +500,8 @@ ffs_full_fsync(struct vnode *vp, int flags)
return error;
error = ffs_update(vp, NULL, NULL, uflags);
UFS_WAPBL_END(mp);
} else {
error = 0;
}
if (error || (flags & FSYNC_NOLOG) != 0)
return error;
@ -525,7 +527,7 @@ ffs_full_fsync(struct vnode *vp, int flags)
}
#endif /* WAPBL */
error = vflushbuf(vp, (flags & FSYNC_WAIT) != 0);
error = vflushbuf(vp, flags);
if (error == 0)
error = ffs_update(vp, NULL, NULL, uflags);
if (error == 0 && (flags & FSYNC_CACHE) != 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_readwrite.c,v 1.103 2012/04/17 19:15:16 christos Exp $ */
/* $NetBSD: ufs_readwrite.c,v 1.104 2012/04/29 22:54:01 chs Exp $ */
/*-
* Copyright (c) 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.103 2012/04/17 19:15:16 christos Exp $");
__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.104 2012/04/29 22:54:01 chs Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@ -418,7 +418,7 @@ WRITE(void *v)
mutex_enter(vp->v_interlock);
error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16,
(uio->uio_offset >> 16) << 16,
PGO_CLEANIT | PGO_JOURNALLOCKED);
PGO_CLEANIT | PGO_JOURNALLOCKED | PGO_LAZY);
if (error)
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_pager.h,v 1.42 2011/09/28 22:52:15 matt Exp $ */
/* $NetBSD: uvm_pager.h,v 1.43 2012/04/29 22:54:01 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -154,6 +154,7 @@ struct uvm_pagerops {
#define PGO_NOTIMESTAMP 0x1000 /* don't mark object accessed/modified */
#define PGO_RECLAIM 0x2000 /* object is being reclaimed */
#define PGO_GLOCKHELD 0x4000 /* genfs_node's lock is already held */
#define PGO_LAZY 0x8000 /* equivalent of MNT_LAZY / FSYNC_LAZY */
/* page we are not interested in getting */
#define PGO_DONTCARE ((struct vm_page *) -1L) /* [get only] */