xfs: test directory metadata corruption checking and repair

Targeted fuzzing tests which destroy various pieces of directory
metadata; the tests look for (a) kernel detection of corruption, (b)
xfs_repair repair of said corruption, and (c) post-repair fs
usability.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Darrick J. Wong
2015-09-21 12:50:36 +10:00
committed by Dave Chinner
parent d492bcd86b
commit c8e6dbc881
15 changed files with 911 additions and 0 deletions
Executable
+111
View File
@@ -0,0 +1,111 @@
#! /bin/bash
# FS QA Test No. 099
#
# Create and populate an XFS filesystem, corrupt a block directory, then see
# how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((dblksz / 40))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}"
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" block
echo "+ corrupt dir"
$XFS_DB_PROG -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
_scratch_xfs_repair >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 016
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
Executable
+116
View File
@@ -0,0 +1,116 @@
#! /bin/bash
# FS QA Test No. 100
#
# Create and populate an XFS filesystem, corrupt a leaf directory's data
# extent, then see how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((dblksz / 12))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}"
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" leaf
echo "+ corrupt dir"
loff=0
while true; do
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
loff="$((loff + 1))"
done
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
_scratch_xfs_repair >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 017
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
Executable
+111
View File
@@ -0,0 +1,111 @@
#! /bin/bash
# FS QA Test No. 101
#
# Create and populate an XFS filesystem, corrupt a leaf directory's leaf
# extent, then see how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((dblksz / 12))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}"
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" leaf
echo "+ corrupt dir"
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
_scratch_xfs_repair >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 018
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
Executable
+116
View File
@@ -0,0 +1,116 @@
#! /bin/bash
# FS QA Test No. 102
#
# Create and populate an XFS filesystem, corrupt a node directory's data
# extent, then see how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((16 * dblksz / 40))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}" true
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
echo "+ corrupt dir"
loff=0
while true; do
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
loff="$((loff + 1))"
done
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
_scratch_xfs_repair >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 019
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
Executable
+116
View File
@@ -0,0 +1,116 @@
#! /bin/bash
# FS QA Test No. 105
#
# Create and populate an XFS filesystem, corrupt a node directory's leaf
# extent, then see how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((16 * dblksz / 40))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}" true
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
echo "+ corrupt dir"
loff="${leaf_lblk}"
while true; do
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
loff="$((loff + 1))"
done
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
_scratch_xfs_repair >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 105
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
Executable
+120
View File
@@ -0,0 +1,120 @@
#! /bin/bash
# FS QA Test No. 112
#
# Create and populate an XFS filesystem, corrupt a node directory's freeindex
# extent, then see how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((16 * dblksz / 40))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}" true
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
echo "+ corrupt dir"
loff="${node_lblk}"
while true; do
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
loff="$((loff + 1))"
done
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
if [ $? -eq 2 ]; then
_scratch_mount
umount "${SCRATCH_MNT}"
_scratch_xfs_repair >> $seqres.full 2>&1
fi
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 112
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
Executable
+116
View File
@@ -0,0 +1,116 @@
#! /bin/bash
# FS QA Test No. 113
#
# Create and populate an XFS filesystem, corrupt a btree directory's data
# extent, then see how the kernel and xfs_repair deal with it.
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
#
# 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"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
#rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
# real QA test starts here
_supported_fs xfs
_supported_os Linux
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
_require_attrs
_require_xfs_db_blocktrash_z_command
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
rm -f $seqres.full
echo "+ create scratch fs"
_scratch_mkfs_xfs > /dev/null
echo "+ mount fs image"
_scratch_mount
dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
nr="$((128 * dblksz / 40))"
blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
leaf_lblk="$((32 * 1073741824 / blksz))"
node_lblk="$((64 * 1073741824 / blksz))"
echo "+ make some files"
__populate_create_dir "${SCRATCH_MNT}/blockdir" "${nr}" true
inode="$(stat -c '%i' "${SCRATCH_MNT}/blockdir")"
umount "${SCRATCH_MNT}"
echo "+ check fs"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
echo "+ check dir"
__populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" btree
echo "+ corrupt dir"
loff=0
while true; do
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
loff="$((loff + 1))"
done
echo "+ mount image"
_scratch_mount
echo "+ modify dir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
umount "${SCRATCH_MNT}"
echo "+ repair fs"
_scratch_xfs_repair >> $seqres.full 2>&1
_scratch_xfs_repair >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount
echo "+ chattr -R -i"
chattr -R -f -i "${SCRATCH_MNT}/"
echo "+ modify dir (2)"
mkdir -p "${SCRATCH_MNT}/blockdir"
rm -rf "${SCRATCH_MNT}/blockdir/00000000" || _fail "couldn't modify repaired directory"
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" || _fail "add to repaired directory"
umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
status=0
exit
+14
View File
@@ -0,0 +1,14 @@
QA output created by 113
+ create scratch fs
+ mount fs image
+ make some files
+ check fs
+ check dir
+ corrupt dir
+ mount image
+ modify dir
+ repair fs
+ mount image (2)
+ chattr -R -i
+ modify dir (2)
+ check fs (2)
+7
View File
@@ -96,14 +96,21 @@
096 mkfs v2log auto quick
097 fuzzers
098 fuzzers
099 fuzzers
100 fuzzers
101 fuzzers
102 fuzzers
103 metadata dir ioctl auto quick
104 growfs ioctl prealloc auto stress
105 fuzzers
106 quota
107 quota
108 quota auto quick
109 metadata auto
110 repair auto
111 ioctl
112 fuzzers
113 fuzzers
114 parent attr stress
115 parent attr
116 quota auto quick