generic: test mapped write after shutdown and failed writeback
authorBrian Foster <bfoster@redhat.com>
Wed, 10 Feb 2021 17:06:28 +0000 (12:06 -0500)
committerEryu Guan <guaneryu@gmail.com>
Sun, 28 Feb 2021 14:17:26 +0000 (22:17 +0800)
XFS has a regression where it failed to check shutdown status in the
write fault path. This produced an iomap warning if the page
happened to recently fail a writeback attempt because writeback
failure can clear Uptodate status on the page.

Add a test for this scenario to help ensure mapped write failures
are handled as expected in the event of filesystem shutdown.
Upstream commit e4826691cc7e ("xfs: restore shutdown check in mapped
write fault path") fixed this bug.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/623 [new file with mode: 0755]
tests/generic/623.out [new file with mode: 0644]
tests/generic/group

diff --git a/tests/generic/623 b/tests/generic/623
new file mode 100755 (executable)
index 0000000..7be3895
--- /dev/null
@@ -0,0 +1,45 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright 2021 Red Hat, Inc.
+#
+# FS QA Test No. 623
+#
+# Test a write fault scenario on a shutdown fs.
+#
+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()
+{
+       rm -f $tmp.*
+}
+
+. ./common/rc
+. ./common/filter
+
+rm -f $seqres.full
+
+_supported_fs generic
+_require_scratch_nocheck
+_require_scratch_shutdown
+
+_scratch_mkfs &>> $seqres.full
+_scratch_mount
+
+# XFS had a regression where it failed to check shutdown status in the fault
+# path. This produced an iomap warning because writeback failure clears Uptodate
+# status on the page.
+file=$SCRATCH_MNT/file
+$XFS_IO_PROG -fc "pwrite 0 4k" -c fsync $file | _filter_xfs_io
+$XFS_IO_PROG -x -c "mmap 0 4k" -c "mwrite 0 4k" -c shutdown -c fsync \
+       -c "mwrite 0 4k" $file | _filter_xfs_io
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/623.out b/tests/generic/623.out
new file mode 100644 (file)
index 0000000..a23b6bb
--- /dev/null
@@ -0,0 +1,4 @@
+QA output created by 623
+wrote 4096/4096 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+fsync: Input/output error
index b10fdea4c31a3082e4e7487c69c1e9f8991f5ca5..8c71fada0049dcedd57a053b5e646cc1b44ac5d0 100644 (file)
 620 auto mount quick
 621 auto quick encrypt
 622 auto shutdown metadata atime
+623 auto quick shutdown