From patchwork Tue Feb 14 21:31:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lakshmipathi.G" X-Patchwork-Id: 9572955 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 E0E75601E7 for ; Tue, 14 Feb 2017 21:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFB7726E4C for ; Tue, 14 Feb 2017 21:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C127127813; Tue, 14 Feb 2017 21:32:42 +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 C273026E4C for ; Tue, 14 Feb 2017 21:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751577AbdBNVcj (ORCPT ); Tue, 14 Feb 2017 16:32:39 -0500 Received: from p3nlsmtpcp01-03.prod.phx3.secureserver.net ([184.168.200.142]:59058 "EHLO p3nlsmtpcp01-03.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751441AbdBNVci (ORCPT ); Tue, 14 Feb 2017 16:32:38 -0500 Received: from p3plcpnl0639.prod.phx3.secureserver.net ([50.62.176.166]) by : HOSTING RELAY : with SMTP id dkhFcC7gkQTQJdkhFcyuVV; Tue, 14 Feb 2017 14:31:37 -0700 Received: from [42.109.217.201] (port=28955 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 1cdkhE-0003yK-QA for linux-btrfs@vger.kernel.org; Tue, 14 Feb 2017 14:31:37 -0700 Date: Wed, 15 Feb 2017 03:01:25 +0530 From: "Lakshmipathi.G" To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: misc-tests: Primary Superblock corruption and recovery using backup Superblock. Message-ID: <20170214213125.GA25514@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: MS4wfFbqPK4qVG27cOuBc+BqfeKwWU+CyQyA5DxTsxJlkxf5DEgda1atnLf7dAJXBOkBhaLjDlHwgfN2hru8EpGH1f6T5X4COhXDaTZPoHkIWTv8WVK5jhGz qFMfmjv3W4e+XSCFthGGN3XQ8CGReF1iI82wjE+3qJCxpy2OxBPbK0NvDL7ylCoEBGS1hODP9Mf7TaqgL7/5AuEcrb1uzgiaLhgVu1S5W1nRmycj/h9R14VF 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 Signed-off-by: Lakshmipathi.G --- .../019-fix-corrupted-superblock/test.sh | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 tests/misc-tests/019-fix-corrupted-superblock/test.sh diff --git a/tests/misc-tests/019-fix-corrupted-superblock/test.sh b/tests/misc-tests/019-fix-corrupted-superblock/test.sh new file mode 100755 index 0000000..806c775 --- /dev/null +++ b/tests/misc-tests/019-fix-corrupted-superblock/test.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Corrupt primary superblock and restore it using backup superblock. +# + +source $TOP/tests/common + +check_prereq btrfs-select-super + +setup_root_helper +prepare_test_dev 512M + +superblock_offset=65536 + +test_superblock_restore() +{ + run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV + + # Corrupt superblock checksum + dd if=/dev/zero of=$TEST_DEV seek=$superblock_offset bs=1 \ + count=4 conv=notrunc &> /dev/null + run_check_stdout $SUDO_HELPER mount $TEST_DEV $TEST_MNT | \ + grep -q 'wrong fs type' + if [ $? -ne 0 ]; then + _fail "Failed to corrupt superblock." + fi + + # Copy backup superblock to primary + run_check $TOP/btrfs-select-super -s 1 $TEST_DEV + run_check $SUDO_HELPER mount $TEST_DEV $TEST_MNT + if [ $? -ne 0 ]; then + _fail "Failed to fix superblock." + fi + run_check_umount_test_dev +} + +test_superblock_restore