* [PATCH 1/7] common: add routines to fuzz filesystems
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
2015-08-15 1:52 ` [PATCH 2/7] randomly fuzz XFS and ext4 filesystems Darrick J. Wong
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
Create common/populate with routines to support the new fuzz tests.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
common/populate | 546 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 546 insertions(+)
create mode 100644 common/populate
diff --git a/common/populate b/common/populate
new file mode 100644
index 0000000..d166c24
--- /dev/null
+++ b/common/populate
@@ -0,0 +1,546 @@
+##/bin/bash
+# Routines for populating a scratch fs, and helpers to exercise an FS
+# once it's been fuzzed.
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle. 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will 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 to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
+# Mountain View, CA 94043, USA, or: http://www.sgi.com
+#-----------------------------------------------------------------------
+
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+
+_require_xfs_db_blocktrash_z_command() {
+ test "${FSTYP}" = "xfs" || _notrun "cannot run xfs_db on ${FSTYP}"
+ $XFS_DB_PROG -x -f -c 'blocktrash -z' "${TEST_DEV}" | grep -q 'nothing on stack' || _notrun "blocktrash -z not supported"
+}
+
+# Attempt to make files of "every" format for data, dirs, attrs etc.
+# (with apologies to Eric Sandeen for mutating xfser.sh)
+
+# Create a large directory
+__populate_create_dir() {
+ name="$1"
+ nr="$2"
+ missing="$3"
+
+ mkdir -p "${name}"
+ seq 0 "${nr}" | while read d; do
+ creat=mkdir
+ test "$((d % 20))" -eq 0 && creat=touch
+ $creat "${name}/$(printf "%.08d" "$d")"
+ done
+
+ test -z "${missing}" && return
+ seq 1 2 "${nr}" | while read d; do
+ rm -rf "${name}/$(printf "%.08d" "$d")"
+ done
+}
+
+# Add a bunch of attrs to a file
+__populate_create_attr() {
+ name="$1"
+ nr="$2"
+ missing="$3"
+
+ touch "${name}"
+ seq 0 "${nr}" | while read d; do
+ setfattr -n "user.$(printf "%.08d" "$d")" -v "$(printf "%.08d" "$d")" "${name}"
+ done
+
+ test -z "${missing}" && return
+ seq 1 2 "${nr}" | while read d; do
+ setfattr -x "user.$(printf "%.08d" "$d")" "${name}"
+ done
+}
+
+# Fill up 60% of the remaining free space
+__populate_fill_fs() {
+ dir="$1"
+ pct="$2"
+ test -z "${pct}" && pct=60
+
+ SRC_SZ="$(du -ks "${SRCDIR}" | cut -f 1)"
+ FS_SZ="$(( $(stat -f "${dir}" -c '%a * %S') / 1024 ))"
+
+ NR="$(( (FS_SZ * ${pct} / 100) / SRC_SZ ))"
+ test "${NR}" -lt 1 && NR=1
+
+ seq 1 "${NR}" | while read nr; do
+ cp -pRdu "${SRCDIR}" "${dir}/test.${nr}" >> $seqres.full 2>&1
+ done
+}
+
+# Populate an XFS on the scratch device with (we hope) all known
+# types of metadata block
+_scratch_xfs_populate() {
+ _scratch_mount
+ blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+ dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
+ leaf_lblk="$((32 * 1073741824 / blksz))"
+ node_lblk="$((64 * 1073741824 / blksz))"
+
+ # Data:
+
+ # Regular files
+ # - FMT_EXTENTS
+ echo "+ extents file"
+ $XFS_IO_PROG -f -c "pwrite -S 0x61 0 ${blksz}" "${SCRATCH_MNT}/S_IFREG.FMT_EXTENTS"
+
+ # - FMT_BTREE
+ echo "+ btree extents file"
+ nr="$((blksz * 2 / 16))"
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/S_IFREG.FMT_BTREE"
+ for i in $(seq 1 2 ${nr}); do
+ $XFS_IO_PROG -f -c "fpunch $((i * blksz)) ${blksz}" "${SCRATCH_MNT}/S_IFREG.FMT_BTREE"
+ done
+
+ # Directories
+ # - INLINE
+ echo "+ inline dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_INLINE" 1
+
+ # - BLOCK
+ echo "+ block dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_BLOCK" "$((dblksz / 40))"
+
+ # - LEAF
+ echo "+ leaf dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_LEAF" "$((dblksz / 12))"
+
+ # - NODE
+ echo "+ node dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_NODE" "$((16 * dblksz / 40))" true
+
+ # - BTREE
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_BTREE" "$((128 * dblksz / 40))" true
+
+ # Symlinks
+ # - FMT_LOCAL
+ echo "+ inline symlink"
+ ln -s target "${SCRATCH_MNT}/S_IFLNK.FMT_LOCAL"
+
+ # - FMT_EXTENTS
+ echo "+ extents symlink"
+ ln -s "$(perl -e 'print "x" x 1023;')" "${SCRATCH_MNT}/S_IFLNK.FMT_EXTENTS"
+
+ # Char & block
+ echo "+ special"
+ mkdir devices
+ mknod "${SCRATCH_MNT}/S_IFCHR" c 1 1
+ mknod "${SCRATCH_MNT}/S_IFBLK" c 1 1
+
+ # Attribute formats
+ # LOCAL
+ echo "+ local attr"
+ __populate_create_attr "${SCRATCH_MNT}/ATTR.FMT_LOCAL" 1
+
+ # LEAF
+ echo "+ leaf attr"
+ __populate_create_attr "${SCRATCH_MNT}/ATTR.FMT_LEAF" "$((blksz / 40))"
+
+ # NODE
+ echo "+ node attr"
+ __populate_create_attr "${SCRATCH_MNT}/ATTR.FMT_NODE" "$((8 * blksz / 40))"
+
+ # BTREE
+ echo "+ btree attr"
+ __populate_create_attr "${SCRATCH_MNT}/ATTR.FMT_BTREE" "$((64 * blksz / 40))" true
+
+ # FMT_EXTENTS with a remote less-than-a-block value
+ echo "+ attr extents with a remote less-than-a-block value"
+ touch "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE3K"
+ $XFS_IO_PROG -f -c "pwrite -S 0x43 0 3k" "${SCRATCH_MNT}/attrvalfile" > /dev/null
+ attr -q -s user.remotebtreeattrname "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE3K" < "${SCRATCH_MNT}/attrvalfile"
+
+ # FMT_EXTENTS with a remote block-size value
+ echo "+ attr extents with a remote one-block value"
+ touch "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE4K"
+ $XFS_IO_PROG -f -c "pwrite -S 0x44 0 4k" "${SCRATCH_MNT}/attrvalfile" > /dev/null
+ attr -q -s user.remotebtreeattrname "${SCRATCH_MNT}/ATTR.FMT_EXTENTS_REMOTE4K" < "${SCRATCH_MNT}/attrvalfile"
+ rm -rf "${SCRATCH_MNT}/attrvalfile"
+
+ # Make an unused inode
+ echo "+ empty file"
+ touch "${SCRATCH_MNT}/unused"
+ $XFS_IO_PROG -f -c 'fsync' "${SCRATCH_MNT}/unused"
+ rm -rf "${SCRATCH_MNT}/unused"
+
+ # Copy some real files (xfs tests, I guess...)
+ echo "+ real files"
+ #__populate_fill_fs "${SCRATCH_MNT}" 40
+ cp -pRdu --reflink=always "${SCRATCH_MNT}/S_IFREG.FMT_BTREE" "${SCRATCH_MNT}/S_IFREG.FMT_BTREE.REFLINK" 2> /dev/null
+
+ umount "${SCRATCH_MNT}"
+}
+
+# Populate an ext4 on the scratch device with (we hope) all known
+# types of metadata block
+_scratch_ext4_populate() {
+ _scratch_mount
+ blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+ dblksz="${blksz}"
+ leaf_lblk="$((32 * 1073741824 / blksz))"
+ node_lblk="$((64 * 1073741824 / blksz))"
+
+ # Data:
+
+ # Regular files
+ # - FMT_INLINE
+ echo "+ inline file"
+ $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1" "${SCRATCH_MNT}/S_IFREG.FMT_INLINE"
+
+ # - FMT_EXTENTS
+ echo "+ extents file"
+ $XFS_IO_PROG -f -c "pwrite -S 0x61 0 ${blksz}" "${SCRATCH_MNT}/S_IFREG.FMT_EXTENTS"
+
+ # - FMT_ETREE
+ echo "+ extent tree file"
+ nr="$((blksz * 2 / 12))"
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" "${SCRATCH_MNT}/S_IFREG.FMT_ETREE"
+ for i in $(seq 1 2 ${nr}); do
+ $XFS_IO_PROG -f -c "fpunch $((i * blksz)) ${blksz}" "${SCRATCH_MNT}/S_IFREG.FMT_ETREE"
+ done
+
+ # Directories
+ # - INLINE
+ echo "+ inline dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_INLINE" 1
+
+ # - BLOCK
+ echo "+ block dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_BLOCK" "$((dblksz / 24))"
+
+ # - HTREE
+ echo "+ htree dir"
+ __populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_HTREE" "$((4 * dblksz / 24))"
+
+ # Symlinks
+ # - FMT_LOCAL
+ echo "+ inline symlink"
+ ln -s target "${SCRATCH_MNT}/S_IFLNK.FMT_LOCAL"
+
+ # - FMT_EXTENTS
+ echo "+ extents symlink"
+ ln -s "$(perl -e 'print "x" x 1023;')" "${SCRATCH_MNT}/S_IFLNK.FMT_EXTENTS"
+
+ # Char & block
+ echo "+ special"
+ mkdir devices
+ mknod "${SCRATCH_MNT}/S_IFCHR" c 1 1
+ mknod "${SCRATCH_MNT}/S_IFBLK" c 1 1
+
+ # Attribute formats
+ # LOCAL
+ echo "+ local attr"
+ __populate_create_attr "${SCRATCH_MNT}/ATTR.FMT_LOCAL" 1
+
+ # BLOCK
+ echo "+ block attr"
+ __populate_create_attr "${SCRATCH_MNT}/ATTR.FMT_BLOCK" "$((blksz / 40))"
+
+ # Make an unused inode
+ echo "+ empty file"
+ touch "${SCRATCH_MNT}/unused"
+ $XFS_IO_PROG -f -c 'fsync' "${SCRATCH_MNT}/unused"
+ rm -rf "${SCRATCH_MNT}/unused"
+
+ # Copy some real files (xfs tests, I guess...)
+ echo "+ real files"
+ __populate_fill_fs "${SCRATCH_MNT}"
+ cp -pRdu --reflink=always "${SCRATCH_MNT}/S_IFREG.FMT_ETREE" "${SCRATCH_MNT}/S_IREG.FMT_ETREE.REFLINK" 2> /dev/null
+
+ umount "${SCRATCH_MNT}"
+}
+
+# Find the inode number of a file
+__populate_find_inode() {
+ name="$1"
+ inode="$(stat -c '%i' "${name}")"
+ echo "${inode}"
+}
+
+# Check data fork format of XFS file
+__populate_check_xfs_dformat() {
+ dev="$1"
+ inode="$2"
+ format="$3"
+
+ fmt="$($XFS_DB_PROG -c "inode ${inode}" -c 'p core.format' "${dev}" | sed -e 's/^.*(\([a-z]*\)).*$/\1/g')"
+ test "${format}" = "${fmt}" || _fail "failed to create ino ${inode} dformat expected ${format} saw ${fmt}"
+}
+
+# Check attr fork format of XFS file
+__populate_check_xfs_aformat() {
+ dev="$1"
+ inode="$2"
+ format="$3"
+
+ fmt="$($XFS_DB_PROG -c "inode ${inode}" -c 'p core.aformat' "${dev}" | sed -e 's/^.*(\([a-z]*\)).*$/\1/g')"
+ test "${format}" = "${fmt}" || _fail "failed to create ino ${inode} aformat expected ${format} saw ${fmt}"
+}
+
+# Check structure of XFS directory
+__populate_check_xfs_dir() {
+ dev="$1"
+ inode="$2"
+ dtype="$3"
+
+ (test -n "${leaf_lblk}" && test -n "${node_lblk}") || _fail "must define leaf_lblk and node_lblk before calling __populate_check_xfs_dir"
+ datab=0
+ leafb=0
+ freeb=0
+ #echo "== check dir ${inode} type ${dtype}" ; $XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}"
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "dblock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' || datab=1
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' || leafb=1
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${node_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' || freeb=1
+
+ case "${dtype}" in
+ "shortform"|"inline"|"local")
+ (test "${datab}" -eq 0 && test "${leafb}" -eq 0 && test "${freeb}" -eq 0) || _fail "failed to create ${dtype} dir ino ${inode} datab ${datab} leafb ${leafb} freeb ${freeb}"
+ ;;
+ "block")
+ (test "${datab}" -eq 1 && test "${leafb}" -eq 0 && test "${freeb}" -eq 0) || _fail "failed to create ${dtype} dir ino ${inode} datab ${datab} leafb ${leafb} freeb ${freeb}"
+ ;;
+ "leaf")
+ (test "${datab}" -eq 1 && test "${leafb}" -eq 1 && test "${freeb}" -eq 0) || _fail "failed to create ${dtype} dir ino ${inode} datab ${datab} leafb ${leafb} freeb ${freeb}"
+ ;;
+ "node"|"btree")
+ (test "${datab}" -eq 1 && test "${leafb}" -eq 1 && test "${freeb}" -eq 1) || _fail "failed to create ${dtype} dir ino ${inode} datab ${datab} leafb ${leafb} freeb ${freeb}"
+ ;;
+ *)
+ _fail "Unknown directory type ${dtype}"
+ esac
+}
+
+# Check structure of XFS attr
+__populate_check_xfs_attr() {
+ dev="$1"
+ inode="$2"
+ atype="$3"
+
+ datab=0
+ leafb=0
+ #echo "== check attr ${inode} type ${dtype}" ; $XFS_DB_PROG -x -c "inode ${inode}" -c "bmap -a" "${SCRATCH_DEV}"
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || datab=1
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 1" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || leafb=1
+
+ case "${atype}" in
+ "shortform"|"inline"|"local")
+ (test "${datab}" -eq 0 && test "${leafb}" -eq 0) || _fail "failed to create ${atype} attr ino ${inode} datab ${datab} leafb ${leafb}"
+ ;;
+ "leaf")
+ (test "${datab}" -eq 1 && test "${leafb}" -eq 0) || _fail "failed to create ${atype} attr ino ${inode} datab ${datab} leafb ${leafb}"
+ ;;
+ "node"|"btree")
+ (test "${datab}" -eq 1 && test "${leafb}" -eq 1) || _fail "failed to create ${atype} attr ino ${inode} datab ${datab} leafb ${leafb}"
+ ;;
+ *)
+ _fail "Unknown attribute type ${atype}"
+ esac
+}
+
+# Check that populate created all the types of files we wanted
+_scratch_xfs_populate_check() {
+ _scratch_mount
+ extents_file="$(__populate_find_inode "${SCRATCH_MNT}/S_IFREG.FMT_EXTENTS")"
+ btree_file="$(__populate_find_inode "${SCRATCH_MNT}/S_IFREG.FMT_BTREE")"
+ inline_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_INLINE")"
+ block_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_BLOCK")"
+ leaf_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_LEAF")"
+ node_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_NODE")"
+ btree_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_BTREE")"
+ local_slink="$(__populate_find_inode "${SCRATCH_MNT}/S_IFLNK.FMT_LOCAL")"
+ extents_slink="$(__populate_find_inode "${SCRATCH_MNT}/S_IFLNK.FMT_EXTENTS")"
+ bdev="$(__populate_find_inode "${SCRATCH_MNT}/S_IFBLK")"
+ cdev="$(__populate_find_inode "${SCRATCH_MNT}/S_IFCHR")"
+ local_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_LOCAL")"
+ leaf_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_LEAF")"
+ node_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_NODE")"
+ btree_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_BTREE")"
+
+ blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+ dblksz="$(xfs_info "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')"
+ leaf_lblk="$((32 * 1073741824 / blksz))"
+ node_lblk="$((64 * 1073741824 / blksz))"
+ umount "${SCRATCH_MNT}"
+
+ __populate_check_xfs_dformat "${SCRATCH_DEV}" "${extents_file}" "extents"
+ __populate_check_xfs_dformat "${SCRATCH_DEV}" "${btree_file}" "btree"
+ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inline_dir}" "inline"
+ __populate_check_xfs_dir "${SCRATCH_DEV}" "${block_dir}" "block"
+ __populate_check_xfs_dir "${SCRATCH_DEV}" "${leaf_dir}" "leaf"
+ __populate_check_xfs_dir "${SCRATCH_DEV}" "${node_dir}" "node"
+ __populate_check_xfs_dir "${SCRATCH_DEV}" "${btree_dir}" "btree"
+ __populate_check_xfs_dformat "${SCRATCH_DEV}" "${btree_dir}" "btree"
+ __populate_check_xfs_dformat "${SCRATCH_DEV}" "${bdev}" "dev"
+ __populate_check_xfs_dformat "${SCRATCH_DEV}" "${cdev}" "dev"
+ __populate_check_xfs_attr "${SCRATCH_DEV}" "${local_attr}" "local"
+ __populate_check_xfs_attr "${SCRATCH_DEV}" "${leaf_attr}" "leaf"
+ __populate_check_xfs_attr "${SCRATCH_DEV}" "${node_attr}" "node"
+ __populate_check_xfs_attr "${SCRATCH_DEV}" "${btree_attr}" "btree"
+ __populate_check_xfs_aformat "${SCRATCH_DEV}" "${btree_attr}" "btree"
+}
+
+# Check data fork format of ext4 file
+__populate_check_ext4_dformat() {
+ dev="$1"
+ inode="$2"
+ format="$3"
+
+ extents=0
+ etree=0
+ debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'ETB[0-9]' -q && etree=1
+ iflags="$(debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'Flags:' | sed -e 's/^.*Flags: \([0-9a-fx]*\).*$/\1/g')"
+ test "$(echo "${iflags}" | awk '{print and(strtonum($1), 0x80000);}')" -gt 0 && extents=1
+
+ case "${format}" in
+ "blockmap")
+ test "${extents}" -eq 0 || _fail "failed to create ino ${inode} with blockmap"
+ ;;
+ "extent"|"extents")
+ test "${extents}" -eq 1 || _fail "failed to create ino ${inode} with extents"
+ ;;
+ "etree")
+ (test "${extents}" -eq 1 && test "${etree}" -eq 1) || _fail "failed to create ino ${inode} with extent tree"
+ ;;
+ *)
+ _fail "Unknown dformat ${format}"
+ esac
+}
+
+# Check attr fork format of ext4 file
+__populate_check_ext4_aformat() {
+ dev="$1"
+ inode="$2"
+ format="$3"
+
+ ablock=1
+ debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'File ACL: 0' -q && ablock=0
+
+ case "${format}" in
+ "local"|"inline")
+ test "${ablock}" -eq 0 || _fail "failed to create inode ${inode} with ${format} xattr"
+ ;;
+ "block")
+ test "${extents}" -eq 1 || _fail "failed to create inode ${inode} with ${format} xattr"
+ ;;
+ *)
+ _fail "Unknown aformat ${format}"
+ esac
+}
+
+# Check structure of ext4 dir
+__populate_check_ext4_dir() {
+ dev="$1"
+ inode="$2"
+ dtype="$3"
+
+ htree=0
+ inline=0
+ iflags="$(debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'Flags:' | sed -e 's/^.*Flags: \([0-9a-fx]*\).*$/\1/g')"
+ test "$(echo "${iflags}" | awk '{print and(strtonum($1), 0x1000);}')" -gt 0 && htree=1
+ test "$(echo "${iflags}" | awk '{print and(strtonum($1), 0x10000000);}')" -gt 0 && inline=1
+
+ case "${dtype}" in
+ "inline")
+ (test "${inline}" -eq 1 && test "${htree}" -eq 0) || _fail "failed to create ${dtype} dir ino ${inode} htree ${htree} inline ${inline}"
+ ;;
+ "block")
+ (test "${inline}" -eq 0 && test "${htree}" -eq 0) || _fail "failed to create ${dtype} dir ino ${inode} htree ${htree} inline ${inline}"
+ ;;
+ "htree")
+ (test "${inline}" -eq 0 && test "${htree}" -eq 1) || _fail "failed to create ${dtype} dir ino ${inode} htree ${htree} inline ${inline}"
+ ;;
+ *)
+ _fail "Unknown directory type ${dtype}"
+ ;;
+ esac
+}
+
+# Check that populate created all the types of files we wanted
+_scratch_ext4_populate_check() {
+ _scratch_mount
+ extents_file="$(__populate_find_inode "${SCRATCH_MNT}/S_IFREG.FMT_EXTENTS")"
+ etree_file="$(__populate_find_inode "${SCRATCH_MNT}/S_IFREG.FMT_ETREE")"
+ block_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_BLOCK")"
+ htree_dir="$(__populate_find_inode "${SCRATCH_MNT}/S_IFDIR.FMT_HTREE")"
+ extents_slink="$(__populate_find_inode "${SCRATCH_MNT}/S_IFLNK.FMT_EXTENTS")"
+ local_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_LOCAL")"
+ block_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_BLOCK")"
+ umount "${SCRATCH_MNT}"
+
+ __populate_check_ext4_dformat "${SCRATCH_DEV}" "${extents_file}" "extents"
+ __populate_check_ext4_dformat "${SCRATCH_DEV}" "${etree_file}" "etree"
+ __populate_check_ext4_dir "${SCRATCH_DEV}" "${block_dir}" "block"
+ __populate_check_ext4_dir "${SCRATCH_DEV}" "${htree_dir}" "htree"
+ __populate_check_ext4_dformat "${SCRATCH_DEV}" "${extents_slink}" "extents"
+ __populate_check_ext4_aformat "${SCRATCH_DEV}" "${local_attr}" "local"
+ __populate_check_ext4_aformat "${SCRATCH_DEV}" "${block_attr}" "block"
+}
+
+# Populate a scratch FS and check the contents to make sure we got that
+_scratch_populate() {
+ case "${FSTYP}" in
+ "xfs")
+ _scratch_xfs_populate
+ _scratch_xfs_populate_check
+ ;;
+ "ext4")
+ _scratch_ext4_populate
+ _scratch_ext4_populate_check
+ ;;
+ *)
+ _fail "Don't know how to populate a ${FSTYP} filesystem."
+ ;;
+ esac
+}
+
+# Modify various files after a fuzzing operation
+_scratch_fuzz_modify() {
+ nr="$1"
+
+ test -z "${nr}" && nr=50000
+ echo "+++ touch ${nr} files"
+ $XFS_IO_PROG -f -c "pwrite -S 0x63 0 ${BLK_SZ}" "/tmp/afile" > /dev/null
+ date="$(date)"
+ find "${SCRATCH_MNT}/" -type f 2> /dev/null | head -n "${nr}" | while read f; do
+ setfattr -n "user.date" -v "${date}" "$f"
+ cat "/tmp/afile" >> "$f"
+ mv "$f" "$f.longer"
+ done
+ rm -rf "/tmp/afile"
+
+ echo "+++ create files"
+ cp -pRdu "${SRCDIR}" "${SCRATCH_MNT}/test.moo"
+ sync
+
+ echo "+++ remove files"
+ rm -rf "${SCRATCH_MNT}/test.moo"
+ rm -rf "${SCRATCH_MNT}/test.1"
+}
+
+# Try to access files after fuzzing
+_scratch_fuzz_test() {
+ echo "+++ ls -laR" >> $seqres.full
+ ls -laR "${SCRATCH_MNT}/test.1/" >/dev/null 2>&1
+
+ echo "+++ cat files" >> $seqres.full
+ (find "${SCRATCH_MNT}/test.1/" -type f -size -1048576k -print0 | xargs -0 cat) >/dev/null 2>&1
+}
+
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] randomly fuzz XFS and ext4 filesystems
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
2015-08-15 1:52 ` [PATCH 1/7] common: add routines to fuzz filesystems Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
2015-08-15 1:52 ` [PATCH 3/7] ext4: test block group metadata corruption checking and repair Darrick J. Wong
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
Introduce tests for XFS and ext4 which format a filesystem, populate
it, then uses blocktrash and e2fuzz to corrupt the metadata. The FS
is remounted, modified, and unmounted. Following that, xfs_repair or
e2fsck are run until it no longer finds errors to correct, after which
the FS is mounted yet again and exercised to see if there are any
errors remaining.
The XFS test requires an xfs_db that can handle blocktrash and v5
filesystems.
The ext4 test requires metadata_csum support in e2fsprogs.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
tests/ext4/700 | 161 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/ext4/700.out | 3 +
tests/ext4/group | 1
tests/xfs/700 | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/700.out | 3 +
tests/xfs/group | 1
6 files changed, 343 insertions(+)
create mode 100755 tests/ext4/700
create mode 100644 tests/ext4/700.out
create mode 100755 tests/xfs/700
create mode 100644 tests/xfs/700.out
diff --git a/tests/ext4/700 b/tests/ext4/700
new file mode 100755
index 0000000..ef68d75
--- /dev/null
+++ b/tests/ext4/700
@@ -0,0 +1,161 @@
+#! /bin/bash
+# FS QA Test No. 700
+#
+# Create and populate an ext4 filesystem, fuzz the metadata, then see how
+# the kernel reacts, how e2fsck fares in fixing the mess, and then
+# try more kernel accesses to see if it really fixed things.
+#
+#-----------------------------------------------------------------------
+# 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
+
+if [ ! -x "$(which e2fuzz)" ]; then
+ _notrun "Couldn't find e2fuzz"
+fi
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+_require_attrs
+
+repair_scratch() {
+ fsck_pass="$1"
+
+ FSCK_LOG="${tmp}-fuzz-${fsck_pass}.log"
+ echo "++ fsck pass ${fsck_pass}" > "${FSCK_LOG}"
+ e2fsck -f -y "${SCRATCH_DEV}"
+ res=$?
+ if [ "${res}" -eq 0 ]; then
+ echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
+ _check_scratch_fs -n >> "${FSCK_LOG}" 2>&1
+ res=$?
+ fi
+ echo "++ fsck returns ${res}" >> "${FSCK_LOG}"
+ if [ "${res}" -eq 0 ]; then
+ echo "++ fsck thinks we are done" >> "${FSCK_LOG}"
+ cat "${FSCK_LOG}"
+ return 0
+ elif [ "${fsck_pass}" -eq "${FSCK_PASSES}" ]; then
+ echo "++ fsck did not fix in ${FSCK_PASSES} passes." >> "${FSCK_LOG}"
+ cat "${FSCK_LOG}"
+ return 0
+ fi
+ cat "${FSCK_LOG}"
+ if [ "${fsck_pass}" -gt 1 ]; then
+ cmp -s "${tmp}-fuzz-$((fsck_pass - 1)).log" "${FSCK_LOG}"
+ if [ $? -eq 0 ]; then
+ echo "++ fsck makes no progress"
+ return 2
+ fi
+ fi
+ return 1
+}
+
+rm -f $seqres.full
+echo "See interesting results in $seqres.full" | sed -e "s,$RESULT_DIR,RESULT_DIR,g"
+SRCDIR=`pwd`
+test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-b 32 -v"
+test -z "${FSCK_PASSES}" && FSCK_PASSES=10
+BLK_SZ=4096
+
+echo "fuzzing ext4 with FUZZ_ARGS=$FUZZ_ARGS and FSCK_PASSES=$FSCK_PASSES" > $seqres.full
+
+echo "+ create scratch fs" >> $seqres.full
+_scratch_mkfs_ext4 >> $seqres.full 2>&1
+
+echo "+ populate fs image" >> $seqres.full
+_scratch_populate >> $seqres.full
+
+echo "+ check fs" >> $seqres.full
+_check_scratch_fs >> $seqres.full 2>&1 || _fail "should pass initial fsck"
+
+echo "++ corrupt image" >> $seqres.full
+e2fuzz ${FUZZ_ARGS} ${SCRATCH_DEV} >> $seqres.full 2>&1
+
+echo "++ mount image" >> $seqres.full
+_scratch_mount >> $seqres.full 2>&1
+
+echo "++ test scratch" >> $seqres.full
+_scratch_fuzz_test >> $seqres.full 2>&1
+
+echo "++ modify scratch" >> $seqres.full
+_scratch_fuzz_modify >> $seqres.full 2>&1
+
+echo "++ unmount" >> $seqres.full
+umount "${SCRATCH_MNT}"
+
+# repair in a loop...
+for p in $(seq 1 "${FSCK_PASSES}"); do
+ repair_scratch "$p" >> $seqres.full 2>&1 && break
+done
+echo "+ fsck loop returns ${fsck_loop_ret}" >> $seqres.full
+
+echo "++ check fs for round 2" >> $seqres.full
+_check_scratch_fs >> $seqres.full 2>&1
+
+ROUND2_LOG="${tmp}-round2-${fsck_pass}.log"
+echo "++ mount image (2)" >> $ROUND2_LOG
+_scratch_mount >> $ROUND2_LOG 2>&1
+
+echo "++ chattr -R -i" >> $ROUND2_LOG
+chattr -R -f -i "${SCRATCH_MNT}/" > /dev/null 2>> $ROUND2_LOG
+
+echo "++ test scratch" >> $ROUND2_LOG
+_scratch_fuzz_test >> $ROUND2_LOG 2>&1
+
+echo "++ modify scratch" >> $ROUND2_LOG
+_scratch_fuzz_modify >> $ROUND2_LOG 2>&1
+
+echo "++ unmount" >> $ROUND2_LOG
+umount "${SCRATCH_MNT}" >> $ROUND2_LOG 2>&1
+
+cat "$ROUND2_LOG" >> $seqres.full
+
+echo "++ check fs (2)" >> $seqres.full
+_check_scratch_fs >> $seqres.full 2>&1
+
+egrep -q '(did not fix|makes no progress)' $seqres.full && echo "e2fsck failed" | tee -a $seqres.full
+if [ "$(wc -l < "$ROUND2_LOG")" -ne 8 ]; then
+ echo "e2fsck did not fix everything" | tee -a $seqres.full
+fi
+echo "finished fuzzing" | tee -a "$seqres.full"
+
+status=0
+exit
diff --git a/tests/ext4/700.out b/tests/ext4/700.out
new file mode 100644
index 0000000..c0a16f6
--- /dev/null
+++ b/tests/ext4/700.out
@@ -0,0 +1,3 @@
+QA output created by 700
+See interesting results in RESULT_DIR/700.full
+finished fuzzing
diff --git a/tests/ext4/group b/tests/ext4/group
index 96218b7..dfadd91 100644
--- a/tests/ext4/group
+++ b/tests/ext4/group
@@ -17,3 +17,4 @@
306 auto rw resize quick
307 auto ioctl rw
308 auto ioctl rw prealloc quick
+700 dangerous_fuzzers
diff --git a/tests/xfs/700 b/tests/xfs/700
new file mode 100755
index 0000000..bc3f176
--- /dev/null
+++ b/tests/xfs/700
@@ -0,0 +1,174 @@
+#! /bin/bash
+# FS QA Test No. 700
+#
+# Create and populate an XFS filesystem, fuzz the metadata, then see how
+# the kernel reacts, how xfs_repair fares in fixing the mess, and then
+# try more kernel accesses to see if it really fixed things.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_require_scratch
+#_require_xfs_crc # checksum not required, but you probably want it anyway...
+#_require_xfs_mkfs_crc
+_require_attrs
+
+scratch_repair() {
+ fsck_pass="$1"
+
+ FSCK_LOG="${tmp}-fuzz-${fsck_pass}.log"
+ echo "++ fsck pass ${fsck_pass}" > "${FSCK_LOG}"
+ _scratch_xfs_repair >> "${FSCK_LOG}" 2>&1
+ res=$?
+ if [ "${res}" -eq 0 ]; then
+ echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
+ _scratch_xfs_repair -n >> "${FSCK_LOG}" 2>&1
+ res=$?
+ fi
+ echo "++ fsck returns ${res}" >> "${FSCK_LOG}"
+ if [ "${res}" -eq 0 ]; then
+ echo "++ fsck thinks we are done" >> "${FSCK_LOG}"
+ cat "${FSCK_LOG}"
+ return 0
+ elif [ "${res}" -eq 2 ]; then
+ # replay log?
+ echo "+++ replaying log" >> "${FSCK_LOG}"
+ _scratch_mount >> "${FSCK_LOG}" 2>&1
+ res=$?
+ echo "+++ mount returns ${res}" >> "${FSCK_LOG}"
+ if [ "${res}" -gt 0 ]; then
+ echo "+++ zeroing log" >> "${FSCK_LOG}"
+ _scratch_xfs_repair -L >> "${FSCK_LOG}" 2>&1
+ echo "+++ returns $?" >> "${FSCK_LOG}"
+ else
+ umount "${SCRATCH_MNT}" >> "${FSCK_LOG}" 2>&1
+ fi
+ elif [ "${fsck_pass}" -eq "${FSCK_PASSES}" ]; then
+ echo "++ fsck did not fix in ${FSCK_PASSES} passes." >> "${FSCK_LOG}"
+ cat "${FSCK_LOG}"
+ return 0
+ fi
+ cat "${FSCK_LOG}"
+ if [ "${fsck_pass}" -gt 1 ]; then
+ cmp -s "${tmp}-fuzz-$((fsck_pass - 1)).log" "${FSCK_LOG}"
+ if [ $? -eq 0 ]; then
+ echo "++ fsck makes no progress"
+ return 2
+ fi
+ fi
+ return 1
+}
+
+rm -f $seqres.full
+echo "See interesting results in $seqres.full" | sed -e "s,$RESULT_DIR,RESULT_DIR,g"
+SRCDIR=`pwd`
+test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-3 -n 32"
+test -z "${FSCK_PASSES}" && FSCK_PASSES=10
+BLK_SZ=4096
+
+echo "fuzzing xfs with FUZZ_ARGS=$FUZZ_ARGS and FSCK_PASSES=$FSCK_PASSES" > $seqres.full
+
+echo "+ create scratch fs" >> $seqres.full
+_scratch_mkfs_xfs >> $seqres.full 2>&1
+
+echo "+ populate fs image" >> $seqres.full
+_scratch_populate >> $seqres.full
+
+echo "+ check fs" >> $seqres.full
+_scratch_xfs_repair >> $seqres.full 2>&1 || _fail "should pass initial fsck"
+
+echo "++ corrupt image" >> $seqres.full
+xfs_db -x -c blockget -c "blocktrash ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "++ mount image" >> $seqres.full
+_scratch_mount >> $seqres.full 2>&1
+
+echo "+++ test scratch" >> $seqres.full
+_scratch_fuzz_test >> $seqres.full 2>&1
+
+echo "+++ modify scratch" >> $seqres.full
+_scratch_fuzz_modify >> $seqres.full 2>&1
+
+echo "++ umount" >> $seqres.full
+umount "${SCRATCH_MNT}"
+
+# repair in a loop...
+for p in $(seq 1 "${FSCK_PASSES}"); do
+ scratch_repair "$p" >> $seqres.full 2>&1 && break
+done
+echo "+ fsck loop returns ${fsck_loop_ret}" >> $seqres.full
+
+echo "++ check fs for round 2" >> $seqres.full
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+ROUND2_LOG="${tmp}-round2-${fsck_pass}.log"
+echo "++ mount image (2)" >> $ROUND2_LOG
+_scratch_mount >> $ROUND2_LOG 2>&1
+
+echo "++ chattr -R -i" >> $ROUND2_LOG
+chattr -R -f -i "${SCRATCH_MNT}/" > /dev/null 2>> $ROUND2_LOG
+
+echo "+++ test scratch" >> $ROUND2_LOG
+_scratch_fuzz_test >> $ROUND2_LOG 2>&1
+
+echo "+++ modify scratch" >> $ROUND2_LOG
+_scratch_fuzz_modify >> $ROUND2_LOG 2>&1
+
+echo "++ umount" >> $ROUND2_LOG
+umount "${SCRATCH_MNT}" >> $ROUND2_LOG 2>&1
+
+cat "$ROUND2_LOG" >> $seqres.full
+
+echo "++ check fs (2)" >> $seqres.full
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+egrep -q '(did not fix|makes no progress)' $seqres.full && echo "xfs_repair failed" | tee -a $seqres.full
+if [ "$(wc -l < "$ROUND2_LOG")" -ne 8 ]; then
+ echo "xfs_repair did not fix everything" | tee -a $seqres.full
+fi
+echo "finished fuzzing" | tee -a "$seqres.full"
+
+status=0
+exit
diff --git a/tests/xfs/700.out b/tests/xfs/700.out
new file mode 100644
index 0000000..c0a16f6
--- /dev/null
+++ b/tests/xfs/700.out
@@ -0,0 +1,3 @@
+QA output created by 700
+See interesting results in RESULT_DIR/700.full
+finished fuzzing
diff --git a/tests/xfs/group b/tests/xfs/group
index ebe8e7e..140df27 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -197,3 +197,4 @@
303 auto quick quota
304 auto quick quota
305 auto quota
+700 dangerous_fuzzers
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] ext4: test block group metadata corruption checking and repair
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
2015-08-15 1:52 ` [PATCH 1/7] common: add routines to fuzz filesystems Darrick J. Wong
2015-08-15 1:52 ` [PATCH 2/7] randomly fuzz XFS and ext4 filesystems Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
2015-08-15 1:52 ` [PATCH 4/7] ext4: test file/dir/symlink " Darrick J. Wong
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
Targeted fuzzing tests which destroy various pieces of filesystem or
block group metadata; the tests look for (a) kernel detection of
corruption, (b) e2fsck repair of said corruption, and (c) post-repair
fs usability.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
common/rc | 11 +++++
tests/ext4/701 | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/ext4/701.out | 13 ++++++
tests/ext4/702 | 103 ++++++++++++++++++++++++++++++++++++++++++++
tests/ext4/702.out | 10 ++++
tests/ext4/703 | 113 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/ext4/703.out | 12 +++++
tests/ext4/704 | 102 +++++++++++++++++++++++++++++++++++++++++++
tests/ext4/704.out | 12 +++++
tests/ext4/705 | 88 ++++++++++++++++++++++++++++++++++++++
tests/ext4/705.out | 10 ++++
tests/ext4/706 | 87 +++++++++++++++++++++++++++++++++++++
tests/ext4/706.out | 10 ++++
tests/ext4/group | 6 +++
14 files changed, 699 insertions(+)
create mode 100755 tests/ext4/701
create mode 100644 tests/ext4/701.out
create mode 100755 tests/ext4/702
create mode 100644 tests/ext4/702.out
create mode 100755 tests/ext4/703
create mode 100644 tests/ext4/703.out
create mode 100755 tests/ext4/704
create mode 100644 tests/ext4/704.out
create mode 100755 tests/ext4/705
create mode 100644 tests/ext4/705.out
create mode 100755 tests/ext4/706
create mode 100644 tests/ext4/706.out
diff --git a/common/rc b/common/rc
index 70d2fa8..f889103 100644
--- a/common/rc
+++ b/common/rc
@@ -1398,6 +1398,17 @@ _require_xfs_crc()
umount $SCRATCH_MNT
}
+# this test requires the ext4 kernel support crc feature on scratch device
+#
+_require_scratch_ext4_crc()
+{
+ _scratch_mkfs_ext4 >/dev/null 2>&1
+ dumpe2fs -h $SCRATCH_DEV 2> /dev/null | grep -q metadata_csum || _notrun "metadata_csum not supported by this filesystem"
+ _scratch_mount >/dev/null 2>&1 \
+ || _notrun "Kernel doesn't support metadata_csum feature"
+ umount $SCRATCH_MNT
+}
+
# this test requires the bigalloc feature to be available in mkfs.ext4
#
_require_ext4_mkfs_bigalloc()
diff --git a/tests/ext4/701 b/tests/ext4/701
new file mode 100755
index 0000000..6833954
--- /dev/null
+++ b/tests/ext4/701
@@ -0,0 +1,122 @@
+#! /bin/bash
+# FS QA Test No. 701
+#
+# Create and populate an ext4 filesystem, corrupt the primary superblock, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+dumpe2fs -g "${SCRATCH_DEV}" > /dev/null 2>&1 || _notrun "dumpe2fs -g not supported"
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+nr_groups="$(dumpe2fs -g "${SCRATCH_DEV}" 2> /dev/null | tail -n 1 | cut -d : -f 1)"
+test "${nr_groups}" -gt 0 || _notrun "scratch device not big enough for backup superblocks"
+backup_sb="$(dumpe2fs -g "${SCRATCH_DEV}" 2> /dev/null | awk -F ':' 'BEGIN {x = 0;} {if (x == 0 && int($3) > 1) {print $3; x++;}}')"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 128`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 64 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if ($1 == 0) {print $3}}' | while read blk; do
+ debugfs -w -R "zap_block ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "primary sb fuzz failed"
+done
+
+echo "+ mount image"
+_scratch_mount 2> /dev/null && _fail "mount should not succeed"
+
+echo "+ repair fs"
+# Have to specify backup sb and blocksize here so we don't pick up superblocks
+# scattered elsewhere on the scratch device.
+echo e2fsck -f -y -B "${blksz}" -b "${backup_sb}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+e2fsck -f -y -B "${blksz}" -b "${backup_sb}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ modify files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -e "${TESTFILE}.${x}" || continue
+ stat "${TESTFILE}.${x}" >> /dev/null 2>&1
+ test $? -ne 0 && broken=1
+ echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/701.out b/tests/ext4/701.out
new file mode 100644
index 0000000..a44edb2
--- /dev/null
+++ b/tests/ext4/701.out
@@ -0,0 +1,13 @@
+QA output created by 701
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/ext4/702 b/tests/ext4/702
new file mode 100755
index 0000000..60c52f6
--- /dev/null
+++ b/tests/ext4/702
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 702
+#
+# Create and populate an ext4 filesystem, corrupt a group descriptor, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+dumpe2fs -g "${SCRATCH_DEV}" > /dev/null 2>&1 || _notrun "dumpe2fs -g not supported"
+
+echo "+ mount fs image"
+_scratch_mount
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 128`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 64 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ echo moo >> "${TESTFILE}.${x}"
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if (int($4) != -1) {print $4}}' | sed -e 's/-.*$//g' | awk '{if (int($1) > 0) {print $1}}' | while read blk; do
+ debugfs -w -R "zap_block ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "group descriptor fuzz failed"
+done
+
+echo "+ mount image"
+_scratch_mount 2> /dev/null && _fail "mount should not succeed"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/702.out b/tests/ext4/702.out
new file mode 100644
index 0000000..66f3b3b
--- /dev/null
+++ b/tests/ext4/702.out
@@ -0,0 +1,10 @@
+QA output created by 702
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ check fs (2)
diff --git a/tests/ext4/703 b/tests/ext4/703
new file mode 100755
index 0000000..61fb55b
--- /dev/null
+++ b/tests/ext4/703
@@ -0,0 +1,113 @@
+#! /bin/bash
+# FS QA Test No. 703
+#
+# Create and populate an ext4 filesystem, corrupt a block bitmap, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_xfs_io_command "falloc"
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+dumpe2fs -g "${SCRATCH_DEV}" > /dev/null 2>&1 || _notrun "dumpe2fs -g not supported"
+nr_groups="$(dumpe2fs -g "${SCRATCH_DEV}" 2> /dev/null | tail -n 1 | cut -d : -f 1)"
+
+echo "+ mount fs image"
+_scratch_mount
+# abuse orlov allocator in the hopes that each bg ends up with some inodes
+for i in `seq 1 $((nr_groups * 8))`; do
+ mkdir -p "${SCRATCH_MNT}/d_${i}"
+done
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+freeblks="$(stat -f -c '%a' "${SCRATCH_MNT}")"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * freeblks))" "${SCRATCH_MNT}/bigfile2" >> $seqres.full
+umount "${SCRATCH_MNT}"
+
+echo "+ make some files"
+_scratch_mount
+rm -rf "${SCRATCH_MNT}/bigfile2"
+touch "${SCRATCH_MNT}/bigfile"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if (int($5) > 0) {print $5}}' | while read blk; do
+ debugfs -w -n -R "zap_block -p 0xff ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "block bitmap fuzz failed"
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+b_bytes="$(stat -c '%B' "${SCRATCH_MNT}/bigfile")"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * freeblks))" "${SCRATCH_MNT}/bigfile" >> $seqres.full 2> /dev/null
+after="$(stat -c '%b' "${SCRATCH_MNT}/bigfile")"
+echo "$((after * b_bytes))" lt "$((blksz * freeblks / 4))" >> $seqres.full
+test "$((after * b_bytes))" -lt "$((blksz * freeblks / 4))" || _fail "falloc should fail"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ modify files (2)"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * freeblks))" "${SCRATCH_MNT}/bigfile" >> $seqres.full
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/703.out b/tests/ext4/703.out
new file mode 100644
index 0000000..42ecc84
--- /dev/null
+++ b/tests/ext4/703.out
@@ -0,0 +1,12 @@
+QA output created by 703
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image (2)
++ modify files (2)
++ check fs (2)
diff --git a/tests/ext4/704 b/tests/ext4/704
new file mode 100755
index 0000000..da94317
--- /dev/null
+++ b/tests/ext4/704
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 704
+#
+# Create and populate an ext4 filesystem, corrupt an inode bitmap, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+dumpe2fs -g "${SCRATCH_DEV}" > /dev/null 2>&1 || _notrun "dumpe2fs -g not supported"
+resize2fs -M "${SCRATCH_DEV}" >> $seqres.full 2>&1
+nr_groups="$(dumpe2fs -g "${SCRATCH_DEV}" 2> /dev/null | tail -n 1 | cut -d : -f 1)"
+
+echo "+ mount fs image"
+_scratch_mount
+
+echo "+ make some files"
+# abuse orlov allocator in the hopes that each bg ends up with some inodes
+for i in `seq 1 $((nr_groups * 8))`; do
+ mkdir -p "${SCRATCH_MNT}/d_${i}"
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if (int($6) > 0) {print $6}}' | while read blk; do
+ debugfs -w -n -R "zap_block ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "inode bitmap fuzz failed"
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+touch "${SCRATCH_MNT}/file0" > /dev/null 2>&1 && _fail "touch should fail"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ modify files (2)"
+touch "${SCRATCH_MNT}/file1"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/704.out b/tests/ext4/704.out
new file mode 100644
index 0000000..e1b0dbd
--- /dev/null
+++ b/tests/ext4/704.out
@@ -0,0 +1,12 @@
+QA output created by 704
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image (2)
++ modify files (2)
++ check fs (2)
diff --git a/tests/ext4/705 b/tests/ext4/705
new file mode 100755
index 0000000..11ff98f
--- /dev/null
+++ b/tests/ext4/705
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test No. 705
+#
+# Create and populate an ext4 filesystem, corrupt the MMP block, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 -O mmp -E mmp_update_interval=2 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+echo moo > "${SCRATCH_MNT}/file0"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+blk="$(dumpe2fs "${SCRATCH_DEV}" 2> /dev/null | grep 'MMP block number' | sed -e 's/^MMP block number: *\([0-9]*\)$/\1/g')"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $((blk * blksz + 16)) 8" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount 2> /dev/null && _fail "mount should fail due to bad MMP"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount || _fail "mount should not fail; MMP has been fixed"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/705.out b/tests/ext4/705.out
new file mode 100644
index 0000000..60c43ef
--- /dev/null
+++ b/tests/ext4/705.out
@@ -0,0 +1,10 @@
+QA output created by 705
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ check fs (2)
diff --git a/tests/ext4/706 b/tests/ext4/706
new file mode 100755
index 0000000..505be41
--- /dev/null
+++ b/tests/ext4/706
@@ -0,0 +1,87 @@
+#! /bin/bash
+# FS QA Test No. 706
+#
+# Create and populate an ext4 filesystem, corrupt the journal, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 -O journal > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+echo moo > "${SCRATCH_MNT}/file0"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+debugfs -w -R 'zap -f <8> 0' "${SCRATCH_DEV}" 2> /dev/null
+
+echo "+ mount image"
+_scratch_mount 2> /dev/null && _fail "mount should fail due to bad journal"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount || _fail "mount should not fail; journal has been fixed"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/706.out b/tests/ext4/706.out
new file mode 100644
index 0000000..f919d45
--- /dev/null
+++ b/tests/ext4/706.out
@@ -0,0 +1,10 @@
+QA output created by 706
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ check fs (2)
diff --git a/tests/ext4/group b/tests/ext4/group
index dfadd91..d685076 100644
--- a/tests/ext4/group
+++ b/tests/ext4/group
@@ -18,3 +18,9 @@
307 auto ioctl rw
308 auto ioctl rw prealloc quick
700 dangerous_fuzzers
+701 fuzzers
+702 fuzzers
+703 fuzzers
+704 fuzzers
+705 fuzzers
+706 fuzzers
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] ext4: test file/dir/symlink metadata corruption checking and repair
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
` (2 preceding siblings ...)
2015-08-15 1:52 ` [PATCH 3/7] ext4: test block group metadata corruption checking and repair Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
2015-08-15 1:52 ` [PATCH 5/7] xfs: test allocation group " Darrick J. Wong
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
Targeted fuzzing tests which destroy various pieces of file,
directory, and symlink metadata; the tests look for (a) kernel
detection of corruption, (b) e2fsck repair of said corruption, and (c)
post-repair fs usability.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
tests/ext4/707 | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/ext4/707.out | 15 ++++++
tests/ext4/708 | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/ext4/708.out | 15 ++++++
tests/ext4/709 | 103 +++++++++++++++++++++++++++++++++++++++++++
tests/ext4/709.out | 12 +++++
tests/ext4/710 | 96 ++++++++++++++++++++++++++++++++++++++++
tests/ext4/710.out | 12 +++++
tests/ext4/711 | 99 +++++++++++++++++++++++++++++++++++++++++
tests/ext4/711.out | 12 +++++
tests/ext4/712 | 97 ++++++++++++++++++++++++++++++++++++++++
tests/ext4/712.out | 12 +++++
tests/ext4/713 | 95 +++++++++++++++++++++++++++++++++++++++
tests/ext4/713.out | 11 +++++
tests/ext4/group | 7 +++
15 files changed, 836 insertions(+)
create mode 100755 tests/ext4/707
create mode 100644 tests/ext4/707.out
create mode 100755 tests/ext4/708
create mode 100644 tests/ext4/708.out
create mode 100755 tests/ext4/709
create mode 100644 tests/ext4/709.out
create mode 100755 tests/ext4/710
create mode 100644 tests/ext4/710.out
create mode 100755 tests/ext4/711
create mode 100644 tests/ext4/711.out
create mode 100755 tests/ext4/712
create mode 100644 tests/ext4/712.out
create mode 100755 tests/ext4/713
create mode 100644 tests/ext4/713.out
diff --git a/tests/ext4/707 b/tests/ext4/707
new file mode 100755
index 0000000..c62b107
--- /dev/null
+++ b/tests/ext4/707
@@ -0,0 +1,126 @@
+#! /bin/bash
+# FS QA Test No. 707
+#
+# Create and populate an ext4 filesystem, corrupt an inode, then see how
+# the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+blk="$(debugfs -R "imap <$inode>" "${SCRATCH_DEV}" 2> /dev/null | grep located | sed -e 's/^.*block \([0-9]*\),.*$/\1/g')"
+debugfs -w -R "zap_block ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "inode fuzz failed"
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+broken=0
+for x in `seq 1 64`; do
+ #test -e "${TESTFILE}.${x}" || continue
+ stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ modify files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -e "${TESTFILE}.${x}" || continue
+ stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/707.out b/tests/ext4/707.out
new file mode 100644
index 0000000..4cbeaf9
--- /dev/null
+++ b/tests/ext4/707.out
@@ -0,0 +1,15 @@
+QA output created by 707
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
+broken: 1
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/ext4/708 b/tests/ext4/708
new file mode 100755
index 0000000..24e259b
--- /dev/null
+++ b/tests/ext4/708
@@ -0,0 +1,124 @@
+#! /bin/bash
+# FS QA Test No. 708
+#
+# Create and populate an ext4 filesystem, corrupt root directory, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 128`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 64 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+debugfs -w -R "zap -f / 0" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+broken=0
+for x in `seq 1 64`; do
+ #test -e "${TESTFILE}.${x}" || continue
+ stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 && _fail "e2fsck should not succeed"
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ modify files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -e "${TESTFILE}.${x}" || continue
+ stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/708.out b/tests/ext4/708.out
new file mode 100644
index 0000000..0eb44c0
--- /dev/null
+++ b/tests/ext4/708.out
@@ -0,0 +1,15 @@
+QA output created by 708
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
+broken: 1
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/ext4/709 b/tests/ext4/709
new file mode 100755
index 0000000..9edfea9
--- /dev/null
+++ b/tests/ext4/709
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 709
+#
+# Create and populate an ext4 filesystem, corrupt an extent tree block, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+freeblks="$((3 * blksz / 12))"
+
+echo "+ make some files"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * freeblks))" "${SCRATCH_MNT}/bigfile" >> $seqres.full
+seq 1 2 ${freeblks} | while read lblk; do
+ $XFS_IO_PROG -f -c "fpunch $((lblk * blksz)) ${blksz}" "${SCRATCH_MNT}/bigfile" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+debugfs "${SCRATCH_DEV}" -R 'ex /bigfile' 2> /dev/null | grep '^ 0' | awk '{print $8}' | while read blk; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 $((blk * blksz + 8)) 8" "${SCRATCH_DEV}" >> $seqres.full
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+echo moo >> "${SCRATCH_MNT}/bigfile" 2> /dev/null && _fail "extent tree should be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ modify files (2)"
+$XFS_IO_PROG -f -c "pwrite ${blksz} ${blksz}" "${SCRATCH_MNT}/bigfile" >> $seqres.full
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/709.out b/tests/ext4/709.out
new file mode 100644
index 0000000..6d8a022
--- /dev/null
+++ b/tests/ext4/709.out
@@ -0,0 +1,12 @@
+QA output created by 709
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image (2)
++ modify files (2)
++ check fs (2)
diff --git a/tests/ext4/710 b/tests/ext4/710
new file mode 100755
index 0000000..e113254
--- /dev/null
+++ b/tests/ext4/710
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 710
+#
+# Create and populate an ext4 filesystem, corrupt a dirent block, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+
+echo "+ make some files"
+for x in `seq 1 15`; do
+ mkdir -p "${SCRATCH_MNT}/test/d_${x}"
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+debugfs -w -R "zap -f /test 0" "${SCRATCH_DEV}" 2> /dev/null
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify dirs"
+mkdir -p "${SCRATCH_MNT}/test/newdir" 2> /dev/null && _fail "directory should be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ modify dirs (2)"
+mkdir -p "${SCRATCH_MNT}/test/newdir" || _fail "directory should be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/710.out b/tests/ext4/710.out
new file mode 100644
index 0000000..6d9b3aa
--- /dev/null
+++ b/tests/ext4/710.out
@@ -0,0 +1,12 @@
+QA output created by 710
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify dirs
++ repair fs
++ mount image (2)
++ modify dirs (2)
++ check fs (2)
diff --git a/tests/ext4/711 b/tests/ext4/711
new file mode 100755
index 0000000..06c6a39
--- /dev/null
+++ b/tests/ext4/711
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 711
+#
+# Create and populate an ext4 filesystem, corrupt a htree block, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${SCRATCH_MNT}/test/"
+for x in `seq 1 $((blksz * 4 / 256))`; do
+ fname="$(printf "%.255s\n" "$(perl -e "print \"${x}_\" x 500;")")"
+ touch "${SCRATCH_MNT}/test/${fname}"
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+debugfs -w -R "zap -f /test 0" "${SCRATCH_DEV}" 2> /dev/null
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify dirs"
+mkdir -p "${SCRATCH_MNT}/test/newdir" 2> /dev/null && _fail "htree should be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ modify dirs (2)"
+mkdir -p "${SCRATCH_MNT}/test/newdir" || _fail "htree should not be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/711.out b/tests/ext4/711.out
new file mode 100644
index 0000000..ef1fc8b
--- /dev/null
+++ b/tests/ext4/711.out
@@ -0,0 +1,12 @@
+QA output created by 711
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify dirs
++ repair fs
++ mount image (2)
++ modify dirs (2)
++ check fs (2)
diff --git a/tests/ext4/712 b/tests/ext4/712
new file mode 100755
index 0000000..4bd341e
--- /dev/null
+++ b/tests/ext4/712
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 712
+#
+# Create and populate an ext4 filesystem, corrupt a xattr block, then
+# see how the kernel and e2fsck 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${SCRATCH_MNT}/attrfile" >> $seqres.full
+setfattr -n user.key -v "$(perl -e 'print "v" x 300;')" "${SCRATCH_MNT}/attrfile"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+blk="$(debugfs -R 'stat /attrfile' "${SCRATCH_DEV}" 2> /dev/null | grep 'File ACL:' | sed -e 's/^.*File ACL: \([0-9]*\).*Directory.*$/\1/g')"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $((blk * blksz + 20)) 8" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify attrs"
+setfattr -n user.newkey -v "$(perl -e 'print "v" x 300;')" "${SCRATCH_MNT}/attrfile" 2> /dev/null && _fail "xattr should be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ modify attrs (2)"
+setfattr -n user.newkey -v "$(perl -e 'print "v" x 300;')" "${SCRATCH_MNT}/attrfile" || _fail "xattr should not be corrupt"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/712.out b/tests/ext4/712.out
new file mode 100644
index 0000000..3bafe93
--- /dev/null
+++ b/tests/ext4/712.out
@@ -0,0 +1,12 @@
+QA output created by 712
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify attrs
++ repair fs
++ mount image (2)
++ modify attrs (2)
++ check fs (2)
diff --git a/tests/ext4/713 b/tests/ext4/713
new file mode 100755
index 0000000..cf15425
--- /dev/null
+++ b/tests/ext4/713
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 713
+#
+# Create and populate an ext4 filesystem, corrupt a big symlink, then
+# see how the kernel and e2fsck deal with it. (They won't)
+#
+#-----------------------------------------------------------------------
+# 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
+
+# real QA test starts here
+_supported_fs ext4
+_supported_os Linux
+
+_require_scratch
+test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
+_require_attrs
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_ext4 -O journal > /dev/null 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+test "${blksz}" -gt 4096 && blksz=4096
+
+echo "+ make some files"
+echo "file contents: moo" > "${SCRATCH_MNT}/x"
+str="$(perl -e "print './' x $(( (blksz / 2) - 16));")x"
+(cd $SCRATCH_MNT; ln -s "${str}" "long_symlink")
+cat "${SCRATCH_MNT}/long_symlink"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+echo "+ corrupt image"
+debugfs -w -R 'zap -f /long_symlink -p 0x62 0' "${SCRATCH_DEV}" 2> /dev/null
+
+echo "+ mount image"
+_scratch_mount 2> /dev/null
+cat "${SCRATCH_MNT}/long_symlink" 2>/dev/null && _fail "symlink should be broken"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+cat "${SCRATCH_MNT}/long_symlink" 2>/dev/null && _fail "symlink should be broken"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+
+status=0
+exit
diff --git a/tests/ext4/713.out b/tests/ext4/713.out
new file mode 100644
index 0000000..10e7305
--- /dev/null
+++ b/tests/ext4/713.out
@@ -0,0 +1,11 @@
+QA output created by 713
++ create scratch fs
++ mount fs image
++ make some files
+file contents: moo
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ check fs (2)
diff --git a/tests/ext4/group b/tests/ext4/group
index d685076..13c8d90 100644
--- a/tests/ext4/group
+++ b/tests/ext4/group
@@ -24,3 +24,10 @@
704 fuzzers
705 fuzzers
706 fuzzers
+707 fuzzers
+708 fuzzers
+709 fuzzers
+710 fuzzers
+711 fuzzers
+712 fuzzers
+713 fuzzers
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] xfs: test allocation group metadata corruption checking and repair
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
` (3 preceding siblings ...)
2015-08-15 1:52 ` [PATCH 4/7] ext4: test file/dir/symlink " Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
2015-08-15 1:52 ` [PATCH 6/7] xfs: test directory " Darrick J. Wong
2015-08-15 1:52 ` [PATCH 7/7] xfs: test file/symlink " Darrick J. Wong
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
Targeted fuzzing tests which destroy various pieces of filesystem or
allocation group 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>
---
common/rc | 11 ++++
tests/xfs/701 | 115 +++++++++++++++++++++++++++++++++++++++++
tests/xfs/701.out | 13 +++++
tests/xfs/702 | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/702.out | 20 +++++++
tests/xfs/703 | 124 +++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/703.out | 15 +++++
tests/xfs/704 | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/704.out | 20 +++++++
tests/xfs/705 | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/705.out | 20 +++++++
tests/xfs/706 | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/706.out | 20 +++++++
tests/xfs/707 | 124 +++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/707.out | 15 +++++
tests/xfs/708 | 127 ++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/708.out | 15 +++++
tests/xfs/709 | 118 +++++++++++++++++++++++++++++++++++++++++++
tests/xfs/709.out | 13 +++++
tests/xfs/group | 9 +++
20 files changed, 1366 insertions(+)
create mode 100755 tests/xfs/701
create mode 100644 tests/xfs/701.out
create mode 100755 tests/xfs/702
create mode 100644 tests/xfs/702.out
create mode 100755 tests/xfs/703
create mode 100644 tests/xfs/703.out
create mode 100755 tests/xfs/704
create mode 100644 tests/xfs/704.out
create mode 100755 tests/xfs/705
create mode 100644 tests/xfs/705.out
create mode 100755 tests/xfs/706
create mode 100644 tests/xfs/706.out
create mode 100755 tests/xfs/707
create mode 100644 tests/xfs/707.out
create mode 100755 tests/xfs/708
create mode 100644 tests/xfs/708.out
create mode 100755 tests/xfs/709
create mode 100644 tests/xfs/709.out
diff --git a/common/rc b/common/rc
index f889103..1e7e47b 100644
--- a/common/rc
+++ b/common/rc
@@ -1409,6 +1409,17 @@ _require_scratch_ext4_crc()
umount $SCRATCH_MNT
}
+# this test requires the xfs kernel support crc feature on scratch device
+#
+_require_scratch_xfs_crc()
+{
+ _scratch_mkfs_xfs >/dev/null 2>&1
+ _scratch_mount >/dev/null 2>&1 \
+ || _notrun "Kernel doesn't support crc feature"
+ xfs_info $SCRATCH_MNT | grep -q 'crc=1' || _notrun "crc feature not supported by this filesystem"
+ umount $SCRATCH_MNT
+}
+
# this test requires the bigalloc feature to be available in mkfs.ext4
#
_require_ext4_mkfs_bigalloc()
diff --git a/tests/xfs/701 b/tests/xfs/701
new file mode 100755
index 0000000..00f2a46
--- /dev/null
+++ b/tests/xfs/701
@@ -0,0 +1,115 @@
+#! /bin/bash
+# FS QA Test No. 701
+#
+# Create and populate an XFS filesystem, corrupt a superblock, 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
+
+rm -f $seqres.full
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 32 4" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount 2>/dev/null && _fail "mount should not succeed"
+
+echo "+ repair fs"
+_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 files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -e "${TESTFILE}.${x}" || continue
+ echo moo | dd oflag=append conv=notrunc of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+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/701.out b/tests/xfs/701.out
new file mode 100644
index 0000000..a44edb2
--- /dev/null
+++ b/tests/xfs/701.out
@@ -0,0 +1,13 @@
+QA output created by 701
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/702 b/tests/xfs/702
new file mode 100755
index 0000000..1cbc3e9
--- /dev/null
+++ b/tests/xfs/702
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FS QA Test No. 702
+#
+# Create and populate an XFS filesystem, corrupt an AGF, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+test "${agcount}" -gt 1 || _notrun "Single-AG XFS not supported"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+# Try to append to files; this should fail
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files"
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+
+# Try appending again, now that we've fixed the fs
+echo "+ modify files (2)"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 ${blksz} ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/702.out b/tests/xfs/702.out
new file mode 100644
index 0000000..e44c454
--- /dev/null
+++ b/tests/xfs/702.out
@@ -0,0 +1,20 @@
+QA output created by 702
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image
++ chattr -R -i
++ check files
+broken: 1
++ modify files (2)
++ repair fs
++ mount image
++ chattr -R -i
++ check files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/703 b/tests/xfs/703
new file mode 100755
index 0000000..459d80b
--- /dev/null
+++ b/tests/xfs/703
@@ -0,0 +1,124 @@
+#! /bin/bash
+# FS QA Test No. 703
+#
+# Create and populate an XFS filesystem, corrupt the AGI, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+broken=0
+for x in `seq 65 70`; do
+ touch "${TESTFILE}.${x}" 2> /dev/null || broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_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 files (2)"
+broken=0
+for x in `seq 65 70`; do
+ touch "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/703.out b/tests/xfs/703.out
new file mode 100644
index 0000000..76ba47c
--- /dev/null
+++ b/tests/xfs/703.out
@@ -0,0 +1,15 @@
+QA output created by 703
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
+broken: 1
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/704 b/tests/xfs/704
new file mode 100755
index 0000000..9370463
--- /dev/null
+++ b/tests/xfs/704
@@ -0,0 +1,146 @@
+#! /bin/bash
+# FS QA Test No. 704
+#
+# Create and populate an XFS filesystem, corrupt the AGFL, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agfl ${ag}" -c "agfl ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+# Try to append to files; this should fail
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files"
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+
+# Try appending again, now that we've fixed the fs
+echo "+ modify files (2)"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 ${blksz} ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/704.out b/tests/xfs/704.out
new file mode 100644
index 0000000..14871e5
--- /dev/null
+++ b/tests/xfs/704.out
@@ -0,0 +1,20 @@
+QA output created by 704
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image
++ chattr -R -i
++ check files
+broken: 1
++ modify files (2)
++ repair fs
++ mount image
++ chattr -R -i
++ check files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/705 b/tests/xfs/705
new file mode 100755
index 0000000..b5c3eb0
--- /dev/null
+++ b/tests/xfs/705
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FS QA Test No. 705
+#
+# Create and populate an XFS filesystem, corrupt the bnobt, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr bnoroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+# Try to append to files; this should fail
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files"
+ls -la "${TESTDIR}" >> $seqres.full
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+
+# Try appending again, now that we've fixed the fs
+echo "+ modify files (2)"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 ${blksz} ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/705.out b/tests/xfs/705.out
new file mode 100644
index 0000000..4288234
--- /dev/null
+++ b/tests/xfs/705.out
@@ -0,0 +1,20 @@
+QA output created by 705
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image
++ chattr -R -i
++ check files
+broken: 1
++ modify files (2)
++ repair fs
++ mount image
++ chattr -R -i
++ check files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/706 b/tests/xfs/706
new file mode 100755
index 0000000..1aa2d57
--- /dev/null
+++ b/tests/xfs/706
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FS QA Test No. 706
+#
+# Create and populate an XFS filesystem, corrupt the cntbt, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr cntroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+# Try to append to files; this should fail
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files"
+ls -la "${TESTDIR}" >> $seqres.full
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+
+# Try appending again, now that we've fixed the fs
+echo "+ modify files (2)"
+for x in `seq 1 64`; do
+ $XFS_IO_PROG -f -c "pwrite -S 0x62 ${blksz} ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
+done
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ check files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -s "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/706.out b/tests/xfs/706.out
new file mode 100644
index 0000000..0051a92
--- /dev/null
+++ b/tests/xfs/706.out
@@ -0,0 +1,20 @@
+QA output created by 706
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image
++ chattr -R -i
++ check files
+broken: 1
++ modify files (2)
++ repair fs
++ mount image
++ chattr -R -i
++ check files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/707 b/tests/xfs/707
new file mode 100755
index 0000000..1107714
--- /dev/null
+++ b/tests/xfs/707
@@ -0,0 +1,124 @@
+#! /bin/bash
+# FS QA Test No. 707
+#
+# Create and populate an XFS filesystem, corrupt the inobt, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+broken=0
+for x in `seq 65 70`; do
+ touch "${TESTFILE}.${x}" 2> /dev/null || broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_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 files (2)"
+broken=0
+for x in `seq 65 70`; do
+ touch "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/707.out b/tests/xfs/707.out
new file mode 100644
index 0000000..4cbeaf9
--- /dev/null
+++ b/tests/xfs/707.out
@@ -0,0 +1,15 @@
+QA output created by 707
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
+broken: 1
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/708 b/tests/xfs/708
new file mode 100755
index 0000000..a9a3710
--- /dev/null
+++ b/tests/xfs/708
@@ -0,0 +1,127 @@
+#! /bin/bash
+# FS QA Test No. 708
+#
+# Create and populate an XFS filesystem, corrupt the finobt, 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
+_require_xfs_mkfs_finobt
+_require_xfs_finobt
+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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+xfs_info "${SCRATCH_MNT}" | grep -q "finobt=1" || _notrun "finobt not enabled"
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+ $XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+broken=0
+for x in `seq 65 70`; do
+ touch "${TESTFILE}.${x}" 2> /dev/null || broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_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 files (2)"
+broken=0
+for x in `seq 65 70`; do
+ touch "${TESTFILE}.${x}" || broken=1
+done
+echo "broken: ${broken}"
+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/708.out b/tests/xfs/708.out
new file mode 100644
index 0000000..0eb44c0
--- /dev/null
+++ b/tests/xfs/708.out
@@ -0,0 +1,15 @@
+QA output created by 708
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
+broken: 1
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/709 b/tests/xfs/709
new file mode 100755
index 0000000..33192f8
--- /dev/null
+++ b/tests/xfs/709
@@ -0,0 +1,118 @@
+#! /bin/bash
+# FS QA Test No. 709
+#
+# Create and populate an XFS filesystem, corrupt the journal, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+logstart="$($XFS_DB_PROG -c 'sb 0' -c 'p' "${SCRATCH_DEV}" | grep '^logstart =' | cut -d ' ' -f 3)"
+logstart="$($XFS_DB_PROG -c "convert fsblock ${logstart} byte" "${SCRATCH_DEV}" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
+logblocks="$(xfs_db -c 'sb 0' -c 'p' "${SCRATCH_DEV}" | grep '^logblocks =' | cut -d ' ' -f 3)"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount 2>/dev/null && _fail "mount should not succeed"
+
+echo "+ repair fs"
+_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 files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -e "${TESTFILE}.${x}" || continue
+ echo moo | dd oflag=append conv=notrunc of="${TESTFILE}.${x}" 2>/dev/null
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+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/709.out b/tests/xfs/709.out
new file mode 100644
index 0000000..6badb94
--- /dev/null
+++ b/tests/xfs/709.out
@@ -0,0 +1,13 @@
+QA output created by 709
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/group b/tests/xfs/group
index 140df27..bdd0bb0 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -198,3 +198,12 @@
304 auto quick quota
305 auto quota
700 dangerous_fuzzers
+701 fuzzers
+702 fuzzers
+703 fuzzers
+704 fuzzers
+705 fuzzers
+706 fuzzers
+707 fuzzers
+708 fuzzers
+709 fuzzers
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] xfs: test directory metadata corruption checking and repair
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
` (4 preceding siblings ...)
2015-08-15 1:52 ` [PATCH 5/7] xfs: test allocation group " Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
2015-08-15 1:52 ` [PATCH 7/7] xfs: test file/symlink " Darrick J. Wong
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
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>
---
tests/xfs/710 | 111 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/710.out | 14 ++++++
tests/xfs/711 | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/711.out | 14 ++++++
tests/xfs/712 | 111 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/712.out | 14 ++++++
tests/xfs/713 | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/713.out | 14 ++++++
tests/xfs/714 | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/714.out | 14 ++++++
tests/xfs/715 | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/715.out | 14 ++++++
tests/xfs/716 | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/716.out | 14 ++++++
tests/xfs/group | 7 +++
15 files changed, 911 insertions(+)
create mode 100755 tests/xfs/710
create mode 100644 tests/xfs/710.out
create mode 100755 tests/xfs/711
create mode 100644 tests/xfs/711.out
create mode 100755 tests/xfs/712
create mode 100644 tests/xfs/712.out
create mode 100755 tests/xfs/713
create mode 100644 tests/xfs/713.out
create mode 100755 tests/xfs/714
create mode 100644 tests/xfs/714.out
create mode 100755 tests/xfs/715
create mode 100644 tests/xfs/715.out
create mode 100755 tests/xfs/716
create mode 100644 tests/xfs/716.out
diff --git a/tests/xfs/710 b/tests/xfs/710
new file mode 100755
index 0000000..11c91fe
--- /dev/null
+++ b/tests/xfs/710
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 710
+#
+# 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/710.out b/tests/xfs/710.out
new file mode 100644
index 0000000..d8b5681
--- /dev/null
+++ b/tests/xfs/710.out
@@ -0,0 +1,14 @@
+QA output created by 710
++ 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/711 b/tests/xfs/711
new file mode 100755
index 0000000..7efcccf
--- /dev/null
+++ b/tests/xfs/711
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 711
+#
+# 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/711.out b/tests/xfs/711.out
new file mode 100644
index 0000000..d8edca0
--- /dev/null
+++ b/tests/xfs/711.out
@@ -0,0 +1,14 @@
+QA output created by 711
++ 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/712 b/tests/xfs/712
new file mode 100755
index 0000000..61b22d2
--- /dev/null
+++ b/tests/xfs/712
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 712
+#
+# 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/712.out b/tests/xfs/712.out
new file mode 100644
index 0000000..c1df4c8
--- /dev/null
+++ b/tests/xfs/712.out
@@ -0,0 +1,14 @@
+QA output created by 712
++ 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/713 b/tests/xfs/713
new file mode 100755
index 0000000..4afeeac
--- /dev/null
+++ b/tests/xfs/713
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 713
+#
+# 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/713.out b/tests/xfs/713.out
new file mode 100644
index 0000000..22f1de1
--- /dev/null
+++ b/tests/xfs/713.out
@@ -0,0 +1,14 @@
+QA output created by 713
++ 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/714 b/tests/xfs/714
new file mode 100755
index 0000000..488bb7c
--- /dev/null
+++ b/tests/xfs/714
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 714
+#
+# 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/714.out b/tests/xfs/714.out
new file mode 100644
index 0000000..c280b7b
--- /dev/null
+++ b/tests/xfs/714.out
@@ -0,0 +1,14 @@
+QA output created by 714
++ 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/715 b/tests/xfs/715
new file mode 100755
index 0000000..7121ca9
--- /dev/null
+++ b/tests/xfs/715
@@ -0,0 +1,120 @@
+#! /bin/bash
+# FS QA Test No. 715
+#
+# 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/715.out b/tests/xfs/715.out
new file mode 100644
index 0000000..c5b733a
--- /dev/null
+++ b/tests/xfs/715.out
@@ -0,0 +1,14 @@
+QA output created by 715
++ 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/716 b/tests/xfs/716
new file mode 100755
index 0000000..7a309c5
--- /dev/null
+++ b/tests/xfs/716
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 716
+#
+# 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/716.out b/tests/xfs/716.out
new file mode 100644
index 0000000..36e3fca
--- /dev/null
+++ b/tests/xfs/716.out
@@ -0,0 +1,14 @@
+QA output created by 716
++ 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 bdd0bb0..8e4f8b7 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -207,3 +207,10 @@
707 fuzzers
708 fuzzers
709 fuzzers
+710 fuzzers
+711 fuzzers
+712 fuzzers
+713 fuzzers
+714 fuzzers
+715 fuzzers
+716 fuzzers
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] xfs: test file/symlink metadata corruption checking and repair
2015-08-15 1:52 [PATCH 0/7] xfstests: fuzz ext4 and xfs Darrick J. Wong
` (5 preceding siblings ...)
2015-08-15 1:52 ` [PATCH 6/7] xfs: test directory " Darrick J. Wong
@ 2015-08-15 1:52 ` Darrick J. Wong
6 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2015-08-15 1:52 UTC (permalink / raw)
To: david, darrick.wong; +Cc: linux-ext4, fstests, xfs
Targeted fuzzing tests which destroy various pieces of file and
symlink 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>
---
tests/xfs/717 | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/717.out | 15 ++++++
tests/xfs/718 | 111 +++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/718.out | 13 +++++
tests/xfs/719 | 96 +++++++++++++++++++++++++++++++++++++++
tests/xfs/719.out | 11 ++++
tests/xfs/720 | 114 ++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/720.out | 14 ++++++
tests/xfs/721 | 114 ++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/721.out | 14 ++++++
tests/xfs/722 | 118 +++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/722.out | 14 ++++++
tests/xfs/group | 6 ++
13 files changed, 772 insertions(+)
create mode 100755 tests/xfs/717
create mode 100644 tests/xfs/717.out
create mode 100755 tests/xfs/718
create mode 100644 tests/xfs/718.out
create mode 100755 tests/xfs/719
create mode 100644 tests/xfs/719.out
create mode 100755 tests/xfs/720
create mode 100644 tests/xfs/720.out
create mode 100755 tests/xfs/721
create mode 100644 tests/xfs/721.out
create mode 100755 tests/xfs/722
create mode 100644 tests/xfs/722.out
diff --git a/tests/xfs/717 b/tests/xfs/717
new file mode 100755
index 0000000..ffc0c4e
--- /dev/null
+++ b/tests/xfs/717
@@ -0,0 +1,132 @@
+#! /bin/bash
+# FS QA Test No. 717
+#
+# Create and populate an XFS filesystem, corrupt an inode, 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
+TESTDIR="${SCRATCH_MNT}/scratchdir"
+TESTFILE="${TESTDIR}/testfile"
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+
+echo "+ make some files"
+mkdir -p "${TESTDIR}"
+for x in `seq 1 1024`; do
+ touch "${SCRATCH_MNT}/junk.${x}"
+ inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
+ if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
+ mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
+ break
+ fi
+done
+for x in `seq 2 64`; do
+ touch "${TESTFILE}.${x}"
+done
+inode="$(stat -c '%i' "${TESTFILE}.1")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+seq "${inode}" "$((inode + 64))" | while read ino; do
+ $XFS_DB_PROG -x -c "inode ${ino}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+broken=0
+for x in `seq 1 64`; do
+ stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ touch "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+done
+echo "broken: ${broken}"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_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 files (2)"
+broken=0
+for x in `seq 1 64`; do
+ test -e "${TESTFILE}.${x}" || continue
+ echo "test ${x}" >> $seqres.full
+ stat "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ touch "${TESTFILE}.${x}" >> $seqres.full 2>&1
+ test $? -ne 0 && broken=1
+ echo "${x}: broken=${broken}" >> $seqres.full
+done
+echo "broken: ${broken}"
+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/717.out b/tests/xfs/717.out
new file mode 100644
index 0000000..6446bb7
--- /dev/null
+++ b/tests/xfs/717.out
@@ -0,0 +1,15 @@
+QA output created by 717
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
+broken: 1
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
+broken: 0
++ check fs (2)
diff --git a/tests/xfs/718 b/tests/xfs/718
new file mode 100755
index 0000000..99519d2
--- /dev/null
+++ b/tests/xfs/718
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 718
+#
+# Create and populate an XFS filesystem, corrupt the bmbt, 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
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+nr="$((blksz * 2 / 16))"
+
+echo "+ make some files"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full
+for i in $(seq 1 2 ${nr}); do
+ $XFS_IO_PROG -f -c "fpunch $((i * blksz)) ${blksz}" "${SCRATCH_MNT}/bigfile" >> $seqres.full
+done
+inode="$(stat -c '%i' "${SCRATCH_MNT}/bigfile")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "addr u.bmbt.ptrs[1]" -c "addr u3.bmbt.ptrs[1]" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify files"
+before="$(stat -c '%b' "${SCRATCH_MNT}/bigfile")"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 ${blksz} ${blksz}" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full 2> /dev/null
+after="$(stat -c '%b' "${SCRATCH_MNT}/bigfile")"
+test "${before}" -eq "${after}" || _fail "pwrite should fail on corrupt bmbt"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_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 files (2)"
+touch "${SCRATCH_MNT}/bigfile"
+before="$(stat -c '%b' "${SCRATCH_MNT}/bigfile")"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 ${blksz} ${blksz}" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full 2> /dev/null
+after="$(stat -c '%b' "${SCRATCH_MNT}/bigfile")"
+test "${before}" -ne "${after}" || _fail "pwrite failed after fixing corrupt bmbt"
+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/718.out b/tests/xfs/718.out
new file mode 100644
index 0000000..0b53f4d
--- /dev/null
+++ b/tests/xfs/718.out
@@ -0,0 +1,13 @@
+QA output created by 718
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ modify files
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify files (2)
++ check fs (2)
diff --git a/tests/xfs/719 b/tests/xfs/719
new file mode 100755
index 0000000..459889e
--- /dev/null
+++ b/tests/xfs/719
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 719
+#
+# Create and populate an XFS filesystem, corrupt a long symlink, 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
+blksz=1000
+
+echo "+ make some files"
+echo "file contents: moo" > "${SCRATCH_MNT}/x"
+str="$(perl -e "print './' x $(( (blksz / 2) - 16));")x"
+(cd $SCRATCH_MNT; ln -s "${str}" "long_symlink")
+cat "${SCRATCH_MNT}/long_symlink"
+inode="$(stat -c '%i' "${SCRATCH_MNT}/long_symlink")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount
+cat "${SCRATCH_MNT}/long_symlink" 2>/dev/null && _fail "symlink should be broken"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+cat "${SCRATCH_MNT}/long_symlink" 2>/dev/null && _fail "symlink should be broken"
+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/719.out b/tests/xfs/719.out
new file mode 100644
index 0000000..bb64ddd
--- /dev/null
+++ b/tests/xfs/719.out
@@ -0,0 +1,11 @@
+QA output created by 719
++ create scratch fs
++ mount fs image
++ make some files
+file contents: moo
++ check fs
++ corrupt image
++ mount image
++ repair fs
++ mount image (2)
++ check fs (2)
diff --git a/tests/xfs/720 b/tests/xfs/720
new file mode 100755
index 0000000..ad4cad3
--- /dev/null
+++ b/tests/xfs/720
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 720
+#
+# Create and populate an XFS filesystem, corrupt a block xattr, 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
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+nr="$((blksz / 40))"
+leaf_lblk="$((32 * 1073741824 / blksz))"
+node_lblk="$((64 * 1073741824 / blksz))"
+
+echo "+ make some files"
+touch "${SCRATCH_MNT}/attrfile"
+seq 0 "${nr}" | while read d; do
+ setfattr -n "user.x$(printf "%.08d" "$d")" -v "0000000000000000" "${SCRATCH_MNT}/attrfile"
+done
+inode="$(stat -c '%i' "${SCRATCH_MNT}/attrfile")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ check xattr"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}" >> $seqres.full
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a block xattr (data)"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${leaf_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || _fail "failed to create a block xattr (leaf)"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${node_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || _fail "failed to create a block xattr (free)"
+
+echo "+ corrupt xattr"
+$XFS_DB_PROG -x -c "inode ${inode}" -c 'ablock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify xattr"
+setfattr -x "user.x00000000" "${SCRATCH_MNT}/attrfile" 2> /dev/null && _fail "modified corrupt xattr"
+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 xattr (2)"
+getfattr "${SCRATCH_MNT}/attrfile" -n "user.x00000000" > /dev/null 2>&1 && (setfattr -x "user.x00000000" "${SCRATCH_MNT}/attrfile" || _fail "remove corrupt xattr")
+setfattr -n "user.x00000000" -v 'x0x0x0x0' "${SCRATCH_MNT}/attrfile" || _fail "add corrupt xattr"
+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/720.out b/tests/xfs/720.out
new file mode 100644
index 0000000..4110f66
--- /dev/null
+++ b/tests/xfs/720.out
@@ -0,0 +1,14 @@
+QA output created by 720
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ check xattr
++ corrupt xattr
++ mount image
++ modify xattr
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify xattr (2)
++ check fs (2)
diff --git a/tests/xfs/721 b/tests/xfs/721
new file mode 100755
index 0000000..ec87139
--- /dev/null
+++ b/tests/xfs/721
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 721
+#
+# Create and populate an XFS filesystem, corrupt a leaf xattr's index 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
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+nr="$((8 * blksz / 40))"
+
+echo "+ make some files"
+touch "${SCRATCH_MNT}/attrfile"
+seq 0 "${nr}" | while read d; do
+ setfattr -n "user.x$(printf "%.08d" "$d")" -v "0000000000000000" "${SCRATCH_MNT}/attrfile"
+done
+seq 1 2 "${nr}" | while read d; do
+ setfattr -x "user.x$(printf "%.08d" "$d")" "${SCRATCH_MNT}/attrfile"
+done
+inode="$(stat -c '%i' "${SCRATCH_MNT}/attrfile")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ check xattr"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}" >> $seqres.full
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (index)"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 1" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (data)"
+
+echo "+ corrupt xattr"
+$XFS_DB_PROG -x -c "inode ${inode}" -c 'ablock 0' -c "stack" -c "blocktrash -x 32 -o +32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ modify xattr"
+setfattr -x "user.x00000000" "${SCRATCH_MNT}/attrfile" 2> /dev/null && _fail "modified corrupt xattr"
+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 xattr (2)"
+setfattr -n "user.x00000000" -v "1111111111111111" "${SCRATCH_MNT}/attrfile" || _fail "modified corrupt xattr"
+setfattr -x "user.x00000000" "${SCRATCH_MNT}/attrfile" || _fail "delete corrupt xattr"
+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/721.out b/tests/xfs/721.out
new file mode 100644
index 0000000..2098e75
--- /dev/null
+++ b/tests/xfs/721.out
@@ -0,0 +1,14 @@
+QA output created by 721
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ check xattr
++ corrupt xattr
++ mount image
++ modify xattr
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify xattr (2)
++ check fs (2)
diff --git a/tests/xfs/722 b/tests/xfs/722
new file mode 100755
index 0000000..f2d7192
--- /dev/null
+++ b/tests/xfs/722
@@ -0,0 +1,118 @@
+#! /bin/bash
+# FS QA Test No. 722
+#
+# Create and populate an XFS filesystem, corrupt a leaf xattr'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
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+nr="$((8 * blksz / 40))"
+
+echo "+ make some files"
+touch "${SCRATCH_MNT}/attrfile"
+seq 0 "${nr}" | while read d; do
+ setfattr -n "user.x$(printf "%.08d" "$d")" -v "0000000000000000" "${SCRATCH_MNT}/attrfile"
+done
+seq 1 2 "${nr}" | while read d; do
+ setfattr -x "user.x$(printf "%.08d" "$d")" "${SCRATCH_MNT}/attrfile"
+done
+inode="$(stat -c '%i' "${SCRATCH_MNT}/attrfile")"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ check xattr"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}" >> $seqres.full
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (index)"
+$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 1" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (data)"
+
+echo "+ corrupt xattr"
+loff=1
+while true; do
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && break
+ $XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${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 xattr"
+setfattr -x "user.x00000000" "${SCRATCH_MNT}/attrfile" 2> /dev/null && _fail "modified corrupt xattr"
+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 xattr (2)"
+getfattr "${SCRATCH_MNT}/attrfile" -n "user.x00000000" 2> /dev/null && (setfattr -x "user.x00000000" "${SCRATCH_MNT}/attrfile" || _fail "modified corrupt xattr")
+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/722.out b/tests/xfs/722.out
new file mode 100644
index 0000000..d482a60
--- /dev/null
+++ b/tests/xfs/722.out
@@ -0,0 +1,14 @@
+QA output created by 722
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ check xattr
++ corrupt xattr
++ mount image
++ modify xattr
++ repair fs
++ mount image (2)
++ chattr -R -i
++ modify xattr (2)
++ check fs (2)
diff --git a/tests/xfs/group b/tests/xfs/group
index 8e4f8b7..1510251 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -214,3 +214,9 @@
714 fuzzers
715 fuzzers
716 fuzzers
+717 fuzzers
+718 fuzzers
+719 fuzzers
+720 fuzzers
+721 fuzzers
+722 fuzzers
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 8+ messages in thread