blob: e15a4623bbc3a71b9aaa3eeae435a87e94310959 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017 Liu Bo. All Rights Reserved.
# Copyright (c) 2022 Christoph Hellwig.
#
# FS QA Test 267
#
# Test that btrfs buffered read repair on a raid1c3 profile can repair
# interleaving errors on all mirrors.
#
. ./common/preamble
_begin_fstest auto quick read_repair
. ./common/filter
_supported_fs btrfs
_require_scratch_dev_pool 3
# No data checksums for NOCOW case, so can't detect corruption and repair data.
_require_btrfs_no_nodatacow
_require_odirect
# Overwriting data is forbidden on a zoned block device
_require_non_zoned_device "${SCRATCH_DEV}"
_scratch_dev_pool_get 3
# step 1, create a raid1 btrfs which contains one 128k file.
echo "step 1......mkfs.btrfs"
mkfs_opts="-d raid1c3 -b 1G"
_scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
_scratch_mount
$XFS_IO_PROG -f -d -c "pwrite -S 0xaa -b 256K 0 256K" \
"$SCRATCH_MNT/foobar" | \
_filter_xfs_io_offset
# step 2, corrupt 64k in each copy
echo "step 2......corrupt file extent"
# ensure btrfs-map-logical sees the tree updates
sync
logical=$(_btrfs_get_first_logical $SCRATCH_MNT/foobar)
physical1=$(_btrfs_get_physical ${logical} 1)
devpath1=$(_btrfs_get_device_path ${logical} 1)
physical2=$(_btrfs_get_physical ${logical} 2)
devpath2=$(_btrfs_get_device_path ${logical} 2)
physical3=$(_btrfs_get_physical ${logical} 3)
devpath3=$(_btrfs_get_device_path ${logical} 3)
_scratch_unmount
$XFS_IO_PROG -d -c "pwrite -S 0xbd -b 64K $physical3 64K" \
$devpath3 > /dev/null
$XFS_IO_PROG -d -c "pwrite -S 0xba -b 64K $physical1 128K" \
$devpath1 > /dev/null
$XFS_IO_PROG -d -c "pwrite -S 0xbb -b 64K $((physical2 + 65536)) 128K" \
$devpath2 > /dev/null
$XFS_IO_PROG -d -c "pwrite -S 0xbc -b 64K $((physical3 + (2 * 65536))) 128K" \
$devpath3 > /dev/null
_scratch_mount
# step 3, 128k dio read (this read can repair bad copy)
echo "step 3......repair the bad copy"
_btrfs_direct_read_on_mirror 0 3 "$SCRATCH_MNT/foobar" 0 256K
_btrfs_direct_read_on_mirror 1 3 "$SCRATCH_MNT/foobar" 0 256K
_btrfs_direct_read_on_mirror 2 3 "$SCRATCH_MNT/foobar" 0 256K
_scratch_unmount
echo "step 4......check if the repair worked"
$XFS_IO_PROG -d -c "pread -v -b 512 $physical1 512" $devpath1 |\
_filter_xfs_io_offset
$XFS_IO_PROG -d -c "pread -v -b 512 $physical2 512" $devpath2 |\
_filter_xfs_io_offset
$XFS_IO_PROG -d -c "pread -v -b 512 $physical3 512" $devpath3 |\
_filter_xfs_io_offset
_scratch_dev_pool_put
# success, all done
status=0
exit
|