From patchwork Thu Mar 1 05:38:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10250585 X-Patchwork-Delegate: snitzer@redhat.com 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 EB8C360211 for ; Thu, 1 Mar 2018 09:12:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDC8928CCC for ; Thu, 1 Mar 2018 09:12:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D294B28D7A; Thu, 1 Mar 2018 09:12:51 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 677AA28CCC for ; Thu, 1 Mar 2018 09:12:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A988B5D68B; Thu, 1 Mar 2018 09:12:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EF7D620B2; Thu, 1 Mar 2018 09:12:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 322BF18033EF; Thu, 1 Mar 2018 09:12:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w215ccLv024121 for ; Thu, 1 Mar 2018 00:38:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id E07CF60C80; Thu, 1 Mar 2018 05:38:38 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAA7860BEB for ; Thu, 1 Mar 2018 05:38:35 +0000 (UTC) Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7F074E8BA for ; Thu, 1 Mar 2018 05:38:33 +0000 (UTC) Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Wed, 28 Feb 2018 22:38:24 -0700 From: Qu Wenruo To: fstests@vger.kernel.org Date: Thu, 1 Mar 2018 13:38:19 +0800 Message-Id: <20180301053821.18718-1-wqu@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 01 Mar 2018 05:38:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 01 Mar 2018 05:38:34 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'wqu@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 01 Mar 2018 04:12:01 -0500 Cc: dm-devel@redhat.com Subject: [dm-devel] [RFC PATCH] fstests: Check if a fs can survive random (emulated) power loss X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Mar 2018 09:12:50 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP This test case is originally designed to expose unexpected corruption for btrfs, where there are several reports about btrfs serious metadata corruption after power loss. The test case itself will trigger heavy fsstress for the fs, and use dm-flakey to emulate power loss by dropping all later writes. For btrfs, it should be completely fine, as long as superblock write (FUA write) finishes atomically, since with metadata CoW, superblock either points to old trees or new tress, the fs should be as atomic as superblock. For journal based filesystems, each metadata update should be journaled, so metadata operation is as atomic as journal updates. It does show that XFS is doing the best work among the tested filesystems (Btrfs, XFS, ext4), no kernel nor xfs_repair problem at all. For btrfs, although btrfs check doesn't report any problem, kernel reports some data checksum error, which is a little unexpected as data is CoWed by default, which should be as atomic as superblock. (Unfortunately, still not the exact problem I'm chasing for) For EXT4, kernel is fine, but later e2fsck reports problem, which may indicates there is still something to be improved. Signed-off-by: Qu Wenruo --- tests/generic/479 | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/479.out | 2 + tests/generic/group | 1 + 3 files changed, 112 insertions(+) create mode 100755 tests/generic/479 create mode 100644 tests/generic/479.out diff --git a/tests/generic/479 b/tests/generic/479 new file mode 100755 index 00000000..ab530231 --- /dev/null +++ b/tests/generic/479 @@ -0,0 +1,109 @@ +#! /bin/bash +# FS QA Test 479 +# +# Test if a filesystem can survive emulated powerloss. +# +# No matter what the solution a filesystem uses (journal or CoW), +# it should survive unexpected powerloss, without major metadata +# corruption. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 SuSE. 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() +{ + ps -e | grep fsstress > /dev/null 2>&1 + while [ $? -eq 0 ]; do + $KILLALL_PROG -KILL fsstress > /dev/null 2>&1 + wait > /dev/null 2>&1 + ps -e | grep fsstress > /dev/null 2>&1 + done + _unmount_flakey &> /dev/null + _cleanup_flakey + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/dmflakey + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_scratch +_require_dm_target flakey +_require_command "$KILLALL_PROG" "killall" + +runtime=$(($TIME_FACTOR * 15)) +loops=$(($LOAD_FACTOR * 4)) + +for i in $(seq -w $loops); do + echo "=== Loop $i: $(date) ===" >> $seqres.full + + _scratch_mkfs >/dev/null 2>&1 + _init_flakey + _mount_flakey + + ($FSSTRESS_PROG $FSSTRESS_AVOID -w -d $SCRATCH_MNT -n 1000000 \ + -p 100 >> $seqres.full &) > /dev/null 2>&1 + + sleep $runtime + + # Here we only want to drop all write, don't need to umount the fs + _load_flakey_table $FLAKEY_DROP_WRITES + + ps -e | grep fsstress > /dev/null 2>&1 + while [ $? -eq 0 ]; do + $KILLALL_PROG -KILL fsstress > /dev/null 2>&1 + wait > /dev/null 2>&1 + ps -e | grep fsstress > /dev/null 2>&1 + done + + _unmount_flakey + _cleanup_flakey + + # Mount the fs to do proper log replay for journal based fs + # so later check won't report annoying dirty log and only + # report real problem. + _scratch_mount + _scratch_unmount + + _check_scratch_fs +done + +echo "Silence is golden" + +# success, all done +status=0 +exit diff --git a/tests/generic/479.out b/tests/generic/479.out new file mode 100644 index 00000000..290f18b3 --- /dev/null +++ b/tests/generic/479.out @@ -0,0 +1,2 @@ +QA output created by 479 +Silence is golden diff --git a/tests/generic/group b/tests/generic/group index 1e808865..5ce3db1d 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -481,3 +481,4 @@ 476 auto rw 477 auto quick exportfs 478 auto quick +479 auto