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.
This commit is contained in:
parent
9d170964e4
commit
0f7289022b
@ -2378,6 +2378,9 @@ vfs_msync(struct mount *mp, int flags) {
|
||||
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)
|
||||
|
@ -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 */
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user