From patchwork Mon Jan 9 13:39:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9504663 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 80AFE6075F for ; Mon, 9 Jan 2017 13:39:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A59C284AD for ; Mon, 9 Jan 2017 13:39:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F263283BA; Mon, 9 Jan 2017 13:39:39 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 89AF9284D4 for ; Mon, 9 Jan 2017 13:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754902AbdAINj2 (ORCPT ); Mon, 9 Jan 2017 08:39:28 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34717 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753251AbdAINj0 (ORCPT ); Mon, 9 Jan 2017 08:39:26 -0500 Received: by mail-wm0-f66.google.com with SMTP id c85so22087561wmi.1; Mon, 09 Jan 2017 05:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mEc8EC0E9XtVcqfLSgrmZPrQL81rhjzhrYJEpG/LUfk=; b=E5fDIxwaEBXIm/TmfCQtZtgp9DCXhX02HYwJHRknzV6Z+JGniUYlhgzDsw1NvM32F3 yid4HA6Lokh/AerH5UtSGLdTn/Mtm3zmWfw672TyI2TcUm9IrWyq+qPF7VPoHOrHVZXY HBGNKriDcsMU6F2qcHTFrwhgjfDaCJZaUypEmdm9Jf9SEy3IviUEcf20hEQJobTwpn+5 pRuFyTJ9A+uTR8l5JVoir4eSozWufl5kSz/Qqhf3FtnO2v9S3gZwK42m/Kc8oY/jZhqx 9Y4GVWRTA0ZdEglW2srUptPzMDhxF7v0XwfmTrGjqAGxl/eGNoBOHr6NsqqDFwzIQ1+c e7AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mEc8EC0E9XtVcqfLSgrmZPrQL81rhjzhrYJEpG/LUfk=; b=nbti9g8+jrLMYI/boeCWrq3CxeEoSlnwVn+SrgQWueplyxphptYFdInfi+4lnelUvo 0rS0J1YTPKWLHESTooPEGD7z3DCh6UpN+sVRI1CyrOSt5Vd1JPvVd308J/6XGGouxdtj jyq5LGLB9mZNVWBASFPa8YEgHQxq1YbqLdx+LaDdsz8XYNO+7ctxBtGTxniSJKfXPaP5 GxHbzcEppn0uvAzYEZKu0juP84Q8jF214p/lmBqP/HGtShCMws81iMZ6VEha7i4dF9KN y0dAijLzHVceqC+Cyk4Om4BTdY/wL0LkUkTRC5SZHOPt40I64GAyRlunLfRW4TeNAT6v Cl5w== X-Gm-Message-State: AIkVDXLnhhUddz0J0O+DBysgs+1AxnO47EehW1HRrOu9P31fxMdzE34T1ZVmSof1gnVYYg== X-Received: by 10.28.87.16 with SMTP id l16mr4330913wmb.111.1483969163921; Mon, 09 Jan 2017 05:39:23 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-82-81-193-202.cablep.bezeqint.net. [82.81.193.202]) by smtp.gmail.com with ESMTPSA id d10sm123579595wja.20.2017.01.09.05.39.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 05:39:23 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Brian Foster , "Darrick J . Wong" , fstests@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v3 1/3] xfs: test handling of invalid inode modes Date: Mon, 9 Jan 2017 15:39:11 +0200 Message-Id: <1483969151-30188-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483968625-29160-2-git-send-email-amir73il@gmail.com> References: <1483968625-29160-2-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Set all possible file type values for different types of files and verify that xfs_repair detects the correct errors. When setting invalid file type values (e.g. core.mode = 0170644), all files are expected to have been junked by xfs_repair. When setting valid file type values to non matching file types, xfs_repair would either detect wrong format and junk the file, e.g.: would have junked entry "DATA" in directory PARENT_INO or detect a ftype mismatch error, e.g.: would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO If ftype feature is enabled, when setting file type to one of the special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), xfs_repair is expected to detect ftype mismatch error. Otherwise, xfs_repair is not expected to detect ftype mismatch error. Signed-off-by: Amir Goldstein --- tests/xfs/348 | 129 ++++++++++++++++++++++++++++ tests/xfs/348.out | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 378 insertions(+) create mode 100755 tests/xfs/348 create mode 100644 tests/xfs/348.out diff --git a/tests/xfs/348 b/tests/xfs/348 new file mode 100755 index 0000000..c5249eb --- /dev/null +++ b/tests/xfs/348 @@ -0,0 +1,129 @@ +#! /bin/bash +# FSQA Test No. 348 +# +# Test handling of invalid inode modes +# +# Set all possible file type values for different types of files +# and verify that xfs_repair detects the correct errors. +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2016 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein +# +# 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" + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/repair + +# real QA test starts here +_supported_fs xfs +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +_scratch_mount + +# Create our test files. +testdir=$SCRATCH_MNT/test +mkdir -p $testdir +mkdir $testdir/DIR +echo 123 > $testdir/DATA +touch $testdir/EMPTY +ln -s $testdir/DATA $testdir/SYMLINK +mknod $testdir/CHRDEV c 1 1 +mknod $testdir/BLKDEV b 1 1 +mknod $testdir/FIFO p + +xfs_info $SCRATCH_MNT | grep -q "ftype=1" && FTYPE_FEATURE=1 + +# Record test dir inode for xfs_repair filter +inode_filter=$tmp.sed +rm -f $inode_filter +pino=$(ls -id $testdir | awk '{print $1}') +echo "s/inode $pino/PARENT_INO/" >> $inode_filter +echo "s/directory $pino/directory PARENT_INO/" >> $inode_filter + +inodes="" +# Record inode numbers for xfs_db commands and xfs_repair filter +for f in DIR DATA EMPTY SYMLINK CHRDEV BLKDEV FIFO; do + ino=$(ls -id $testdir/$f | awk '{print $1}') + inodes="$inodes $ino" + echo "s/inode $ino/${f}_INO/" >> $inode_filter +done + +_scratch_unmount + +# Possible mode file type values (mode & S_IFMT) >> 12 +dtypes="0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17" +echo "===== Find inode by file type:" +for dt in $dtypes; do + # Set all our test files to dt value + for ino in $inodes; do + _scratch_xfs_db -c "inode $ino" -c "print core.mode" | \ + grep -q "0${dt}0...$" && \ + (echo "dt=$dt => inode $ino" | sed -f $inode_filter) + done +done +for dt in $dtypes; do + echo + echo "===== Setting dt=$dt to all files:" + # Set all our test files to dt value + for ino in $inodes; do + _scratch_xfs_db -x -c "inode $ino" -c "write core.mode 0${dt}0644" + done + # Repair should detect the inconsistencies + # For invalid dt values, all files would have been junked. + # For valid dt values, one test file is expected to be valid. + # The rest would either have wrong format or non matching dir ftype. + _scratch_xfs_repair -n 2>&1 | tee -a $seqres.full | \ + _filter_repair | grep "^would have junked" | sed -f $inode_filter | sort -u + # If ftype feature is enabled, when setting file type to one of the + # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), + # xfs_repair is expected to detect ftype mismatch error. Otherewise, + # xfs_repair is not expected to detect ftype mismatch error. + if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then + _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \ + echo "xfs_repair should fix ftype mismatch" + else + _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \ + echo "xfs_repair should not fix ftype mismatch" + fi +done + +# Repair should detect and junk all test files +_scratch_xfs_repair 2>&1 >> $seqres.full 2>&1 || _fail "xfs_repair should not fail" + +status=0 +exit diff --git a/tests/xfs/348.out b/tests/xfs/348.out new file mode 100644 index 0000000..31cf415 --- /dev/null +++ b/tests/xfs/348.out @@ -0,0 +1,248 @@ +QA output created by 348 +===== Find inode by file type: +dt=1 => FIFO_INO +dt=2 => CHRDEV_INO +dt=4 => DIR_INO +dt=6 => BLKDEV_INO +dt=10 => DATA_INO +dt=10 => EMPTY_INO +dt=12 => SYMLINK_INO + +===== Setting dt=0 to all files: +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=1 to all files: +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=2 to all files: +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=3 to all files: +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=4 to all files: +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO + +===== Setting dt=5 to all files: +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=6 to all files: +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=7 to all files: +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=10 to all files: +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=11 to all files: +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=12 to all files: +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO + +===== Setting dt=13 to all files: +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=14 to all files: +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=15 to all files: +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=16 to all files: +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=17 to all files: +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DATA" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "EMPTY" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO diff --git a/tests/xfs/group b/tests/xfs/group index c237b50..68c2bb6 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -334,3 +334,4 @@ 345 auto quick clone 346 auto quick clone 347 auto quick clone +348 auto quick repair