diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2019-11-27 16:12:14 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2019-11-27 16:12:14 +0000 |
commit | 6bc9253650a6d1f44bf76ff7eccc184620ae0d3b (patch) | |
tree | 6eb242bd9721d83df2bf1f8f9bcdaa8283aacd1c /sys | |
parent | 8de1f7ce9ccf459a9a193ce07197d31b06a746bd (diff) |
Re-enable IO_NOCACHE, and use is in vnd.
Ensure that io to a file backing a vnd is IO_SYNC, so IO to a
vnd device is both synchronous and not cached in the buffer cache.
This allows the "mount" regress to work repeatably, and avoids
a situation where when the buffer cache cleaner runs to clear
dirty buffers while people are waiting, it actually increases the
dirty buffers when the writes to the underlying vnd are also
delayed.
ok bluhm@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/vnd.c | 9 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_readwrite.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 5 |
3 files changed, 11 insertions, 9 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 1aa3a8b89ca..5749dd7150c 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.170 2019/11/03 03:20:15 beck Exp $ */ +/* $OpenBSD: vnd.c,v 1.171 2019/11/27 16:12:13 beck Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -334,10 +334,13 @@ vndstrategy(struct buf *bp) /* * Use IO_NOLIMIT because upper layer has already checked I/O * for limits, so there is no need to do it again. + * + * We use IO_NOCACHE because this data should be cached at the + * upper layer, so there is no need to cache it again. */ bp->b_error = vn_rdwr((bp->b_flags & B_READ) ? UIO_READ : UIO_WRITE, - sc->sc_vp, bp->b_data, bp->b_bcount, off, UIO_SYSSPACE, IO_NOLIMIT, - sc->sc_cred, &bp->b_resid, curproc); + sc->sc_vp, bp->b_data, bp->b_bcount, off, UIO_SYSSPACE, + IO_NOCACHE | IO_SYNC | IO_NOLIMIT, sc->sc_cred, &bp->b_resid, curproc); if (bp->b_error) bp->b_flags |= B_ERROR; diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c index e58b2a20c5d..491889b911d 100644 --- a/sys/ufs/ext2fs/ext2fs_readwrite.c +++ b/sys/ufs/ext2fs/ext2fs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_readwrite.c,v 1.44 2018/01/13 15:57:58 millert Exp $ */ +/* $OpenBSD: ext2fs_readwrite.c,v 1.45 2019/11/27 16:12:13 beck Exp $ */ /* $NetBSD: ext2fs_readwrite.c,v 1.16 2001/02/27 04:37:47 chs Exp $ */ /*- @@ -335,10 +335,10 @@ ext2fs_write(void *v) */ if (error != 0 && !(flags & B_CLRBUF)) memset(bp->b_data + blkoffset, 0, xfersize); -#if 0 + if (ioflag & IO_NOCACHE) bp->b_flags |= B_NOCACHE; -#endif + if (ioflag & IO_SYNC) (void)bwrite(bp); else if (xfersize + blkoffset == fs->e2fs_bsize) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 1bb581fb5b7..bddcc2aeb9b 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vnops.c,v 1.94 2019/07/19 00:54:59 cheloha Exp $ */ +/* $OpenBSD: ffs_vnops.c,v 1.95 2019/11/27 16:12:13 beck Exp $ */ /* $NetBSD: ffs_vnops.c,v 1.7 1996/05/11 18:27:24 mycroft Exp $ */ /* @@ -370,10 +370,9 @@ ffs_write(void *v) if (error != 0 && !(flags & B_CLRBUF)) memset(bp->b_data + blkoffset, 0, xfersize); -#if 0 if (ioflag & IO_NOCACHE) bp->b_flags |= B_NOCACHE; -#endif + if (ioflag & IO_SYNC) (void)bwrite(bp); else if (xfersize + blkoffset == fs->fs_bsize) { |