From 6717a2ac1b2c9927a883421b3a2451e8612d9a64 Mon Sep 17 00:00:00 2001 From: chs Date: Mon, 8 Jan 2001 07:05:47 +0000 Subject: [PATCH] in vtruncbuf(), use a "synchronous freeing" flush to prevent a race between write i/os in a disk-based filesystem vs. the disk block being freed by a truncation, allocated to a new file, and written again with different data. if the disk driver reorders the requests and does the second i/o first, the old data will clobber the new, corrupting the new file. --- sys/kern/vfs_subr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 310418e4e616..c5e7ca07274f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.143 2000/12/31 03:13:51 sommerfeld Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.144 2001/01/08 07:05:47 chs Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -748,7 +748,7 @@ vtruncbuf(vp, lbn, slpflag, slptimeo) simple_lock(&uobj->vmobjlock); rv = (uobj->pgops->pgo_flush)(uobj, round_page(lbn << vp->v_mount->mnt_fs_bshift), - vp->v_uvm.u_size, PGO_FREE); + vp->v_uvm.u_size, PGO_FREE|PGO_SYNCIO); simple_unlock(&uobj->vmobjlock); if (!rv) { splx(s);