aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2021-11-25 14:05:29 +0800
committerEryu Guan <guaneryu@gmail.com>2021-11-29 00:35:52 +0800
commit2050356437e3576673ec5ead79ad72eb619f0d72 (patch)
tree0d943ee494a1b8735b432a0c00d9c6bfccbdc9c6
parentb310fc20be26723c4002e9aa5cb82b7d3c56c83f (diff)
downloadxfstests-dev-2050356437e3576673ec5ead79ad72eb619f0d72.tar.gz
btrfs: add regression test for compress-force mount options
Since kernel commit d4088803f511 ("btrfs: subpage: make lzo_compress_pages() compatible"), lzo compression no longer respects the max compressed page limit, and can cause kernel crash. The upstream fix is 6f019c0e0193 ("btrfs: fix a out-of-bound access in copy_compressed_data_to_page()"). This patch will add such regression test for all possible compress-force mount options, including lzo, zstd and zlib. And since we're here, also make sure the content of the file matches after a mount cycle. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-xtests/btrfs/25160
-rw-r--r--tests/btrfs/251.out7
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/btrfs/251 b/tests/btrfs/251
new file mode 100755
index 0000000000..4b6edd6cbe
--- /dev/null
+++ b/tests/btrfs/251
@@ -0,0 +1,60 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2021 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test 251
+#
+# Test if btrfs will crash when using compress-force mount option against
+# incompressible data
+#
+. ./common/preamble
+_begin_fstest auto quick compress dangerous
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_require_scratch
+
+pagesize=$(get_page_size)
+
+# Read the content from urandom to a known safe location
+$XFS_IO_PROG -f -c "pwrite -i /dev/urandom 0 $pagesize" "$tmp.good" > /dev/null
+
+# Make sure we didn't get short write
+if [ $(_get_filesize "$tmp.good") != "$pagesize" ]; then
+ _fail "Got a short read from /dev/urandom"
+fi
+
+workload()
+{
+ local compression=$1
+
+ echo "=== Testing compress-force=$compression ==="
+ _scratch_mkfs -s "$pagesize">> $seqres.full
+ _scratch_mount -o compress-force="$compression"
+ cp "$tmp.good" "$SCRATCH_MNT/$compression"
+
+ # When unpatched, compress-force=lzo would crash at data writeback
+ _scratch_cycle_mount
+
+ # Make sure the content matches
+ if [ "$(_md5_checksum $tmp.good)" != \
+ "$(_md5_checksum $SCRATCH_MNT/$compression)" ]; then
+ echo "Content of '$SCRATCH_MNT/file' mismatch with known good copy"
+ else
+ echo "OK"
+ fi
+ _scratch_unmount
+}
+
+workload lzo
+workload zstd
+workload zlib
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/251.out b/tests/btrfs/251.out
new file mode 100644
index 0000000000..c8cb98ba73
--- /dev/null
+++ b/tests/btrfs/251.out
@@ -0,0 +1,7 @@
+QA output created by 251
+=== Testing compress-force=lzo ===
+OK
+=== Testing compress-force=zstd ===
+OK
+=== Testing compress-force=zlib ===
+OK