From 33ec4891883dcf67319734b57a4b38af003a0e3b Mon Sep 17 00:00:00 2001 From: mycroft Date: Mon, 29 May 2000 18:34:36 +0000 Subject: [PATCH] Pull in IN_ACCESSED changes and some MNT_LAZY `bug fixes' from FFS. --- sys/ufs/ext2fs/ext2fs_inode.c | 14 +++++++++----- sys/ufs/ext2fs/ext2fs_vfsops.c | 26 +++++++++++++++----------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index 48cd8b14ea18..b125b504d71f 100644 --- a/sys/ufs/ext2fs/ext2fs_inode.c +++ b/sys/ufs/ext2fs/ext2fs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_inode.c,v 1.17 2000/05/28 08:44:32 mycroft Exp $ */ +/* $NetBSD: ext2fs_inode.c,v 1.18 2000/05/29 18:34:36 mycroft Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -96,7 +96,7 @@ ext2fs_inactive(v) ip->i_flag |= IN_CHANGE | IN_UPDATE; VOP_VFREE(vp, ip->i_number, ip->i_e2fs_mode); } - if (ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) + if (ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED | IN_ACCESSED)) VOP_UPDATE(vp, NULL, NULL, 0); out: VOP_UNLOCK(vp, 0); @@ -135,6 +135,7 @@ ext2fs_update(v) int error; struct timespec ts; caddr_t cp; + int flags; if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) return (0); @@ -143,10 +144,12 @@ ext2fs_update(v) EXT2FS_ITIMES(ip, ap->a_access ? ap->a_access : &ts, ap->a_modify ? ap->a_modify : &ts, &ts); - if ((ip->i_flag & IN_MODIFIED) == 0) + flags = ip->i_flag & (IN_MODIFIED | IN_ACCESSED); + if (flags == 0) return (0); - ip->i_flag &= ~IN_MODIFIED; + ip->i_flag &= ~flags; fs = ip->i_e2fs; + error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), (int)fs->e2fs_bsize, NOCRED, &bp); @@ -157,7 +160,8 @@ ext2fs_update(v) cp = (caddr_t)bp->b_data + (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE); e2fs_isave(&ip->i_din.e2fs_din, (struct ext2fs_dinode *)cp); - if ((ap->a_flags & (UPDATE_WAIT|UPDATE_DIROP)) && + if ((ap->a_flags & (UPDATE_WAIT|UPDATE_DIROP)) != 0&& + (flags & IN_MODIFIED) != 0 && (ap->a_vp->v_mount->mnt_flag & MNT_ASYNC) == 0) return (bwrite(bp)); else { diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 5c011f679416..cdad72bd7227 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.35 2000/03/30 12:41:11 augustss Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.36 2000/05/29 18:34:36 mycroft Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -749,17 +749,16 @@ ext2fs_sync(mp, waitfor, cred, p) int error, allerror = 0; fs = ump->um_e2fs; - if (fs->e2fs_ronly != 0) { /* XXX */ + if (fs->e2fs_fmod != 0 && fs->e2fs_ronly != 0) { /* XXX */ printf("fs = %s\n", fs->e2fs_fsmnt); panic("update: rofs mod"); } - /* * Write back each (modified) inode. */ simple_lock(&mntvnode_slock); loop: - for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) { + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) { /* * If the vnode that we are about to sync is no longer * associated with this mount point, start over. @@ -767,11 +766,12 @@ loop: if (vp->v_mount != mp) goto loop; simple_lock(&vp->v_interlock); - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); ip = VTOI(vp); - if (vp->v_type == VNON || ((ip->i_flag & - (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - (vp->v_dirtyblkhd.lh_first == NULL || waitfor == MNT_LAZY))) + if (vp->v_type == VNON || + ((ip->i_flag & + (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED | IN_ACCESSED)) == 0 && + LIST_EMPTY(&vp->v_dirtyblkhd))) { simple_unlock(&vp->v_interlock); continue; @@ -794,9 +794,13 @@ loop: /* * Force stale file system control information to be flushed. */ - if ((error = VOP_FSYNC(ump->um_devvp, cred, - waitfor == MNT_WAIT ? FSYNC_WAIT : 0, p)) != 0) - allerror = error; + if (waitfor != MNT_LAZY) { + vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); + if ((error = VOP_FSYNC(ump->um_devvp, cred, + waitfor == MNT_WAIT ? FSYNC_WAIT : 0, p)) != 0) + allerror = error; + VOP_UNLOCK(ump->um_devvp, 0); + } /* * Write back modified superblock. */