blob: c2d272d10b97474db24e2fede3aa11e6990d0ac7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017 Facebook. All Rights Reserved.
#
# FS QA Test 138
#
# Test decompression in the middle of large extents. Regression test for Linux
# kernel commit 6e78b3f7a193 ("Btrfs: fix btrfs_decompress_buf2page()").
#
. ./common/preamble
_begin_fstest auto compress
. ./common/filter
_supported_fs btrfs
_require_scratch
_require_btrfs_command property
_require_btrfs_no_nodatacow
algos=($(_btrfs_compression_algos))
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
# Need 1GB for the uncompressed file plus <1GB for each compressed file.
_require_fs_space $SCRATCH_MNT $((1024 * 1024 * (1 + ${#algos[@]})))
# Checksum a piece in the middle of the file. This hits the unaligned case that
# caused the original bug.
do_csum()
{
dd if="$1" bs=4K skip=555 count=100 2>>$seqres.full| md5sum | cut -d ' ' -f 1
}
# Create a large, uncompressed (but compressible) file.
touch "${SCRATCH_MNT}/uncompressed"
$BTRFS_UTIL_PROG property set "${SCRATCH_MNT}/uncompressed" compression ""
_ddt of="${SCRATCH_MNT}/uncompressed" bs=1M count=1K 2>&1 | _filter_dd
csum="$(do_csum "${SCRATCH_MNT}/uncompressed")"
for algo in ${algos[@]}; do
echo "Testing ${algo}" >> $seqres.full
# Copy the same data, but with compression enabled.
touch "${SCRATCH_MNT}/${algo}"
$BTRFS_UTIL_PROG property set "${SCRATCH_MNT}/${algo}" compression "${algo}"
dd if="${SCRATCH_MNT}/uncompressed" of="${SCRATCH_MNT}/${algo}" bs=1M 2>&1 | _filter_dd
# The correct data is likely still cached. Cycle the mount to drop the
# cache and start fresh.
_scratch_cycle_mount
# Check the checksum.
compressed_csum="$(do_csum "${SCRATCH_MNT}/${algo}")"
if [ "${compressed_csum}" != "${csum}" ]; then
echo "Checksum mismatch for ${algo} (expected ${csum}, got ${compressed_csum})"
fi
done
echo "Silence is golden"
status=0
exit
|