From owner-freebsd-current@FreeBSD.ORG Fri May 24 02:19:47 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 125C98D6 for ; Fri, 24 May 2013 02:19:47 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id BCB40F3B for ; Fri, 24 May 2013 02:19:46 +0000 (UTC) Received: from lstewart.caia.swin.edu.au (lstewart.caia.swin.edu.au [136.186.229.95]) by lauren.room52.net (Postfix) with ESMTPSA id C3FAF7E8C9; Fri, 24 May 2013 12:19:44 +1000 (EST) Message-ID: <519ECE40.5020901@freebsd.org> Date: Fri, 24 May 2013 12:19:44 +1000 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130521 Thunderbird/17.0.6 MIME-Version: 1.0 To: freebsd-current@freebsd.org Subject: Read-triggered corruption of swap backed MD devices Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=unavailable version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lauren.room52.net Cc: Nigel Williams X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 02:19:47 -0000 Hi all, I tracked the cause of a colleague's nanobsd image creation problem to what appears to be some nasty behaviour with swap-backed MD devices. I've verified the behaviour exists on three separate systems running 10-CURRENT r250260, 9-STABLE r250824 and 9-STABLE r250925. The following minimal reproduction recipe (run as root) deterministically triggers the behaviour for me on the 3 systems I've tested: env MD_DEV=`mdconfig -an -t swap -s 1m -x 63 -y 16` sh -c '(fdisk -I md${MD_DEV} ; bsdlabel -w -B md${MD_DEV}s1 ; bsdlabel md${MD_DEV}s1 ; dd if=/dev/md${MD_DEV} of=/dev/null bs=64k ; bsdlabel md${MD_DEV}s1 ; mdconfig -d -u ${MD_DEV})' By changing the mdconfig "-t swap" argument to "-t malloc", the bsdlabel remains intact after the dd command completes. I've included command line recipe runs from my 10-CURRENT r250260 laptop with both "-t swap" and "-t malloc" at the end of this email for reference. Smells like a VM related problem to me, but ENOCLUE so I would appreciate some help. Cheers, Lawrence root@lstewart-laptop:~ # uname -a FreeBSD lstewart-laptop 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r250260: Wed May 22 15:57:40 EST 2013 root@lstewart-laptop:/usr/obj/usr/src/sys/GENERIC amd64 root@lstewart-laptop:~ # env MD_DEV=`mdconfig -an -t swap -s 1m -x 63 -y 16` sh -c '(fdisk -I md${MD_DEV} ; bsdlabel -w -B md${MD_DEV}s1 ; bsdlabel md${MD_DEV}s1 ; dd if=/dev/md${MD_DEV} of=/dev/null bs=64k ; bsdlabel md${MD_DEV}s1 ; mdconfig -d -u ${MD_DEV})' ******* Working on device /dev/md0 ******* fdisk: invalid fdisk partition table found # /dev/md0s1: 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 1937 16 unused 0 0 c: 1953 0 unused 0 0 # "raw" part, don't edit 16+0 records in 16+0 records out 1048576 bytes transferred in 0.001728 secs (606794497 bytes/sec) bsdlabel: /dev/md0s1: no valid label found root@lstewart-laptop:~ # env MD_DEV=`mdconfig -an -t malloc -s 1m -x 63 -y 16` sh -c '(fdisk -I md${MD_DEV} ; bsdlabel -w -B md${MD_DEV}s1 ; bsdlabel md${MD_DEV}s1 ; dd if=/dev/md${MD_DEV} of=/dev/null bs=64k ; bsdlabel md${MD_DEV}s1 ; mdconfig -d -u ${MD_DEV})' ******* Working on device /dev/md0 ******* fdisk: invalid fdisk partition table found # /dev/md0s1: 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 1937 16 unused 0 0 c: 1953 0 unused 0 0 # "raw" part, don't edit 16+0 records in 16+0 records out 1048576 bytes transferred in 0.001251 secs (838202118 bytes/sec) # /dev/md0s1: 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 1937 16 unused 0 0 c: 1953 0 unused 0 0 # "raw" part, don't edit