]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs: test xfs_copy doesn't do cached read before libxfs_mount master v2022.07.03
authorDarrick J. Wong <djwong@kernel.org>
Thu, 30 Jun 2022 00:48:14 +0000 (17:48 -0700)
committerZorro Lang <zlang@kernel.org>
Sun, 3 Jul 2022 14:08:50 +0000 (22:08 +0800)
This is a regression test for an xfs_copy fix that ensures that it
doesn't perform a cached read of an XFS filesystem prior to initializing
libxfs, since the xfs_mount (and hence the buffer cache) isn't set up
yet.

[zlang: change the supported fs from generic to xfs]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/xfs/082 [new file with mode: 0755]
tests/xfs/082.out [new file with mode: 0644]

diff --git a/tests/xfs/082 b/tests/xfs/082
new file mode 100755 (executable)
index 0000000..cc6bfa6
--- /dev/null
@@ -0,0 +1,38 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 082
+#
+# Regression test for xfsprogs commit:
+#
+# XXXXXXXX ("xfs_copy: don't use cached buffer reads until after libxfs_mount")
+#
+# It was discovered that passing xfs_copy a source device containing an ext4
+# filesystem would cause xfs_copy to crash.  Further investigation revealed
+# that any readable path that didn't have a plausible XFS superblock in block
+# zero would produce the same crash, so this regression test exploits that.
+#
+. ./common/preamble
+_begin_fstest auto copy quick
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_require_xfs_copy
+_require_test
+
+rm -f $TEST_DIR/$seq.*
+$XFS_IO_PROG -f -c 'truncate 100m' $TEST_DIR/$seq.a
+$XFS_IO_PROG -f -c 'truncate 100m' $TEST_DIR/$seq.b
+
+filter_copy() {
+       sed -e 's/Superblock has bad magic number.*/bad magic number/'
+}
+
+$XFS_COPY_PROG $TEST_DIR/$seq.a $TEST_DIR/$seq.b 2>&1 | filter_copy
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/082.out b/tests/xfs/082.out
new file mode 100644 (file)
index 0000000..edf5936
--- /dev/null
@@ -0,0 +1,3 @@
+QA output created by 082
+bad magic number
+xfs_copy: couldn't read superblock, error=22