Read-triggered corruption of swap backed MD devices

From: Lawrence Stewart <lstewart_at_freebsd.org>
Date: Fri, 24 May 2013 12:19:44 +1000
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_at_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_at_lstewart-laptop:/usr/obj/usr/src/sys/GENERIC  amd64



root_at_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_at_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
Received on Fri May 24 2013 - 00:19:47 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:38 UTC