From 44961df1dceab8b67f900b362f44ce7d89e9fa6a Mon Sep 17 00:00:00 2001 From: guenther Date: Thu, 14 Dec 2017 17:25:39 +0000 Subject: [PATCH] If switching RW->RO, then stop deferring timestamp writes...and possibly other pending inode attribute changes. We appear to be missing UFS_UPDATE() calls in some paths with the result that bsd.rd remounting the newly created /mnt to RO would lose the GID changes on device inodes there. This only affected devices, as they're the only inodes where timestamp writes are delayed. ok deraadt@ --- sys/ufs/ffs/ffs_vfsops.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 15c0722cd62..a04cda2e70f 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.168 2017/12/11 17:13:34 deraadt Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.169 2017/12/14 17:25:39 guenther Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1151,11 +1151,23 @@ ffs_sync_vnode(struct vnode *vp, void *arg) { struct inode *ip; int error; + if (vp->v_type == VNON) + return (0); + ip = VTOI(vp); - if (vp->v_type == VNON || - ((ip->i_flag & + + /* + * If unmounting or converting rw to ro, then stop deferring + * timestamp writes. + */ + if (fsa->waitfor == MNT_WAIT && (ip->i_flag & IN_LAZYMOD)) { + ip->i_flag |= IN_MODIFIED; + UFS_UPDATE(ip, 1); + } + + if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - LIST_EMPTY(&vp->v_dirtyblkhd)) ) { + LIST_EMPTY(&vp->v_dirtyblkhd)) { return (0); } -- 2.20.1