From patchwork Mon Dec 15 03:54:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5490241 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8A802BEEA8 for ; Mon, 15 Dec 2014 03:57:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B6EF209F9 for ; Mon, 15 Dec 2014 03:57:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0B47209CD for ; Mon, 15 Dec 2014 03:57:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751138AbaLOD5B (ORCPT ); Sun, 14 Dec 2014 22:57:01 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:48604 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750713AbaLOD5A (ORCPT ); Sun, 14 Dec 2014 22:57:00 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="45151383" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Dec 2014 11:53:37 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sBF3uWID001530 for ; Mon, 15 Dec 2014 11:56:33 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 15 Dec 2014 11:57:00 +0800 From: Qu Wenruo To: Subject: [PATCH 1/2] btrfs-progs: Add support for btrfs-image + corrupt script fsck test case. Date: Mon, 15 Dec 2014 11:54:58 +0800 Message-ID: <1418615699-18169-1-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.1.3 MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Although btrfsck test case support pure image dump(tar.xz), it is still too large for some images, e.g, a small 64M image with about 3 levels (level 0~2) metadata will produce about 2.6M after xz zip, which is too large for a single binary commit. However btrfs-image -c9 will works much finer, the above image with btrfs-image dump will only be less than 200K, which is quite reasonable. Signed-off-by: Qu Wenruo --- tests/fsck-tests.sh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/fsck-tests.sh b/tests/fsck-tests.sh index 8987d04..007e5b0 100644 --- a/tests/fsck-tests.sh +++ b/tests/fsck-tests.sh @@ -22,16 +22,38 @@ run_check() "$@" >> $RESULT 2>&1 || _fail "failed: $@" } +# For complicated fsck repair case, +# where even repairing is OK, it may still report problem before or after +# reparing since the repair needs several loops to repair all the problems +# but report checks it before all repair loops done +run_check_no_fail() +{ + echo "############### $@" >> $RESULT 2>&1 + "$@" >> $RESULT 2>&1 +} + rm -f $RESULT # test rely on corrupting blocks tool run_check make btrfs-corrupt-block +# Supported test image formats: +# 1) btrfs-image dump(.img files) # Some broken filesystem images are kept as .img files, created by the tool -# btrfs-image, and others are kept as .tar.xz files that contain raw filesystem +# btrfs-image +# +# 2) binary image dump only(only test.img in .tar.xz) +# Some are kept as .tar.xz files that contain raw filesystem # image (the backing file of a loop device, as a sparse file). The reason for # keeping some as tarballs of raw images is that for these cases btrfs-image # isn't able to preserve all the (bad) filesystem structure for some reason. +# This provides great flexibility at the cost of large file size. +# +# 3) script generated dump(generate_image.sh + needed things in .tar.gz) +# The image is generated by the generate_image.sh script alone the needed +# files in the tarball, normally a quite small btrfs-image dump. +# This one combines the advatange of relative small btrfs-image and the +# flexibility to support corrupted image. for i in $(find $here/tests/fsck-tests -name '*.img' -o -name '*.tar.xz' | sort) do echo " [TEST] $(basename $i)" @@ -39,16 +61,24 @@ do extension=${i#*.} + if [ -f generate_image.sh ]; then + rm generate_image.sh + fi + if [ $extension == "img" ]; then run_check $here/btrfs-image -r $i test.img else run_check tar xJf $i fi + if [ -x generate_image.sh ]; then + ./generate_image.sh + fi + $here/btrfsck test.img >> $RESULT 2>&1 [ $? -eq 0 ] && _fail "btrfsck should have detected corruption" - run_check $here/btrfsck --repair test.img + run_check_no_fail $here/btrfsck --repair test.img run_check $here/btrfsck test.img done