From 823f741b15885d5bdaf8dd9daa9a31667ad48cfd Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 14 Dec 2017 20:20:38 +0000 Subject: [PATCH] Give vflush_vnode() a hint about vnodes we don't need to account as "busy". Change mountpoint to RDONLY a little later. Seems to improve the rw->ro transition a bit. --- sys/kern/vfs_subr.c | 14 +++++++++----- sys/sys/vnode.h | 4 ++-- sys/ufs/ffs/ffs_vfsops.c | 7 +++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 088a8f883b7..da17524a115 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.263 2017/12/11 14:11:22 bluhm Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.264 2017/12/14 20:20:38 deraadt Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -904,11 +904,15 @@ vflush_vnode(struct vnode *vp, void *arg) return (0); } - if (va->flags & WRITEDEMOTE) { - vp->v_op = &dead_vops; - vp->v_tag = VT_NON; + /* + * If set, this is allowed to ignore vnodes which don't + * have changes pending to disk. + * XXX Might be nice to check per-fs "inode" flags, but + * generally the filesystem is sync'd already, right? + */ + if ((va->flags & IGNORECLEAN) && + LIST_EMPTY(&vp->v_dirtyblkhd)) return (0); - } #ifdef DEBUG if (busyprt) diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 6578c6d54ff..32a2d96f71c 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.141 2017/12/11 05:27:40 deraadt Exp $ */ +/* $OpenBSD: vnode.h,v 1.142 2017/12/14 20:20:38 deraadt Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -227,7 +227,7 @@ extern int vttoif_tab[]; #define FORCECLOSE 0x0002 /* vflush: force file closeure */ #define WRITECLOSE 0x0004 /* vflush: only close writeable files */ #define DOCLOSE 0x0008 /* vclean: close active files */ -#define WRITEDEMOTE 0x0010 /* vflush: ok if some writes remain */ +#define IGNORECLEAN 0x0010 /* vflush: ignore clean vnodes */ #define V_SAVE 0x0001 /* vinvalbuf: sync file first */ #define V_SAVEMETA 0x0002 /* vinvalbuf: leave indirect blocks */ diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index a04cda2e70f..64af433a272 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.169 2017/12/14 17:25:39 guenther Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.170 2017/12/14 20:20:38 deraadt Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -243,16 +243,14 @@ ffs_mount(struct mount *mp, const char *path, void *data, if (ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) { /* Flush any dirty data */ - mp->mnt_flag &= ~MNT_RDONLY; VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p); - mp->mnt_flag |= MNT_RDONLY; /* * Get rid of files open for writing. */ flags = WRITECLOSE; if (args == NULL) - flags |= WRITEDEMOTE; + flags |= IGNORECLEAN; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; if (fs->fs_flags & FS_DOSOFTDEP) { @@ -260,6 +258,7 @@ ffs_mount(struct mount *mp, const char *path, void *data, mp->mnt_flag &= ~MNT_SOFTDEP; } else error = ffs_flushfiles(mp, flags, p); + mp->mnt_flag |= MNT_RDONLY; ronly = 1; } -- 2.20.1