From nobody@FreeBSD.org  Sun Jan  5 11:39:32 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 09340F80
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  5 Jan 2014 11:39:32 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id E99431796
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  5 Jan 2014 11:39:31 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id s05BdVq5088930
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 5 Jan 2014 11:39:31 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id s05BdVpc088920;
	Sun, 5 Jan 2014 11:39:31 GMT
	(envelope-from nobody)
Message-Id: <201401051139.s05BdVpc088920@oldred.freebsd.org>
Date: Sun, 5 Jan 2014 11:39:31 GMT
From: Anders Berggren <anders@halon.se>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Corrupted files with vfs.unmapped_buf_allowed=1
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         185487
>Category:       kern
>Synopsis:       [vfs] Corrupted files with vfs.unmapped_buf_allowed=1
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kib
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 05 11:40:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Thu Jan  9 10:20:01 UTC 2014
>Originator:     Anders Berggren
>Release:        10.0-RC4
>Organization:
Halon Security
>Environment:
FreeBSD sp-build10-i386 10.0-RC4 FreeBSD 10.0-RC4 #0 r260130: Tue Dec 31 20:44:17 UTC 2013     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
We experienced strange problems with the FreeBSD 10 RC, with builds that
failed and Postgres databases that got corrupted. We were able to reduce
the problem down to:

i=0
while true
	do
	i=`expr $i + 1`
	echo RUN $i
	dd if=/dev/random of=disktest bs=1m count=1
	orig=`md5 -q disktest`
	cp disktest disktest2
	md5 -c $orig disktest2
	[ $? -ne 0 ] && echo fail && exit
done

which failed for us (very randomly, sometimes 10 iterations, sometimes
10000, sometimes never). The issue disappeared when disabling vfs
unmapped_buf. We've tested it on different i386 machines, both in VMware
and Hyper-V. Not bare-metal, though. When examining corrupted data, it
appeared"repeated", as repeated pattern in the file of previously
read/written data blocks.
>How-To-Repeat:
Run the script example above, for us it failed in 10-100000 iterations.
We were also able to repeat the problem on real-world, high-traffic
PostgreSQL databases.
>Fix:
vfs.unmapped_buf_allowed="0" in loader.conf

>Release-Note:
>Audit-Trail:

From: Anders Berggren <anders@halon.se>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/185487: Corrupted files with vfs.unmapped_buf_allowed=1
Date: Sun, 5 Jan 2014 23:33:30 +0100

 This may be a duplicate of
 http://lists.freebsd.org/pipermail/freebsd-current/2013-December/047371.html
 
 It anyway might cause a bit of problems for people running i386 in
 virtual machines.
State-Changed-From-To: open->analyzed 
State-Changed-By: glebius 
State-Changed-When: Thu Jan 9 10:18:09 UTC 2014 
State-Changed-Why:  
Konstantin, can you please look at this? 


Responsible-Changed-From-To: freebsd-bugs->kib 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Thu Jan 9 10:18:09 UTC 2014 
Responsible-Changed-Why:  
Konstantin, can you please look at this? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=185487 

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Anders Berggren <anders@halon.se>
Cc: kib@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/185487: Corrupted files with vfs.unmapped_buf_allowed=1
Date: Thu, 9 Jan 2014 14:17:58 +0400

 On Sun, Jan 05, 2014 at 11:39:31AM +0000, Anders Berggren wrote:
 A> >Environment:
 A> FreeBSD sp-build10-i386 10.0-RC4 FreeBSD 10.0-RC4 #0 r260130: Tue Dec 31 20:44:17 UTC 2013     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  i386
 A> 
 A> >Description:
 A> We experienced strange problems with the FreeBSD 10 RC, with builds that failed and Postgres databases that got corrupted. We were able to reduce the problem down to:
 A> 
 A> i=0
 A> while true
 A> 	do
 A> 	i=`expr $i + 1`
 A> 	echo RUN $i
 A> 	dd if=/dev/random of=disktest bs=1m count=1
 A> 	orig=`md5 -q disktest`
 A> 	cp disktest disktest2
 A> 	md5 -c $orig disktest2
 A> 	[ $? -ne 0 ] && echo fail && exit
 A> done
 A> 
 A> which failed for us (very randomly, sometimes 10 iterations, sometimes 10000, sometimes never). The issue disappeared when disabling vfs unmapped_buf. We've tested it on different i386 machines, both in VMware and Hyper-V. Not bare-metal, though. When examining corrupted data, it appeared"repeated", as repeated pattern in the file of previously read/written data blocks.
 A> >How-To-Repeat:
 A> Run the script example above, for us it failed in 10-100000 iterations. We were also able to repeat the problem on real-world, high-traffic PostgreSQL databases.
 A> >Fix:
 A> vfs.unmapped_buf_allowed="0" in loader.conf
 
 The issue is already known under VirtualBox. We plan to publish an errata entry
 on this, since it won't be fixed in 10.0-RELEASE.
 
 I'll assign the to author of unmapped I/O.
 
 -- 
 Totus tuus, Glebius.
>Unformatted:
