From 4b437abe7829ed9af8a9434c256082b546c84682 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 27 Aug 2001 06:09:56 +0000 Subject: 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. --- sys/kern/vfs_subr.c | 3 +++ sys/sys/vnode.h | 2 +- sys/ufs/ufs/ufs_vnops.c | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'sys') 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: -- cgit v1.1