blob: 8bf591b6eb7d55f11ac1149bf25a30dc544e8476 (
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
93
94
95
96
97
98
99
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. btrfs/191
#
# Test that an incremental send operation works after deduplicating into the
# same file in both the parent and send snapshots.
#
. ./common/preamble
_begin_fstest auto quick send dedupe
# Override the default cleanup function.
_cleanup()
{
cd /
rm -fr $send_files_dir
rm -f $tmp.*
}
. ./common/filter
. ./common/reflink
_supported_fs btrfs
_require_test
_require_scratch_dedupe
_require_fssum
send_files_dir=$TEST_DIR/btrfs-test-$seq
rm -fr $send_files_dir
mkdir $send_files_dir
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
# Create our first file. The first half of the file has several 64Kb extents
# while the second half as a single 512Kb extent.
$XFS_IO_PROG -f -s -c "pwrite -S 0xb8 -b 64K 0 512K" $SCRATCH_MNT/foo \
| _filter_xfs_io
$XFS_IO_PROG -c "pwrite -S 0xb8 512K 512K" $SCRATCH_MNT/foo | _filter_xfs_io
# Create the base snapshot and the parent send stream from it.
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
$BTRFS_UTIL_PROG send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1 2>&1 \
| _filter_scratch
# Create our second file, that has exactly the same data as the first file.
$XFS_IO_PROG -f -c "pwrite -S 0xb8 0 1M" $SCRATCH_MNT/bar | _filter_xfs_io
# Create the second snapshot, used for the incremental send, before doing the
# file deduplication.
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
# Now before creating the incremental send stream:
#
# 1) Deduplicate into a subrange of file foo in snapshot mysnap1. This will drop
# several extent items and add a new one, also updating the inode's iversion
# (sequence field in inode item) by 1, but not any other field of the inode;
#
# 2) Deduplicate into a different subrange of file foo in snapshot mysnap2. This
# will replace an extent item with a new one, also updating the inode's
# iversion by 1 but not any other field of the inode.
#
# After these two deduplication operations, the inode items, for file foo, are
# identical in both snapshots, but we have different extent items for this inode
# in both snapshots. We want to check this doesn't cause send to fail with an
# error or produce an incorrect stream.
$XFS_IO_PROG -r -c "dedupe $SCRATCH_MNT/bar 0 0 512K" $SCRATCH_MNT/mysnap1/foo \
| _filter_xfs_io
$XFS_IO_PROG -r -c "dedupe $SCRATCH_MNT/bar 512K 512K 512K" \
$SCRATCH_MNT/mysnap2/foo | _filter_xfs_io
# Create the incremental send stream.
$BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
$SCRATCH_MNT/mysnap2 2>&1 | _filter_scratch
# Create the checksums to verify later that the send streams produce correct
# results.
$FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
$FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
-x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
# Now recreate the filesystem by receiving both send streams and verify we get
# the same content that the original filesystem had.
_scratch_unmount
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
$BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT
$BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT
$FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
$FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
status=0
exit
|