generic: test PF_MEMALLOC interfering with accounting file write
authorEric Biggers <ebiggers@google.com>
Fri, 3 Apr 2020 03:33:55 +0000 (20:33 -0700)
committerEryu Guan <guaneryu@gmail.com>
Mon, 6 Apr 2020 12:50:42 +0000 (20:50 +0800)
Add a regression test for the bug fixed by commit 10a98cb16d80 ("xfs:
clear PF_MEMALLOC before exiting xfsaild thread").

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/config
common/rc
tests/generic/596 [new file with mode: 0755]
tests/generic/596.out [new file with mode: 0644]
tests/generic/group

index 1116cb9955d3f90a8309a6d34b98d55e65da6961..8023273da1158e9f4b041244705c6ff7dc1a71d1 100644 (file)
@@ -220,6 +220,7 @@ export DUPEREMOVE_PROG="$(type -P duperemove)"
 export CC_PROG="$(type -P cc)"
 export FSVERITY_PROG="$(type -P fsverity)"
 export OPENSSL_PROG="$(type -P openssl)"
 export CC_PROG="$(type -P cc)"
 export FSVERITY_PROG="$(type -P fsverity)"
 export OPENSSL_PROG="$(type -P openssl)"
+export ACCTON_PROG="$(type -P accton)"
 
 # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
 # newer systems have udevadm command but older systems like RHEL5 don't.
 
 # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
 # newer systems have udevadm command but older systems like RHEL5 don't.
index 3265c793160c95856f668141ef67a26e49530e2d..24a8f145b8ad15c93be52294aa86fe8e6f63eb3a 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -4184,6 +4184,18 @@ _require_negative_timestamps() {
        esac
 }
 
        esac
 }
 
+# Require the 'accton' userspace tool and CONFIG_BSD_PROCESS_ACCT=y.
+_require_bsd_process_accounting()
+{
+       _require_command "$ACCTON_PROG" accton
+       $ACCTON_PROG on &> $tmp.test_accton
+       cat $tmp.test_accton >> $seqres.full
+       if grep 'Function not implemented' $tmp.test_accton; then
+               _notrun "BSD process accounting support unavailable"
+       fi
+       $ACCTON_PROG off >> $seqres.full
+}
+
 init_rc
 
 ################################################################################
 init_rc
 
 ################################################################################
diff --git a/tests/generic/596 b/tests/generic/596
new file mode 100755 (executable)
index 0000000..2ea2c5e
--- /dev/null
@@ -0,0 +1,60 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2020 Google LLC
+#
+# FS QA Test No. 596
+#
+# Regression test for the bug fixed by commit 10a98cb16d80 ("xfs: clear
+# PF_MEMALLOC before exiting xfsaild thread").  If the bug exists, a kernel
+# WARNING should be triggered.  See the commit message for details.
+#
+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()
+{
+       $ACCTON_PROG off >> $seqres.full
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_bsd_process_accounting
+_require_chattr S
+_require_test
+_require_scratch
+
+# To trigger the bug we must unmount a filesystem while BSD process accounting
+# is enabled.  The accounting file must also be located on a different
+# filesystem and have the sync flag set.
+
+accounting_file=$TEST_DIR/$seq
+
+rm -f $accounting_file
+touch $accounting_file
+$CHATTR_PROG +S $accounting_file
+
+_scratch_mkfs &>> $seqres.full
+$ACCTON_PROG $accounting_file >> $seqres.full
+_scratch_mount
+_scratch_unmount
+$ACCTON_PROG off >> $seqres.full
+
+echo "Silence is golden"
+
+status=0
+exit
diff --git a/tests/generic/596.out b/tests/generic/596.out
new file mode 100644 (file)
index 0000000..48bceb4
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 596
+Silence is golden
index ad448f39541578f91a079b75e0d245bc94ceacfc..99d06c9ad945954cca4dbf32033c600b2a27510c 100644 (file)
 593 auto quick encrypt
 594 auto quick quota
 595 auto quick encrypt
 593 auto quick encrypt
 594 auto quick quota
 595 auto quick encrypt
+596 auto quick