blob: e5dfd227ffa898746bf81e4ae7cb4d36f48320f8 (
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
100
101
102
103
104
105
106
107
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. btrfs/111
#
# Test that resending snapshots from a different filesystem is possible for
# both full and incremental send operations.
#
. ./common/preamble
_begin_fstest auto quick send
# Override the default cleanup function.
_cleanup()
{
cd /
rm -fr $send_files_dir
rm -f $tmp.*
}
. ./common/filter
_supported_fs btrfs
_require_scratch
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 a test file
$XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 32K" $SCRATCH_MNT/foo | _filter_xfs_io
# Create the first snapshot.
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
# Modify our file and create the second snapshot, used later for an incremental
# send operation.
$XFS_IO_PROG -c "pwrite -S 0xbb 4K 4K" $SCRATCH_MNT/foo | _filter_xfs_io
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap2
echo "File digests in the first filesystem:"
md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
# Save send streams for the snapshots. For the first one we use a full send
# operation and the for the second snapshot we use an incremental send.
_btrfs send -f $send_files_dir/1.snap $SCRATCH_MNT/snap1
_btrfs send -p $SCRATCH_MNT/snap1 -f $send_files_dir/2.snap \
$SCRATCH_MNT/snap2
# Create a new filesystem and receive the snapshots.
_scratch_unmount
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
_btrfs receive -vv -f $send_files_dir/1.snap $SCRATCH_MNT
_btrfs receive -vv -f $send_files_dir/2.snap $SCRATCH_MNT
echo "File digests in the second filesystem:"
# Must match the digests we got in the first filesystem.
md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
# Call sync to flush all delalloc data that the receiver processes created.
# Although 'btrfs receive' at the end calls a btrfs specific ioctl to change
# the snapshot from RW mode to RO mode, which commits the current btrfs
# transaction, the dealalloc data is not flushed, as the transaction commit
# intentionally does not do it unless the fs is mounted with '-o flushoncommit'.
# This is a detail that should probably be addressed either in the btrfs ioctls
# called by 'btrfs receive' or in the tools - our test has a different purpose,
# so we get around this by calling 'sync' to make sure all delalloc data is
# durably persisted and the respective file extent items are added to the
# snapshot's btree.
sync
# Now create send streams for the snapshots from this new filesystem. For the
# first snapshot we do a full send while for the second snapshot we do an
# incremental send.
_btrfs send -f $send_files_dir/1_2.snap $SCRATCH_MNT/snap1
_btrfs send -p $SCRATCH_MNT/snap1 -f $send_files_dir/2_2.snap \
$SCRATCH_MNT/snap2
# Create a new filesystem and receive the send streams we just created from the
# second filesystem. This worked until the linux kernel 4.2, where a regression
# was introduced. The problem was that the send stream included an incorrect
# value for the uuid field, which matched a snapshot's uuid (which is different
# on each filesystem) instead of the snapshot's received_uuid value (which is
# preserved across different filesystems).
_scratch_unmount
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
_btrfs receive -vv -f $send_files_dir/1_2.snap $SCRATCH_MNT
_btrfs receive -vv -f $send_files_dir/2_2.snap $SCRATCH_MNT
echo "File digests in the third filesystem:"
# Must match the digests we got in the first and second filesystems.
md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
status=0
exit
|