fstests: remove old electric fence support
[xfstests-dev.git] / common / log
index 87074d971e2a1b90edf522d4e4544263d3da4f65..7a0a5f1f3b168ba0451b79db9b2cf9d6b66173df 100644 (file)
@@ -107,7 +107,6 @@ BEGIN {
 
 _filter_logprint()
 {
-    _fix_malloc |\
     sed '
         s/ver:[0-9]/ver:<VERS>/;
         s/version [0-9] format [0-9]/version <VERS> format <FORMAT>/;
@@ -216,14 +215,80 @@ _check_log()
         | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
 }
 
+_scratch_xfs_logstate()
+{
+    _scratch_xfs_logprint -t | tee -a $seqres.full | grep -q "<CLEAN>"
+    echo $?
+}
+
+_scratch_f2fs_logstate()
+{
+    $DUMP_F2FS_PROG $SCRATCH_DEV | tee -a $seqres.full | grep -q "unmount"
+    echo $?
+}
+
+_scratch_ext4_logstate()
+{
+    $DUMPE2FS_PROG -h $SCRATCH_DEV 2> /dev/null | tee -a $seqres.full | \
+       grep "^Filesystem features" | grep -q needs_recovery
+    test $? -ne 0
+    echo $?
+}
+
+_scratch_dump_log()
+{
+       case "$FSTYP" in
+       xfs)
+               _scratch_xfs_logprint
+               ;;
+       f2fs)
+               $DUMP_F2FS_PROG $SCRATCH_DEV
+               ;;
+       ext4)
+               $DUMPE2FS_PROG -h $SCRATCH_DEV
+               ;;
+       *)
+               ;;
+       esac
+}
+
+_test_dump_log()
+{
+       case "$FSTYP" in
+       xfs)
+               _test_xfs_logprint
+               ;;
+       f2fs)
+               $DUMP_F2FS_PROG $TEST_DEV
+               ;;
+       ext4)
+               $DUMPE2FS_PROG -h $TEST_DEV
+               ;;
+       *)
+               ;;
+       esac
+}
+
 _print_logstate()
 {
-    _scratch_xfs_logprint -t | tee -a $seqres.full >$tmp.logprint
-    if grep -q "<DIRTY>" $tmp.logprint; then
-       echo "dirty log"
-    fi
-    if grep -q "<CLEAN>" $tmp.logprint; then
-       echo "clean log"
+    case "$FSTYP" in
+    xfs)
+        dirty=$(_scratch_xfs_logstate)
+        ;;
+    f2fs)
+        dirty=$(_scratch_f2fs_logstate)
+        ;;
+    ext4)
+        dirty=$(_scratch_ext4_logstate)
+        ;;
+    *)
+        ;;
+    esac
+
+    if [ $dirty -ne 0 ]; then
+        echo "dirty log"
+    else
+        echo "clean log"
     fi
 }
 
@@ -248,7 +313,6 @@ _print_operation()
 # and may not match with the FS mounted at a different LR size 
 # => xlog_do_recovery_pass() can not handle the different hdr sizes
 #    it assumes them all to be the same between the start..finish
-# NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
 
 _print_transaction_inode()
 {
@@ -305,7 +369,7 @@ _create_log()
 {
     # mount the FS
     _full "mount"
-    _scratch_mount >>$seqres.full 2>&1
+    _try_scratch_mount >>$seqres.full 2>&1
     if [ $? -ne 0 ] ; then 
        _echofull "mount failed: $MOUNT_OPTIONS"
        return 1
@@ -318,7 +382,7 @@ _create_log()
        
     # unmount the FS
     _full "umount"
-    umount $SCRATCH_DEV >>$seqres.full 2>&1
+    _scratch_unmount >>$seqres.full 2>&1
     if [ $? -ne 0 ] ; then 
        _echofull "umount failed"
        return 1
@@ -334,7 +398,7 @@ _create_log_sync()
 {
     # mount the FS
     _full " mount"
-    _scratch_mount >>$seqres.full 2>&1
+    _try_scratch_mount >>$seqres.full 2>&1
     if [ $? -ne 0 ] ; then 
        _echofull "mount failed: $MOUNT_OPTIONS"
        return 1
@@ -349,7 +413,7 @@ _create_log_sync()
 
     # unmount the FS
     _full "umount"
-    umount $SCRATCH_DEV >>$seqres.full 2>&1
+    _scratch_unmount >>$seqres.full 2>&1
     if [ $? -ne 0 ] ; then 
        _echofull "umount failed"
        return 1
@@ -454,14 +518,14 @@ _require_v2log()
 
     # test out mount to see if it mounts a v2 log fs
     export MOUNT_OPTIONS="-o logbsize=32k"
-    if ! _scratch_mount >>$seqres.full 2>&1; then
+    if ! _try_scratch_mount >>$seqres.full 2>&1; then
         _notrun "mount/kernel does not support v2 logs"
     fi
 
     # check after unmount to see if it is clean
     # i.e. it is not a 6.5.25 buggy version checking kernel
     touch $SCRATCH_MNT/file
-    umount $SCRATCH_DEV >>$seqres.full 2>&1
+    _scratch_unmount >>$seqres.full 2>&1
     if _scratch_xfs_logprint -t | tee -a $seqres.full \
         | head | grep -q "<DIRTY>"; then
         _notrun "kernel does not support v2 logs"
@@ -470,6 +534,95 @@ _require_v2log()
     # otherwise presume it does support v2 logs...:)
 }
 
+_require_logstate()
+{
+    case "$FSTYP" in
+    xfs)
+        if [ -z "$XFS_LOGPRINT_PROG" ]; then
+            _notrun "This test requires xfs_logprint utility."
+        fi
+        ;;
+    f2fs)
+        if [ -z "$DUMP_F2FS_PROG" ]; then
+            _notrun "This test requires dump.f2fs utility."
+        fi
+        ;;
+    ext4)
+       if [ -z "$DUMPE2FS_PROG" ]; then
+               _notrun "This test requires dumpe2fs utility."
+       fi
+       ;;
+    *)
+        _notrun "$FSTYP does not support log state probing."
+        ;;
+    esac
+}
+
+_xfs_log_config()
+{
+    echo "# mkfs-opt             mount-opt"
+    echo "# ------------------------------"
+    echo "  version=2            logbsize=32k"
+    echo "  version=2,su=4096    logbsize=32k"
+    echo "  version=2,su=32768   logbsize=32k"
+    echo "  version=2,su=32768   logbsize=64k"
+    echo "  version=2            logbsize=64k"
+    echo "  version=2,su=64k     logbsize=64k"
+    echo "  version=2            logbsize=128k"
+    echo "  version=2,su=128k    logbsize=128k"
+    echo "  version=2            logbsize=256k"
+    echo "  version=2,su=256k    logbsize=256k"
+}
+
+_f2fs_log_config()
+{
+    echo "# mkfs-opt             mount-opt"
+    echo "# ------------------------------"
+    echo "  test1     active_logs=6,background_gc=off"
+    echo "  test2     active_logs=6,background_gc=off,inline_data"
+    echo "  test3     active_logs=6,background_gc=off,inline_dentry"
+    echo "  test4     active_logs=6,background_gc=off,inline_data,inline_dentry"
+    echo "  test5     active_logs=6,background_gc=off,disable_roll_forward"
+    echo "  test6     active_logs=6,background_gc=off,discard,inline_data,inline_dentry"
+    echo "  test7     active_logs=6,background_gc=on"
+    echo "  test8     active_logs=6,background_gc=on,inline_data"
+    echo "  test9     active_logs=6,background_gc=on,inline_data,inline_dentry"
+    echo "  test10    active_logs=6,background_gc=on,discard,inline_data,inline_dentry"
+}
+
+_ext4_log_config()
+{
+    echo "# mkfs-opt             mount-opt"
+    echo "# ------------------------------"
+    echo "  /dev/null     data=writeback"
+    echo "  /dev/null     data=ordered"
+    echo "  /dev/null     data=journal"
+    echo "  /dev/null     data=ordered,data_err=abort"
+    echo "  /dev/null     data=writeback,nojournal_checksum"
+    echo "  /dev/null     data=ordered,nojournal_checksum"
+    echo "  /dev/null     data=journal,nojournal_checksum"
+    echo "  /dev/null     data=ordered,data_err=abort,nojournal_checksum"
+    echo "  /dev/null     data=writeback,journal_checksum"
+    echo "  /dev/null     data=ordered,journal_checksum"
+}
+
+_get_log_configs()
+{
+    case "$FSTYP" in
+    xfs)
+        _xfs_log_config
+        ;;
+    f2fs)
+        _f2fs_log_config
+        ;;
+    ext4)
+        _ext4_log_config
+        ;;
+    *)
+        _notrun "$FSTYP does not support log configs."
+        ;;
+    esac
+}
 
 # make sure this script returns success
 /bin/true