Module Name: src Committed By: hannken Date: Sun Dec 12 10:30:10 UTC 2010
Modified Files: src/sys/kern: vfs_bio.c Log Message: brelsel: Clear B_COWDONE flag on clean (! BO_DELWRI) buffer. B_COWDONE is set if the buffer was read with intention to modify but the caller changed its mind. This error could lead to snapshot corruption when a buffer with B_COWDONE set resides on the freelist and we create a new snapshot. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/sys/kern/vfs_bio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_bio.c diff -u src/sys/kern/vfs_bio.c:1.224 src/sys/kern/vfs_bio.c:1.225 --- src/sys/kern/vfs_bio.c:1.224 Tue Nov 2 15:09:52 2010 +++ src/sys/kern/vfs_bio.c Sun Dec 12 10:30:09 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_bio.c,v 1.224 2010/11/02 15:09:52 pooka Exp $ */ +/* $NetBSD: vfs_bio.c,v 1.225 2010/12/12 10:30:09 hannken Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -123,7 +123,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.224 2010/11/02 15:09:52 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.225 2010/12/12 10:30:09 hannken Exp $"); #include "opt_bufcache.h" @@ -983,6 +983,14 @@ if (ISSET(bp->b_cflags, BC_WANTED)) CLR(bp->b_cflags, BC_WANTED|BC_AGE); + /* If it's clean clear the copy-on-write flag. */ + if (ISSET(bp->b_flags, B_COWDONE)) { + mutex_enter(bp->b_objlock); + if (!ISSET(bp->b_oflags, BO_DELWRI)) + CLR(bp->b_flags, B_COWDONE); + mutex_exit(bp->b_objlock); + } + /* * Determine which queue the buffer should be on, then put it there. */