blob: 45872b85aad075528e6b2b2eb1c891b367f7210d (
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. 203
#
# Test that an incremental send operation works correctly when a file has shared
# extents with itself in the send snapshot, with a hole between them, and the
# file size has increased in the send snapshot.
#
. ./common/preamble
_begin_fstest auto quick send clone
# Override the default cleanup function.
_cleanup()
{
cd /
rm -f $tmp.*
rm -fr $send_files_dir
}
. ./common/filter
. ./common/reflink
_supported_fs btrfs
_require_test
_require_scratch_reflink
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 test file with a size of 64K in the parent snapshot.
# After the parent snapshot is created, we will increase its size and then clone
# one of its extents into a different offset and leave a hole between the shared
# extents. The shared extents will be located at offsets greater then size of the
# file in the parent snapshot.
$XFS_IO_PROG -f -c "pwrite -S 0xf1 0 64K" $SCRATCH_MNT/foobar | _filter_xfs_io
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base
$BTRFS_UTIL_PROG send -f $send_files_dir/1.snap $SCRATCH_MNT/base 2>&1 \
| _filter_scratch
# Create a 320K extent at file offset 512K, with chunks of 64K having different
# content (to check cloning operations from send refer to the correct ranges).
# After that clone a range that includes a hole and a part of the extent created
# before - the clone range starts at an offset (448K) lower then the extent's
# offset (512K). We want to see the existence of the hole doesn't confuse the
# kernel's send code to send an invalid clone operation (with a source range
# going beyond the file's current size). The hole that confused send to issue
# an invalid clone operation spans the file range from offset 384K to 512K.
#
# Use offsets and ranges that are aligned to 64K, so that the test can run on
# machines with any page size (and therefore block size).
#
$XFS_IO_PROG -c "pwrite -S 0xab 512K 64K" \
-c "pwrite -S 0xcd 576K 64K" \
-c "pwrite -S 0xef 640K 64K" \
-c "pwrite -S 0x64 704K 64K" \
-c "pwrite -S 0x73 768K 64K" \
-c "reflink $SCRATCH_MNT/foobar 448K 192K 192K" \
$SCRATCH_MNT/foobar | _filter_xfs_io
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr 2>&1
$BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base -f $send_files_dir/2.snap \
$SCRATCH_MNT/incr 2>&1 | _filter_scratch
echo "File foobar digest in the original filesystem:"
_md5_checksum $SCRATCH_MNT/incr/foobar
# Now recreate the filesystem by receiving both send streams and verify we get
# the same file contents 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
echo "File foobar digest in the new filesystem:"
_md5_checksum $SCRATCH_MNT/incr/foobar
status=0
exit
|