linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: [PATCH v4 6/6] fstests: btrfs: Test for btrfs dedup tree balance bug
Date: Wed,  9 Mar 2016 16:33:44 +0800	[thread overview]
Message-ID: <1457512424-9215-7-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1457512424-9215-1-git-send-email-quwenruo@cn.fujitsu.com>

Btrfs in-band de-duplication has a bug when dedup tree metadata is
balanced, it will corrupted btrfs delayed ref and cause the following
kernel warning:

BTRFS error (device sdb6): unable to find ref byte nr 29736960 parent 0
root 11  owner 0 offset 0
------------[ cut here ]------------
WARNING: CPU: 1 PID: 19113 at fs/btrfs/extent-tree.c:6636
__btrfs_free_extent.isra.66+0xb6d/0xd20 [btrfs]()
BTRFS: Transaction aborted (error -2)
Modules linked in: btrfs(O) xor zlib_deflate raid6_pq xfs [last
unloaded: btrfs]
CPU: 1 PID: 19113 Comm: btrfs Tainted: G        W  O    4.5.0-rc5+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox
12/01/2006
 0000000000000000 ffff880035b0ba18 ffffffff813771ff ffff880035b0ba60
 ffffffffa06a810a ffff880035b0ba50 ffffffff810bcb81 ffff88003c45c528
 0000000001c5c000 00000000fffffffe ffff88003dc8c520 0000000000000000
Call Trace:
 [<ffffffff813771ff>] dump_stack+0x67/0x98
 [<ffffffff810bcb81>] warn_slowpath_common+0x81/0xc0
 [<ffffffff810bcc07>] warn_slowpath_fmt+0x47/0x50
 [<ffffffffa06028fd>] __btrfs_free_extent.isra.66+0xb6d/0xd20 [btrfs]
 [<ffffffffa0606d4d>] __btrfs_run_delayed_refs.constprop.71+0x96d/0x1560
[btrfs]
 [<ffffffff81202ad9>] ? cmpxchg_double_slab.isra.68+0x149/0x160
 [<ffffffff81106a1d>] ? trace_hardirqs_on+0xd/0x10
 [<ffffffffa060a5ce>] btrfs_run_delayed_refs+0x8e/0x2d0 [btrfs]
 [<ffffffffa06209fe>] btrfs_commit_transaction+0x3e/0xb50 [btrfs]
 [<ffffffffa069f26e>] ? btrfs_dedup_disable+0x28e/0x2c0 [btrfs]
 [<ffffffff812035c3>] ? kfree+0x223/0x270
 [<ffffffffa069f27a>] btrfs_dedup_disable+0x29a/0x2c0 [btrfs]
 [<ffffffffa065e403>] btrfs_ioctl+0x2363/0x2a40 [btrfs]
 [<ffffffff8116b12a>] ? __audit_syscall_entry+0xaa/0xf0
 [<ffffffff81137ce6>] ? current_kernel_time64+0x56/0xa0
 [<ffffffff8122080e>] do_vfs_ioctl+0x8e/0x690
 [<ffffffff8116b12a>] ? __audit_syscall_entry+0xaa/0xf0
 [<ffffffff8122c181>] ? __fget_light+0x61/0x90
 [<ffffffff81220e84>] SyS_ioctl+0x74/0x80
 [<ffffffff8180ad57>] entry_SYSCALL_64_fastpath+0x12/0x6f
---[ end trace 618d5a5bc21d6a7c ]---

Add regression test case for it.

Reported-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 tests/btrfs/204     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/204.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100755 tests/btrfs/204
 create mode 100644 tests/btrfs/204.out

diff --git a/tests/btrfs/204 b/tests/btrfs/204
new file mode 100755
index 0000000..5baecf8
--- /dev/null
+++ b/tests/btrfs/204
@@ -0,0 +1,74 @@
+#! /bin/bash
+# FS QA Test 204
+#
+# Regression test for dedup tree metadata balance
+# If btrfs balanced dedup tree block twice, delayed ref will be corrupted
+# and cause kernel warning with RO fs.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_subcommand dedup
+_require_btrfs_fs_feature dedup
+_require_btrfs_mkfs_feature dedup
+
+_scratch_mkfs "-O dedup" >> $seqres.full 2>&1
+_scratch_mount
+
+_run_btrfs_util_prog dedup enable $SCRATCH_MNT
+
+# Balance btrfs metadata twice, this will ensure the second balance
+# to drop refence on old dedup root bytenr if kernel has the dedup bug
+_run_btrfs_util_prog balance start -m $SCRATCH_MNT
+_run_btrfs_util_prog balance start -m $SCRATCH_MNT
+
+# Disable will force a sync_fs() and cause kernel warning
+_run_btrfs_util_prog dedup disable $SCRATCH_MNT
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/204.out b/tests/btrfs/204.out
new file mode 100644
index 0000000..1035eae
--- /dev/null
+++ b/tests/btrfs/204.out
@@ -0,0 +1,2 @@
+QA output created by 204
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index fa90f33..089e4a8 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -123,3 +123,4 @@
 201 auto dedup
 202 auto dedup
 203 auto dedup balance
+204 auto quick dedup
-- 
2.7.2




  parent reply	other threads:[~2016-03-09  8:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09  8:33 [PATCH v4 0/6] Btrfs in-band de-duplication test cases Qu Wenruo
2016-03-09  8:33 ` [PATCH v4 1/6] fstests: rename _require_btrfs to _require_btrfs_subcommand Qu Wenruo
2016-03-09  8:33 ` [PATCH v4 2/6] fstests: btrfs: Add basic test for btrfs in-band de-duplication Qu Wenruo
2016-03-09  8:33 ` [PATCH v4 3/6] fstests: btrfs: Add testcase for btrfs dedup enable disable race test Qu Wenruo
2016-03-09  8:33 ` [PATCH v4 4/6] fstests: btrfs: Add per inode dedup flag test Qu Wenruo
2016-03-09  8:33 ` [PATCH v4 5/6] fstests: btrfs: Test inband dedup with balance Qu Wenruo
2016-03-09  8:33 ` Qu Wenruo [this message]
2016-03-14  7:56 ` [PATCH v4 0/6] Btrfs in-band de-duplication test cases Qu Wenruo
2016-03-14 17:24   ` Darrick J. Wong
2016-03-15  1:23     ` Qu Wenruo
2016-03-15  2:42     ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457512424-9215-7-git-send-email-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).