From patchwork Sat Jan 28 10:47: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: 9543171 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 86FE760429 for ; Sat, 28 Jan 2017 10:49:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67D0B2808F for ; Sat, 28 Jan 2017 10:49:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49F3228319; Sat, 28 Jan 2017 10:49:13 +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=-3.3 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB 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 20B8C2808F for ; Sat, 28 Jan 2017 10:49:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751184AbdA1Ksg (ORCPT ); Sat, 28 Jan 2017 05:48:36 -0500 Received: from p3nlsmtpcp01-02.prod.phx3.secureserver.net ([184.168.200.140]:59144 "EHLO p3nlsmtpcp01-02.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbdA1Kse (ORCPT ); Sat, 28 Jan 2017 05:48:34 -0500 Received: from p3plcpnl0639.prod.phx3.secureserver.net ([50.62.176.166]) by : HOSTING RELAY : with SMTP id XQXdcdkVOW2NbXQXdcnjIQ; Sat, 28 Jan 2017 03:47:33 -0700 Received: from [59.93.8.190] (port=36976 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 1cXQXc-00064z-RQ; Sat, 28 Jan 2017 03:47:33 -0700 Date: Sat, 28 Jan 2017 16:17:26 +0530 From: "Lakshmipathi.G" To: quwenruo@cn.fujitsu.com, dsterba@suse.cz, linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: fsck-tests: verify 'btrfs check --repair' fixes corrupted nlink field Message-ID: <20170128104726.GA4757@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: MS4wfABQxdGkmxqJHH5vZtr1gjPscey3/EXoRkGeQhfVyTZeQ5VXym7fzACo5Bx6T2RPlzwKhHZhgM7q15W4FSEMPzgBMXwJDjAI3tWGsg50rL7Hof8FRwkj GRjAstCigdaMHZAVt97S9U+4wG6Rizxju3rkELJfy0/89Z+5Qr0rB8iQDf6codTx6/ejHBDa3ZxOUBPrQuxwilRqzX+iFHksOuHzNJQ01i3sXy7qzJhyLYGW 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 --- tests/fsck-tests/026-check-inode-link/test.sh | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/fsck-tests/026-check-inode-link/test.sh diff --git a/tests/fsck-tests/026-check-inode-link/test.sh b/tests/fsck-tests/026-check-inode-link/test.sh new file mode 100755 index 0000000..9e75ef4 --- /dev/null +++ b/tests/fsck-tests/026-check-inode-link/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +source $TOP/tests/common + +check_prereq btrfs-corrupt-block +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev 512M + +# verify that 'btrfs check --repair' fixes corrupted inode nlink field. +test_inode_nlink_field() +{ + run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV + + run_check_mount_test_dev + run_check $SUDO_HELPER touch $TEST_MNT/test_nlink.txt + + # find inode_item id + inode_item=`stat -c%i $TEST_MNT/test_nlink.txt` + run_check_umount_test_dev + + # corrupt nlink field of inode object + run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -i $inode_item \ + -f nlink $TEST_DEV + + $SUDO_HELPER $TOP/btrfs check $TEST_DEV &>> $RESULTS && \ + _fail "btrfs check failed to detect nlink corruption" + run_check $SUDO_HELPER $TOP/btrfs check --repair $TEST_DEV + run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV +} + +test_inode_nlink_field