From patchwork Thu Jan 26 19:39:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lakshmipathi.G" X-Patchwork-Id: 9540007 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 1485D604A0 for ; Thu, 26 Jan 2017 19:49:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 125342832B for ; Thu, 26 Jan 2017 19:49:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06F562833F; Thu, 26 Jan 2017 19:49:07 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 820892832B for ; Thu, 26 Jan 2017 19:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753201AbdAZTtE (ORCPT ); Thu, 26 Jan 2017 14:49:04 -0500 Received: from p3nlsmtpcp01-01.prod.phx3.secureserver.net ([184.168.200.138]:44694 "EHLO p3nlsmtpcp01-01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752658AbdAZTtD (ORCPT ); Thu, 26 Jan 2017 14:49:03 -0500 Received: from p3plcpnl0639.prod.phx3.secureserver.net ([50.62.176.166]) by : HOSTING RELAY : with SMTP id WptMclwdBk2itWptMcZWYN; Thu, 26 Jan 2017 12:39:32 -0700 Received: from [117.221.128.168] (port=43668 helo=giis.co.in) by p3plcpnl0639.prod.phx3.secureserver.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cWptL-0000wb-MK; Thu, 26 Jan 2017 12:39:32 -0700 Date: Fri, 27 Jan 2017 01:09:26 +0530 From: "Lakshmipathi.G" To: dsterba@suse.cz, linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: fsck-tests: script to verify init-csum-tree Message-ID: <20170126193926.GA12017@giis.co.in> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - p3plcpnl0639.prod.phx3.secureserver.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - giis.co.in X-Get-Message-Sender-Via: p3plcpnl0639.prod.phx3.secureserver.net: authenticated_id: lakshmipathi.g@giis.co.in X-Authenticated-Sender: p3plcpnl0639.prod.phx3.secureserver.net: lakshmipathi.g@giis.co.in X-Source: X-Source-Args: X-Source-Dir: X-CMAE-Envelope: MS4wfMLpq0N5AA/LEqI0ZwsOlD2xZkMG5CsvAWOBnxKU6KSNfas2eEXaoX9/6VZ89L0HpCMf4tMnHlT1USAE6Cjzz5Xj6jYwF99GFTSTUlDWuXnDnIZIsvEB BVHyJCuanK2rFS/9miybBywo+vPy/bwuiPM3RI8bFxcdybROkpBGciJ2dku5H0TM+nBHu2rAFaRPX19Hs1Xa9QmT9eA2pgnpCjlF94Hu5ggvdxO9s7B8Xlpr 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 Corrupt csum entry of a file and re-create csum tree using --init-csum Signed-off-by: Lakshmipathi.G --- .../fsck-tests/025-verify-init-csum-option/test.sh | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 tests/fsck-tests/025-verify-init-csum-option/test.sh diff --git a/tests/fsck-tests/025-verify-init-csum-option/test.sh b/tests/fsck-tests/025-verify-init-csum-option/test.sh new file mode 100755 index 0000000..f496b33 --- /dev/null +++ b/tests/fsck-tests/025-verify-init-csum-option/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# This is a basic script to verify --init-csum recreates the csum tree. + +source $TOP/tests/common + +check_prereq btrfs-corrupt-block +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev 512M + + +# simulate missing csum error and repair using init-csum option +test_csum_corruption() +{ + run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV + + run_check_mount_test_dev + + export DATASET_SIZE=1 + generate_dataset small + + run_check_umount_test_dev + + # find bytenr + bytenr=`$SUDO_HELPER $TOP/btrfs inspect-internal dump-tree -t csum $TEST_DEV | \ + sed -n -r 's/.*EXTENT_CSUM (.*)\) itemoff .*/\1/p'` + + # corrupt csum bytenr + run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -C $bytenr $TEST_DEV + $SUDO_HELPER $TOP/btrfs check $TEST_DEV &>> $RESULTS && \ + _fail "btrfs check failed to detect missing csum." + run_check $SUDO_HELPER $TOP/btrfs check --repair --init-csum $TEST_DEV + run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV +} + +test_csum_corruption