2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test if btrfs will corrupt compressed data extent without data csum
8 # by replacing it with uncompressed data, when doing device replace.
10 # This could be fixed by the following kernel commit:
11 # ac0b4145d662 ("btrfs: scrub: Don't use inode pages for device replace")
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
32 # remove previous $seqres.full before test
35 # real QA test starts here
37 # Modify as appropriate.
39 _require_scratch_dev_pool 2
40 _require_scratch_dev_pool_equal_size
42 _scratch_dev_pool_get 1
44 _scratch_pool_mkfs >> $seqres.full 2>&1
46 # Create nodatasum inode
47 _scratch_mount "-o nodatasum"
48 touch $SCRATCH_MNT/nodatasum_file
49 _scratch_remount "datasum,compress"
50 _pwrite_byte 0xcd 0 128K $SCRATCH_MNT/nodatasum_file > /dev/null
52 # Write the compressed data back to disk
56 _run_btrfs_util_prog replace start -Bf 1 $SPARE_DEV $SCRATCH_MNT
58 # Unmount to drop all cache so next read will read from disk
60 _mount $SPARE_DEV $SCRATCH_MNT
62 # Now the EXTENT_DATA item still marks the extent as compressed,
63 # but the on-disk data is uncompressed, thus reading it as compressed
64 # will definitely cause EIO.
65 cat $SCRATCH_MNT/nodatasum_file > /dev/null
71 echo "Silence is golden"