From patchwork Thu Mar 16 09:08:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9627703 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 04073604A9 for ; Thu, 16 Mar 2017 09:09:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB0D62808F for ; Thu, 16 Mar 2017 09:09:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E013728673; Thu, 16 Mar 2017 09:09:05 +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,LOTS_OF_MONEY, RCVD_IN_DNSWL_HI autolearn=unavailable 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 8285F2808F for ; Thu, 16 Mar 2017 09:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752082AbdCPJJE (ORCPT ); Thu, 16 Mar 2017 05:09:04 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:64909 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751321AbdCPJJB (ORCPT ); Thu, 16 Mar 2017 05:09:01 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="16647190" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Mar 2017 17:09:00 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 83A8949F9A64; Thu, 16 Mar 2017 17:08:58 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 16 Mar 2017 17:08:57 +0800 From: Qu Wenruo To: CC: Subject: [PATCH v2 2/3] fstests: btrfs: Add testcase for btrfs dedupe and metadata balance race test Date: Thu, 16 Mar 2017 17:08:50 +0800 Message-ID: <20170316090851.21608-3-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170316090851.21608-1-quwenruo@cn.fujitsu.com> References: <20170316090851.21608-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 83A8949F9A64.A0C4C X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Btrfs balance with inband dedupe enable/disable will expose a lot of hidden dedupe bug: 1) Enable/disable race bug 2) Btrfs dedupe tree balance corrupted delayed_ref 3) Btrfs disable and balance will cause balance BUG_ON Reported-by: Satoru Takeuchi Signed-off-by: Qu Wenruo --- tests/btrfs/201 | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/201.out | 2 + tests/btrfs/group | 1 + 3 files changed, 116 insertions(+) create mode 100755 tests/btrfs/201 create mode 100644 tests/btrfs/201.out diff --git a/tests/btrfs/201 b/tests/btrfs/201 new file mode 100755 index 0000000..c5f6f23 --- /dev/null +++ b/tests/btrfs/201 @@ -0,0 +1,113 @@ +#! /bin/bash +# FS QA Test 201 +# +# Btrfs inband dedup enable/disable race with metadata balance +# +# This tests will test the following bugs exposed in development: +# 1) enable/disable race +# 2) tree balance cause delayed ref corruption +# 3) disable and balance cause BUG_ON +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Fujitsu. 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.* + $KILLALL_PROG $FSSTRESS_PROG &> /dev/null + kill $trigger_pid &> /dev/null + kill $balance_pid &> /dev/null + wait + + # See comment later + $BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null +} + +# 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 + +_supported_fs btrfs +_supported_os Linux +_require_command "$KILLALL_PROG" killall +_require_scratch +_require_btrfs_command dedupe +_require_btrfs_fs_feature dedupe + +# Use 64K dedupe size to keep compatibility for 64K page size +dedupe_bs=64K + +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +mkdir -p $SCRATCH_MNT/stressdir + +runtime=$((60 * $TIME_FACTOR)) + +trigger_work() +{ + while true; do + _run_btrfs_util_prog dedupe enable -s inmemory \ + -b $dedupe_bs $SCRATCH_MNT + sleep 1 + _run_btrfs_util_prog dedupe disable $SCRATCH_MNT + sleep 1 + done +} + +# redirect all output, as error output like 'balance cancelled by user' +# will populuate the golden output. +_btrfs_stress_balance -m $SCRATCH_MNT &> /dev/null & +balance_pid=$! + +$FSSTRESS_PROG $(_scale_fsstress_args -p 1 -n 10000000) $FSSTRESS_AVOID \ + -d $SCRATCH_MNT/stressdir > /dev/null 2>&1 & + +trigger_work & +trigger_pid=$! + +sleep $runtime +$KILLALL_PROG $FSSTRESS_PROG &> /dev/null +kill $trigger_pid &> /dev/null +kill $balance_pid &> /dev/null +wait + +# Manually stop balance as it's possible balance is still running for a short +# time. And we don't want to populate $seqres.full, so call $BTRFS_UTIL_PROG +# directly +$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null + +echo "Silence is golden" +# success, all done +status=0 +exit diff --git a/tests/btrfs/201.out b/tests/btrfs/201.out new file mode 100644 index 0000000..5ac973f --- /dev/null +++ b/tests/btrfs/201.out @@ -0,0 +1,2 @@ +QA output created by 201 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index 4e49564..1856d7e 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -142,3 +142,4 @@ 137 auto quick send 138 auto compress 200 auto ib-dedupe +201 auto ib-dedupe