From c8e6dbc88126537ce3536dc3c958b82d15c9bb87 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 21 Sep 2015 12:50:36 +1000 Subject: [PATCH] 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 Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- tests/xfs/099 | 111 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/099.out | 14 ++++++ tests/xfs/100 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/100.out | 14 ++++++ tests/xfs/101 | 111 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/101.out | 14 ++++++ tests/xfs/102 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/102.out | 14 ++++++ tests/xfs/105 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/105.out | 14 ++++++ tests/xfs/112 | 120 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/112.out | 14 ++++++ tests/xfs/113 | 116 ++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/113.out | 14 ++++++ tests/xfs/group | 7 +++ 15 files changed, 911 insertions(+) create mode 100755 tests/xfs/099 create mode 100644 tests/xfs/099.out create mode 100755 tests/xfs/100 create mode 100644 tests/xfs/100.out create mode 100755 tests/xfs/101 create mode 100644 tests/xfs/101.out create mode 100755 tests/xfs/102 create mode 100644 tests/xfs/102.out create mode 100755 tests/xfs/105 create mode 100644 tests/xfs/105.out create mode 100755 tests/xfs/112 create mode 100644 tests/xfs/112.out create mode 100755 tests/xfs/113 create mode 100644 tests/xfs/113.out diff --git a/tests/xfs/099 b/tests/xfs/099 new file mode 100755 index 00000000..6118abf3 --- /dev/null +++ b/tests/xfs/099 @@ -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 diff --git a/tests/xfs/099.out b/tests/xfs/099.out new file mode 100644 index 00000000..44268594 --- /dev/null +++ b/tests/xfs/099.out @@ -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) diff --git a/tests/xfs/100 b/tests/xfs/100 new file mode 100755 index 00000000..d5e3d3be --- /dev/null +++ b/tests/xfs/100 @@ -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 diff --git a/tests/xfs/100.out b/tests/xfs/100.out new file mode 100644 index 00000000..98d8dbc2 --- /dev/null +++ b/tests/xfs/100.out @@ -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) diff --git a/tests/xfs/101 b/tests/xfs/101 new file mode 100755 index 00000000..99f4b8fc --- /dev/null +++ b/tests/xfs/101 @@ -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 diff --git a/tests/xfs/101.out b/tests/xfs/101.out new file mode 100644 index 00000000..49430f7d --- /dev/null +++ b/tests/xfs/101.out @@ -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) diff --git a/tests/xfs/102 b/tests/xfs/102 new file mode 100755 index 00000000..641a96c6 --- /dev/null +++ b/tests/xfs/102 @@ -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 diff --git a/tests/xfs/102.out b/tests/xfs/102.out new file mode 100644 index 00000000..58f493ce --- /dev/null +++ b/tests/xfs/102.out @@ -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) diff --git a/tests/xfs/105 b/tests/xfs/105 new file mode 100755 index 00000000..2594ca36 --- /dev/null +++ b/tests/xfs/105 @@ -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 diff --git a/tests/xfs/105.out b/tests/xfs/105.out new file mode 100644 index 00000000..d8510a09 --- /dev/null +++ b/tests/xfs/105.out @@ -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) diff --git a/tests/xfs/112 b/tests/xfs/112 new file mode 100755 index 00000000..27ca6d8d --- /dev/null +++ b/tests/xfs/112 @@ -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 diff --git a/tests/xfs/112.out b/tests/xfs/112.out new file mode 100644 index 00000000..be0e61f4 --- /dev/null +++ b/tests/xfs/112.out @@ -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) diff --git a/tests/xfs/113 b/tests/xfs/113 new file mode 100755 index 00000000..21277345 --- /dev/null +++ b/tests/xfs/113 @@ -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 diff --git a/tests/xfs/113.out b/tests/xfs/113.out new file mode 100644 index 00000000..0b59fe86 --- /dev/null +++ b/tests/xfs/113.out @@ -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) diff --git a/tests/xfs/group b/tests/xfs/group index fe420680..caeac637 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -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 -- 2.39.5