From patchwork Tue Jan 2 20:35:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10141383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8DD9760362 for ; Tue, 2 Jan 2018 21:37:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8072428D9E for ; Tue, 2 Jan 2018 21:37:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7557C28E53; Tue, 2 Jan 2018 21:37:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D783028D9E for ; Tue, 2 Jan 2018 21:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750913AbeABVhl (ORCPT ); Tue, 2 Jan 2018 16:37:41 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:44808 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbeABVhk (ORCPT ); Tue, 2 Jan 2018 16:37:40 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id w02Lb8Yo152807; Tue, 2 Jan 2018 21:37:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=9dbuAzg0RP5mDEVQNcBFPvCcUrmap6mnPsJHs37bmwI=; b=V8qeBvJyHG7XuZLWtg9M/FY7jJarMpG9Kwlxqt5CEaT5YsnD3/fPkCKaCYZebErTdGm7 mK6fjNZ1Efwp7eYRJvayM3NCGcsim70IMMM8K+8NhoRTsI4mH4LkaA4ywyi2p+lQuhIo sUALGwrBPIa15fan1kfHOA0VWKIUH+rBbniK32Pz2SZjPQqVZN3y8dsngEexjxqZfZoG FxV/85wv66ysrQPBM5eJwt3seitRN5WQi/0ubvJX8tZSsNREMkMFPEafZXrnFQVhh4bP JsxMBJgVrn7t1vqE3aAV8z2ACjUMgdxyUhdR3dMYFzdq4UOHqVmtH8uQJZuKonjqw/5S rw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2f8hua82mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Jan 2018 21:37:39 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w02Lbcnd031425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 2 Jan 2018 21:37:38 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w02LbcMh012002; Tue, 2 Jan 2018 21:37:38 GMT Received: from dhcp-10-211-47-181.usdhcp.oraclecorp.com.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 02 Jan 2018 13:37:37 -0800 From: Liu Bo To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] fstests: btrfs/158: reproduce a scrub bug on raid6 corruption Date: Tue, 2 Jan 2018 13:35:00 -0700 Message-Id: <20180102203500.12713-1-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8762 signatures=668650 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=52 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801020301 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is to reproduce a bug of scrub, with which scrub is unable to repair raid6 corruption as expected. The kernel side fixes are Btrfs: make raid6 rebuild retry more Btrfs: fix scrub to repair raid6 corruption Signed-off-by: Liu Bo --- tests/btrfs/158 | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/158.out | 10 +++++ tests/btrfs/group | 1 + 3 files changed, 125 insertions(+) create mode 100755 tests/btrfs/158 create mode 100644 tests/btrfs/158.out diff --git a/tests/btrfs/158 b/tests/btrfs/158 new file mode 100755 index 0000000..43afc2d --- /dev/null +++ b/tests/btrfs/158 @@ -0,0 +1,114 @@ +#! /bin/bash +# FS QA Test 158 +# +# The test case is check if scrub is able fix raid6 data corruption, +# ie. if there is data corruption on two disks in the same horizontal +# stripe, e.g. due to bitrot. +# +# The kernel fixes are +# Btrfs: make raid6 rebuild retry more +# Btrfs: fix scrub to repair raid6 corruption +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Oracle. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs btrfs +_supported_os Linux +_require_scratch_dev_pool 4 +_require_btrfs_command inspect-internal dump-tree + +get_physical_stripe0() +{ + $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \ + grep " DATA\|RAID6" -A 10 | \ + $AWK_PROG '($1 ~ /stripe/ && $3 ~ /devid/ && $2 ~ /0/) { print $6 }' +} + +get_physical_stripe1() +{ + $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \ + grep " DATA\|RAID6" -A 10 | \ + $AWK_PROG '($1 ~ /stripe/ && $3 ~ /devid/ && $2 ~ /1/) { print $6 }' +} + +_scratch_dev_pool_get 4 +# step 1: create a raid6 btrfs and create a 4K file +echo "step 1......mkfs.btrfs" >>$seqres.full + +mkfs_opts="-d raid6 -b 1G" +_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1 + +# -o nospace_cache makes sure data is written to the start position of the data +# chunk +_scratch_mount -o nospace_cache + +# [0,64K) is written to stripe 0 and [64K, 128K) is written to stripe 1 +$XFS_IO_PROG -f -d -c "pwrite -S 0xaa 0 128K" -c "fsync" \ + "$SCRATCH_MNT/foobar" | _filter_xfs_io + +_scratch_unmount + +stripe_0=`get_physical_stripe0` +stripe_1=`get_physical_stripe1` +dev4=`echo $SCRATCH_DEV_POOL | awk '{print $4}'` +dev3=`echo $SCRATCH_DEV_POOL | awk '{print $3}'` + +# step 2: corrupt the 1st and 2nd stripe (stripe 0 and 1) +echo "step 2......simulate bitrot at offset $stripe_0 of device_4($dev4) and offset $stripe_1 of device_3($dev3)" >>$seqres.full + +$XFS_IO_PROG -f -d -c "pwrite -S 0xbb $stripe_0 64K" $dev4 | _filter_xfs_io +$XFS_IO_PROG -f -d -c "pwrite -S 0xbb $stripe_1 64K" $dev3 | _filter_xfs_io + +# step 3: read foobar to repair the bitrot +echo "step 3......repair the bitrot" >> $seqres.full +_scratch_mount -o nospace_cache + +btrfs scrub start -B $SCRATCH_MNT >> $seqres.full 2>&1 + +od -x $SCRATCH_MNT/foobar + +_scratch_dev_pool_put + +# success, all done +status=0 +exit diff --git a/tests/btrfs/158.out b/tests/btrfs/158.out new file mode 100644 index 0000000..1f5ad3f --- /dev/null +++ b/tests/btrfs/158.out @@ -0,0 +1,10 @@ +QA output created by 158 +wrote 131072/131072 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 9437184 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 9437184 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +0000000 aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa +* +0400000 diff --git a/tests/btrfs/group b/tests/btrfs/group index f68abf4..0b3cf12 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -160,3 +160,4 @@ 155 auto quick send 156 auto quick trim 157 auto quick raid +158 auto quick raid