summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2001-08-27 06:09:56 +0000
committerpeter <peter@FreeBSD.org>2001-08-27 06:09:56 +0000
commit4b437abe7829ed9af8a9434c256082b546c84682 (patch)
treea8cac4344907af5683b1c88f1f7e46973765b594 /sys
parent4d1f4f0e8abb7b90a7320815340366eb1491a971 (diff)
downloadFreeBSD-src-4b437abe7829ed9af8a9434c256082b546c84682.zip
FreeBSD-src-4b437abe7829ed9af8a9434c256082b546c84682.tar.gz
If a file has been completely unlinked, stop automatically syncing the
file. ffs will discard any pending dirty pages when it is closed, so we may as well not waste time trying to clean them. This doesn't stop other things from writing it out, eg: pageout, fsync(2) etc.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_subr.c3
-rw-r--r--sys/sys/vnode.h2
-rw-r--r--sys/ufs/ufs/ufs_vnops.c2
3 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index b421902..b38bc16 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -2378,6 +2378,9 @@ loop:
if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
continue;
+ if (vp->v_flag & VNOSYNC) /* unlinked, skip it */
+ continue;
+
if (flags != MNT_WAIT) {
if (VOP_GETVOBJECT(vp, &obj) != 0 ||
(obj->flags & OBJ_MIGHTBEDIRTY) == 0)
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index f00bc03..9ee79d1 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -163,7 +163,7 @@ struct vnode {
#define VXLOCK 0x00100 /* vnode is locked to change underlying type */
#define VXWANT 0x00200 /* process is waiting for vnode */
#define VBWAIT 0x00400 /* waiting for output to complete */
-/* open for business 0x00800 */
+#define VNOSYNC 0x01000 /* unlinked, stop syncing */
/* open for business 0x01000 */
#define VOBJBUF 0x02000 /* Allocate buffers in VM object */
#define VCOPYONWRITE 0x04000 /* vnode is doing copy-on-write */
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index c0826cf..e52bf93 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -758,6 +758,8 @@ ufs_remove(ap)
goto out;
}
error = ufs_dirremove(dvp, ip, ap->a_cnp->cn_flags, 0);
+ if (ip->i_nlink <= 0)
+ vp->v_flag |= VNOSYNC;
VN_KNOTE(vp, NOTE_DELETE);
VN_KNOTE(dvp, NOTE_WRITE);
out:
OpenPOWER on IntegriCloud