summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-03-19 04:17:33 +0000
committerguenther <guenther@openbsd.org>2014-03-19 04:17:33 +0000
commitcd0929b614b2c8e39f75ecde6094c427d1b04680 (patch)
treed5889e6e9f64f951912de469520ad96cf96a4095
parentno rest for the wicked. increase user blf logrounds default to 8(+2). (diff)
downloadwireguard-openbsd-cd0929b614b2c8e39f75ecde6094c427d1b04680.tar.xz
wireguard-openbsd-cd0929b614b2c8e39f75ecde6094c427d1b04680.zip
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@
-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
-rw-r--r--usr.sbin/pstat/pstat.810
-rw-r--r--usr.sbin/pstat/pstat.c4
6 files changed, 33 insertions, 15 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) {
diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8
index 365717baa84..07a081860f7 100644
--- a/usr.sbin/pstat/pstat.8
+++ b/usr.sbin/pstat/pstat.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pstat.8,v 1.46 2014/02/16 19:20:26 schwarze Exp $
+.\" $OpenBSD: pstat.8,v 1.47 2014/03/19 04:17:33 guenther Exp $
.\" $NetBSD: pstat.8,v 1.9.4.1 1996/06/02 09:08:17 mrg Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993, 1994
@@ -30,7 +30,7 @@
.\"
.\" from: @(#)pstat.8 8.4 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: February 16 2014 $
+.Dd $Mdocdate: March 19 2014 $
.Dt PSTAT 8
.Os
.Sh NAME
@@ -301,13 +301,13 @@ access time must be corrected
.It C
changed time must be corrected
.It U
-update time
-.Pq Xr fs 5
-must be corrected
+modification time must be corrected
.It R
has a rename in progress
.It M
contains modifications
+.It m
+contains lazy modifications
.It S
shared lock applied
.It E
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c
index 5fd2c28613f..d903d796657 100644
--- a/usr.sbin/pstat/pstat.c
+++ b/usr.sbin/pstat/pstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pstat.c,v 1.89 2013/12/01 16:40:56 krw Exp $ */
+/* $OpenBSD: pstat.c,v 1.90 2014/03/19 04:17:33 guenther Exp $ */
/* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */
/*-
@@ -498,6 +498,8 @@ ufs_print(struct vnode *vp)
*flags++ = 'U';
if (flag & IN_MODIFIED)
*flags++ = 'M';
+ if (flag & IN_LAZYMOD)
+ *flags++ = 'm';
if (flag & IN_RENAME)
*flags++ = 'R';
if (flag & IN_SHLOCK)