generic: test deadlock on O_DIRECT|O_DSYNC
authorJosef Bacik <josef@toxicpanda.com>
Wed, 2 Sep 2020 17:10:36 +0000 (13:10 -0400)
committerEryu Guan <guaneryu@gmail.com>
Sun, 13 Sep 2020 15:04:12 +0000 (23:04 +0800)
We had a problem recently where btrfs would deadlock with
O_DIRECT|O_DSYNC because of an unexpected dependency on ->fsync in
iomap.  This was only caught by chance with aiostress, because weirdly
we don't actually test this particular configuration anywhere in
xfstests.  Fix this by adding a basic test that just does
O_DIRECT|O_DSYNC writes.  With this test the box deadlocks right away
with Btrfs, which would have been helpful in finding this issue before
the patches were merged.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/609 [new file with mode: 0755]
tests/generic/609.out [new file with mode: 0644]
tests/generic/group

diff --git a/tests/generic/609 b/tests/generic/609
new file mode 100755 (executable)
index 0000000..6feb7c1
--- /dev/null
@@ -0,0 +1,44 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Josef Bacik.  All Rights Reserved.
+#
+# FS QA Test 609
+#
+# iomap can call generic_write_sync() if we're O_DSYNC, so write a basic test to
+# exercise O_DSYNC so any unsuspecting file systems will get lockdep warnings if
+# their locking isn't compatible.
+#
+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.*
+       rm -rf $TEST_DIR/file
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_xfs_io_command "pwrite"
+_require_odirect
+
+$XFS_IO_PROG -f -d -s -c "pwrite 0 64k" $TEST_DIR/file | _filter_xfs_io
+
+status=0
+exit
diff --git a/tests/generic/609.out b/tests/generic/609.out
new file mode 100644 (file)
index 0000000..111c7fe
--- /dev/null
@@ -0,0 +1,3 @@
+QA output created by 609
+wrote 65536/65536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
index aa969bcbe7b9cdd7fe444b2d6f1f63de47873544..2c704266f614339ef05a02e66302633d9cf97182 100644 (file)
 606 auto attr quick dax
 607 auto attr quick dax
 608 auto attr quick dax
 606 auto attr quick dax
 607 auto attr quick dax
 608 auto attr quick dax
+609 auto quick rw