summaryrefslogtreecommitdiff
path: root/sys/kern/vfs_cluster.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-03-21 10:11:23 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-03-21 10:11:23 +0000
commit15f7479f39a557a9477a8e4c14d9e005f2c5453b (patch)
tree593376608bd10aa2e0dd27e67fb2be6d58dbd50e /sys/kern/vfs_cluster.c
parent02f5d5b2c95143efbee29dc5124559ff49f0962c (diff)
Fix a race which could cause us to write out data belonging
to some other buffer.
Diffstat (limited to 'sys/kern/vfs_cluster.c')
-rw-r--r--sys/kern/vfs_cluster.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index 4da9e7d6ae1..df7b6b39b68 100644
--- a/sys/kern/vfs_cluster.c
+++ b/sys/kern/vfs_cluster.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_cluster.c,v 1.21 2001/02/27 14:55:34 csapuntz Exp $ */
+/* $OpenBSD: vfs_cluster.c,v 1.22 2001/03/21 10:11:22 art Exp $ */
/* $NetBSD: vfs_cluster.c,v 1.12 1996/04/22 01:39:05 christos Exp $ */
/*-
@@ -625,7 +625,15 @@ redo:
bawrite(last_bp);
} else if (len) {
bp = getblk(vp, start_lbn, size, 0, 0);
- bawrite(bp);
+ /*
+ * The buffer could have already been flushed out of
+ * the cache. If that has happened, we'll get a new
+ * buffer here with random data, just drop it.
+ */
+ if ((bp->b_flags & B_DELWRI) == 0)
+ brelse(bp);
+ else
+ bawrite(bp);
}
return;
}