summaryrefslogtreecommitdiff
path: root/tests/btrfs/167
blob: 57c2afad784050e69d9223a905d1a90680c00b58 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test 167
#
# Test if btrfs will corrupt compressed data extent without data csum
# by replacing it with uncompressed data, when doing device replace.
#
# This could be fixed by the following kernel commit:
# ac0b4145d662 ("btrfs: scrub: Don't use inode pages for device replace")
#
. ./common/preamble
_begin_fstest auto quick replace volume remount compress

. ./common/filter

_supported_fs btrfs
_require_scratch_dev_pool 2
_require_scratch_dev_pool_equal_size

_scratch_dev_pool_get 1
_spare_dev_get
_scratch_pool_mkfs >> $seqres.full 2>&1

# Create nodatasum inode
_scratch_mount "-o nodatasum"
touch $SCRATCH_MNT/nodatasum_file
_scratch_remount "datasum,compress"
_pwrite_byte 0xcd 0 128K $SCRATCH_MNT/nodatasum_file > /dev/null

# Write the compressed data back to disk
sync

# Replace the device
_btrfs replace start -Bf 1 $SPARE_DEV $SCRATCH_MNT

# Unmount to drop all cache so next read will read from disk
_scratch_unmount
_mount $SPARE_DEV $SCRATCH_MNT

# Now the EXTENT_DATA item still marks the extent as compressed,
# but the on-disk data is uncompressed, thus reading it as compressed
# will definitely cause EIO.
cat $SCRATCH_MNT/nodatasum_file > /dev/null

_scratch_unmount
_spare_dev_put
_scratch_dev_pool_put

echo "Silence is golden"

# success, all done
status=0
exit