Index: sys/ufs/ufs/ufs_readwrite.c =================================================================== RCS file: /usr2/ncvs/src/sys/ufs/ufs/ufs_readwrite.c,v retrieving revision 1.65.2.4 retrieving revision 1.65.2.5 diff -u -r1.65.2.4 -r1.65.2.5 --- sys/ufs/ufs/ufs_readwrite.c 2000/12/11 07:33:22 1.65.2.4 +++ sys/ufs/ufs/ufs_readwrite.c 2000/12/22 18:44:34 1.65.2.5 @@ -468,10 +468,19 @@ if (uio->uio_offset + xfersize > ip->i_size) vnode_pager_setsize(vp, uio->uio_offset + xfersize); + /* + * Avoid a data-consistency race between write() and mmap() + * by ensuring that newly allocated blocks are zerod. The + * race can occur even in the case where the write covers + * the entire block. + */ + flags |= B_CLRBUF; +#if 0 if (fs->fs_bsize > xfersize) flags |= B_CLRBUF; else flags &= ~B_CLRBUF; +#endif /* XXX is uio->uio_offset the right thing here? */ error = VOP_BALLOC(vp, uio->uio_offset, xfersize, ap->a_cred, flags, &bp); Index: sys/gnu/ext2fs/ext2_readwrite.c =================================================================== RCS file: /usr2/ncvs/src/sys/gnu/ext2fs/ext2_readwrite.c,v retrieving revision 1.18.2.1 retrieving revision 1.18.2.2 diff -u -r1.18.2.1 -r1.18.2.2 --- sys/gnu/ext2fs/ext2_readwrite.c 2000/04/26 20:36:30 1.18.2.1 +++ sys/gnu/ext2fs/ext2_readwrite.c 2000/12/22 18:44:33 1.18.2.2 @@ -238,10 +238,19 @@ if (uio->uio_offset + xfersize > ip->i_size) vnode_pager_setsize(vp, uio->uio_offset + xfersize); + /* + * Avoid a data-consistency race between write() and mmap() + * by ensuring that newly allocated blocks are zerod. The + * race can occur even in the case where the write covers + * the entire block. + */ + flags |= B_CLRBUF; +#if 0 if (fs->s_frag_size > xfersize) flags |= B_CLRBUF; else flags &= ~B_CLRBUF; +#endif error = ext2_balloc(ip, lbn, blkoffset + xfersize, ap->a_cred, &bp, flags);