summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-03-19 04:17:34 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-03-19 04:17:34 +0000
commit335290b893ea5e4e6b907bdd6cff7aae5a1fa231 (patch)
tree6e43711dcbd52703f97b0480101ef7f291ea03ec /sys/ufs
parente6e04b68c6a6211babdef3ce319971ec558bdd84 (diff)
Pull in FreeBSD r37363 and r37887:
-- 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. -- Made lazy syncing of timestamps for special files non-optional. -- Also, include support in 'pstat -v' to display the IN_LAZYMOD flag. ok tedu@ millert@
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_inode.c11
-rw-r--r--sys/ufs/ufs/inode.h3
-rw-r--r--sys/ufs/ufs/ufs_inode.c13
-rw-r--r--sys/ufs/ufs/ufs_vnops.c7
4 files changed, 25 insertions, 9 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 80a1b1c11e9..641e596e7dd 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_inode.c,v 1.67 2014/01/25 23:31:12 guenther Exp $ */
+/* $OpenBSD: ffs_inode.c,v 1.68 2014/03/19 04:17:33 guenther Exp $ */
/* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */
/*
@@ -59,8 +59,11 @@ int ffs_indirtrunc(struct inode *, daddr_t, daddr_t, daddr_t, int, long *);
* 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 but that the
- * times have already been set. If waitfor is set, then wait for
- * the disk write of the inode to complete.
+ * times have already been set. The IN_LAZYMOD flag is used to specify
+ * that the inode needs to be updated at some point, by reclaim if not
+ * in the course of other changes; this is used to defer writes just to
+ * update device timestamps. If waitfor is set, then wait for the disk
+ * write of the inode to complete.
*/
int
ffs_update(struct inode *ip, int waitfor)
@@ -76,7 +79,7 @@ ffs_update(struct inode *ip, int waitfor)
if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor != MNT_WAIT)
return (0);
- ip->i_flag &= ~IN_MODIFIED;
+ ip->i_flag &= ~(IN_MODIFIED | IN_LAZYMOD);
fs = ip->i_fs;
/*
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index 3b730c08254..ae721caad4d 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.h,v 1.42 2014/01/26 02:02:26 tedu Exp $ */
+/* $OpenBSD: inode.h,v 1.43 2014/03/19 04:17:33 guenther Exp $ */
/* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */
/*
@@ -250,6 +250,7 @@ struct inode_vtbl {
#define IN_RENAME 0x0010 /* Inode is being renamed. */
#define IN_SHLOCK 0x0020 /* File has shared lock. */
#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
+#define IN_LAZYMOD 0x0080 /* Modified, but don't write yet. */
#define i_devvp i_ump->um_devvp
diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c
index 0b14a34cf4d..df5f2681911 100644
--- a/sys/ufs/ufs/ufs_inode.c
+++ b/sys/ufs/ufs/ufs_inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_inode.c,v 1.38 2009/08/14 20:55:05 jasper Exp $ */
+/* $OpenBSD: ufs_inode.c,v 1.39 2014/03/19 04:17:33 guenther Exp $ */
/* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */
/*
@@ -139,10 +139,19 @@ ufs_reclaim(struct vnode *vp, struct proc *p)
vprint("ufs_reclaim: pushing active", vp);
#endif
+ ip = VTOI(vp);
+
+ /*
+ * Stop deferring timestamp writes
+ */
+ if (ip->i_flag & IN_LAZYMOD) {
+ ip->i_flag |= IN_MODIFIED;
+ UFS_UPDATE(ip, 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 daf7b6ab9aa..5f9fa643686 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.112 2014/01/25 23:31:13 guenther Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.113 2014/03/19 04:17:33 guenther Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -131,7 +131,10 @@ ufs_itimes(struct vnode *vp)
}
#endif
- ip->i_flag |= IN_MODIFIED;
+ if ((vp->v_type == VBLK || vp->v_type == VCHR) && !DOINGSOFTDEP(vp))
+ ip->i_flag |= IN_LAZYMOD;
+ else
+ ip->i_flag |= IN_MODIFIED;
getnanotime(&ts);
if (ip->i_flag & IN_ACCESS) {