common/dump: filter out xfs_restore messages about fallocate failures
[xfstests-dev.git] / common / dump
index 898aaa40b31ea6facade3f95a3a86740a4ac5f13..3c4029ff1f37ba77b10fc468ddf15c1c1e3de8e6 100644 (file)
@@ -1,23 +1,8 @@
 ##/bin/bash
-#
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2000-2002,2005 Silicon Graphics, 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
-#
-#
 # Functions useful for xfsdump/xfsrestore tests
-#
 
 # --- initializations ---
 rm -f $seqres.full
@@ -29,10 +14,10 @@ if [ -n "$DEBUGDUMP" ]; then
 
        # Use dump/restore in qa directory (copy them here) for debugging
        export PATH="$here:$PATH"
-       export __XFSDUMP_PROG="`set_prog_path xfsdump`"
+       export __XFSDUMP_PROG=$(type -P xfsdump)
        export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
-       export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
-       export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
+       export XFSRESTORE_PROG=$(type -P xfsrestore)
+       export XFSINVUTIL_PROG=$(type -P xfsinvutil)
        [ -x $here/xfsdump ]    && echo "Using xfstests' xfsdump for debug"
        [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
        [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
@@ -60,9 +45,6 @@ session_label="stress_$seq"
 nobody=4 # define this uid/gid as a number
 do_quota_check=true # do quota check if quotas enabled
 
-# install our cleaner
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # start inventory from a known base - move it aside for test
 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
     if [ -d $dir ]; then
@@ -235,14 +217,14 @@ _wipe_fs()
     _require_scratch
 
     _scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
-    _scratch_mount >>$seqres.full || _fail "mount failed"
+    _scratch_mount >>$seqres.full
 }
 
 #
 # Cleanup created dirs and files
 # Called by trap
 #
-_cleanup()
+_cleanup_dump()
 {
     # Some tests include this before checking _supported_fs xfs
     # and the sleeps & checks here get annoying
@@ -251,7 +233,6 @@ _cleanup()
     fi
 
     cd $here
-    rm -f $tmp.*
 
     if [ -n "$DEBUGDUMP" ]; then
        # save it for inspection
@@ -269,7 +250,7 @@ _cleanup()
        mv $dir.$seq $dir
     done
 
-    if [ $status -ne $NOTRUNSTS ]; then
+    if [ -f ${RESULT_DIR}/require_scratch ] && [ $status -ne $NOTRUNSTS ]; then
        # Sleep added to stop _check_scratch_fs from complaining that the
        # scratch_dev is still busy
        sleep 10
@@ -287,7 +268,7 @@ _stable_fs()
 {
     _saveddir=`pwd`; cd /
     _scratch_unmount >>$seqres.full || _fail "unmount failed"
-    _scratch_mount >>$seqres.full || _fail "mount failed"
+    _scratch_mount >>$seqres.full
     cd $_saveddir
 }
 
@@ -312,6 +293,23 @@ _create_dumpdir_stress_num()
         status=1
         exit
     fi
+
+    # Remove fsstress commands that aren't supported on all xfs configs so that
+    # we always execute exactly the same sequence of operations no matter how
+    # the filesystem is configured
+    if $FSSTRESS_PROG | grep -q clonerange; then
+        FSSTRESS_AVOID="-f clonerange=0 $FSSTRESS_AVOID"
+    fi
+    if $FSSTRESS_PROG | grep -q deduperange; then
+        FSSTRESS_AVOID="-f deduperange=0 $FSSTRESS_AVOID"
+    fi
+    if $FSSTRESS_PROG | grep -q copyrange; then
+        FSSTRESS_AVOID="-f copyrange=0 $FSSTRESS_AVOID"
+    fi
+    if $FSSTRESS_PROG | grep -q splice; then
+        FSSTRESS_AVOID="-f splice=0 $FSSTRESS_AVOID"
+    fi
+
     echo ""
     echo "-----------------------------------------------"
     echo "fsstress : $_param"
@@ -868,6 +866,7 @@ _dump_filter_main()
       -e 's/id:[[:space:]]*[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/ID: ID/'                                             \
       -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/'             \
       -e '/skip attribute set/d'                               \
+      -e '/xfsrestore: NOTE: attempt to reserve [0-9]* bytes for.*Operation not supported/d' \
   | perl -ne '
        # filter out all the output between the lines "Dump Summary:"
        # and "Dump Status:"
@@ -1436,16 +1435,19 @@ _check_quota()
                            print "Found extra:", $0
                        }
                        next
+       }
+       $0 ~ "Restore Status: INCOMPLETE" {
+                       incomplete = 1
        }
                        { print }
        END {
-               if (uquota && !found_uquota) {
+               if (uquota && !found_uquota && !incomplete) {
                    print "Missing user quota msg:", usermsg
                }
-               if (gquota && !found_gquota) {
+               if (gquota && !found_gquota && !incomplete) {
                    print "Missing group quota msg:", groupmsg
                }
-               if (pquota && !found_pquota) {
+               if (pquota && !found_pquota && !incomplete) {
                    print "Missing project quota msg:", projectmsg
                }
        }
@@ -1516,6 +1518,26 @@ _check_quota_file()
    _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
 }
 
+_count_dir_files()
+{
+       local dir=$1
+
+       local ndirs=$(find $dir -type d | wc -l)
+       local nents=$(find $dir | wc -l)
+
+       echo "$ndirs directories and $nents entries"
+}
+
+_count_dumpdir_files()
+{
+       _count_dir_files $dump_dir
+}
+
+_count_restoredir_files()
+{
+       _count_dir_files $restore_dir/$dump_sdir
+}
+
 
 # make sure this script returns success
 /bin/true