diff options
author | bde <bde@FreeBSD.org> | 1998-07-03 22:17:03 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-07-03 22:17:03 +0000 |
commit | 660e6408e6df99a20dacb070c5e7f9739efdf96d (patch) | |
tree | fa18791e6630cac02a4e08a1e8a214bd606680e8 | |
parent | dfd9848c30c89d2bd43b93309c934a84cc254107 (diff) | |
download | FreeBSD-src-660e6408e6df99a20dacb070c5e7f9739efdf96d.zip FreeBSD-src-660e6408e6df99a20dacb070c5e7f9739efdf96d.tar.gz |
Sync timestamp changes for inodes of special files to disk as late
as possible (when the inode is reclaimed). Temporarily only do
this if option UFS_LAZYMOD configured and softupdates aren't enabled.
UFS_LAZYMOD is intentionally left out of /sys/conf/options.
This is mainly to avoid almost useless disk i/o on battery powered
machines. It's silly to write to disk (on the next sync or when the
inode becomes inactive) just because someone hit a key or something
wrote to the screen or /dev/null.
PR: 5577
Previous version reviewed by: phk
-rw-r--r-- | sys/gnu/ext2fs/ext2_inode.c | 14 | ||||
-rw-r--r-- | sys/gnu/ext2fs/inode.h | 3 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_inode.c | 14 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/inode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 16 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_inode.c | 10 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 10 |
8 files changed, 44 insertions, 29 deletions
diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index a094ad2..ae37b2c8 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -72,12 +72,12 @@ ext2_init(struct vfsconf *vfsp) /* * Update the access, modified, and inode change times as specified by the - * IACCESS, IUPDATE, and ICHANGE flags respectively. The IMODIFIED flag is - * used to specify that the inode needs to be updated but that the times have - * already been set. The access and modified times are taken from the second - * and third parameters; the inode change time is always taken from the current - * time. If waitfor is set, then wait for the disk write of the inode to - * complete. + * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode + * to disk if the IN_MODIFIED flag is set (it may be set initially, or by + * the timestamp update). The IN_LAZYMOD flag is set to force a write + * later if not now. If we write now, then clear both IN_MODIFIED and + * IN_LAZYMOD to reflect the presumably successful write, and if waitfor is + * set, then wait for the write to complete. */ int ext2_update(vp, access, modify, waitfor) @@ -95,7 +95,7 @@ ext2_update(vp, access, modify, waitfor) ip = VTOI(vp); if ((ip->i_flag & IN_MODIFIED) == 0) return (0); - ip->i_flag &= ~IN_MODIFIED; + ip->i_flag &= ~(IN_LAZYMOD | IN_MODIFIED); if (vp->v_mount->mnt_flag & MNT_RDONLY) return (0); fs = ip->i_e2fs; diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h index c787e1e..76b7b5e 100644 --- a/sys/gnu/ext2fs/inode.h +++ b/sys/gnu/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.21 1998/03/08 09:59:21 julian Exp $ + * $Id: inode.h,v 1.22 1998/03/26 20:53:58 phk Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -127,6 +127,7 @@ struct inode { #define IN_SHLOCK 0x0020 /* File has shared lock. */ #define IN_EXLOCK 0x0040 /* File has exclusive lock. */ #define IN_HASHED 0x0080 /* Inode is on hash list */ +#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */ #ifdef KERNEL /* diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index a094ad2..ae37b2c8 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -72,12 +72,12 @@ ext2_init(struct vfsconf *vfsp) /* * Update the access, modified, and inode change times as specified by the - * IACCESS, IUPDATE, and ICHANGE flags respectively. The IMODIFIED flag is - * used to specify that the inode needs to be updated but that the times have - * already been set. The access and modified times are taken from the second - * and third parameters; the inode change time is always taken from the current - * time. If waitfor is set, then wait for the disk write of the inode to - * complete. + * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode + * to disk if the IN_MODIFIED flag is set (it may be set initially, or by + * the timestamp update). The IN_LAZYMOD flag is set to force a write + * later if not now. If we write now, then clear both IN_MODIFIED and + * IN_LAZYMOD to reflect the presumably successful write, and if waitfor is + * set, then wait for the write to complete. */ int ext2_update(vp, access, modify, waitfor) @@ -95,7 +95,7 @@ ext2_update(vp, access, modify, waitfor) ip = VTOI(vp); if ((ip->i_flag & IN_MODIFIED) == 0) return (0); - ip->i_flag &= ~IN_MODIFIED; + ip->i_flag &= ~(IN_LAZYMOD | IN_MODIFIED); if (vp->v_mount->mnt_flag & MNT_RDONLY) return (0); fs = ip->i_e2fs; diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h index c787e1e..76b7b5e 100644 --- a/sys/gnu/fs/ext2fs/inode.h +++ b/sys/gnu/fs/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.21 1998/03/08 09:59:21 julian Exp $ + * $Id: inode.h,v 1.22 1998/03/26 20:53:58 phk Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -127,6 +127,7 @@ struct inode { #define IN_SHLOCK 0x0020 /* File has shared lock. */ #define IN_EXLOCK 0x0040 /* File has exclusive lock. */ #define IN_HASHED 0x0080 /* Inode is on hash list */ +#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */ #ifdef KERNEL /* diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 89254a2..df06020 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 - * $Id: ffs_inode.c,v 1.43 1998/06/14 19:31:28 julian Exp $ + * $Id: ffs_inode.c,v 1.44 1998/07/03 18:46:47 bde Exp $ */ #include "opt_quota.h" @@ -62,12 +62,12 @@ static int ffs_indirtrunc __P((struct inode *, ufs_daddr_t, ufs_daddr_t, /* * Update the access, modified, and inode change times as specified by the - * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. The IN_MODIFIED - * flag is used to specify that the inode needs to be updated even if none - * of the times needs to be updated. The access and modified times are taken - * from the second and third parameters; the inode change time is always - * taken from the current time. If waitfor is set, then wait for the disk - * write of the inode to complete. + * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode + * to disk if the IN_MODIFIED flag is set (it may be set initially, or by + * the timestamp update). The IN_LAZYMOD flag is set to force a write + * later if not now. If we write now, then clear both IN_MODIFIED and + * IN_LAZYMOD to reflect the presumably successful write, and if waitfor is + * set, then wait for the write to complete. */ int ffs_update(vp, access, modify, waitfor) @@ -85,7 +85,7 @@ ffs_update(vp, access, modify, waitfor) ip = VTOI(vp); if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor != MNT_WAIT) return (0); - ip->i_flag &= ~IN_MODIFIED; + ip->i_flag &= ~(IN_LAZYMOD | IN_MODIFIED); if (vp->v_mount->mnt_flag & MNT_RDONLY) return (0); fs = ip->i_fs; diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index c787e1e..76b7b5e 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.21 1998/03/08 09:59:21 julian Exp $ + * $Id: inode.h,v 1.22 1998/03/26 20:53:58 phk Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -127,6 +127,7 @@ struct inode { #define IN_SHLOCK 0x0020 /* File has shared lock. */ #define IN_EXLOCK 0x0040 /* File has exclusive lock. */ #define IN_HASHED 0x0080 /* Inode is on hash list */ +#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */ #ifdef KERNEL /* diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index f63c08a..be4d2bb 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_inode.c 8.9 (Berkeley) 5/14/95 - * $Id: ufs_inode.c,v 1.21 1997/12/02 11:43:45 bde Exp $ + * $Id: ufs_inode.c,v 1.22 1998/03/30 09:56:16 phk Exp $ */ #include "opt_quota.h" @@ -116,16 +116,22 @@ ufs_reclaim(ap) { register struct inode *ip; register struct vnode *vp = ap->a_vp; + struct timeval tv; #ifdef QUOTA int i; #endif if (prtactive && vp->v_usecount != 0) vprint("ufs_reclaim: pushing active", vp); + ip = VTOI(vp); + if (ip->i_flag & IN_LAZYMOD) { + ip->i_flag |= IN_MODIFIED; + getmicrotime(&tv); + UFS_UPDATE(vp, &tv, &tv, 0); + } /* * Remove the inode from its hash chain. */ - ip = VTOI(vp); ufs_ihashrem(ip); /* * Purge old data structures associated with the inode. diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index bbf701c..2a64e25 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 - * $Id: ufs_vnops.c,v 1.88 1998/06/08 23:55:33 julian Exp $ + * $Id: ufs_vnops.c,v 1.91 1998/07/03 18:46:49 bde Exp $ */ #include "opt_quota.h" @@ -145,7 +145,13 @@ ufs_itimes(vp) return; if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { tv_sec = time_second; - ip->i_flag |= IN_MODIFIED; +#ifdef UFS_LAZYMOD + if ((vp->v_type == VBLK || vp->v_type == VCHR) && + !DOINGSOFTDEP(vp)) + ip->i_flag |= IN_LAZYMOD; + else +#endif + ip->i_flag |= IN_MODIFIED; if (ip->i_flag & IN_ACCESS) ip->i_atime = tv_sec; if (ip->i_flag & IN_UPDATE) { |