dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / rsend / send-c_embedded_blocks.ksh
blob1913c71190ab369c83b689db4c0ab7a83758ffa9
1 #!/usr/bin/ksh
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2015 by Delphix. All rights reserved.
18 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
19 . $STF_SUITE/include/properties.shlib
22 # Description:
23 # Verify that compressed streams can contain embedded blocks.
25 # Strategy:
26 # 1. Create a filesystem with compressible data and embedded blocks.
27 # 2. Verify the created streams can be received correctly.
28 # 3. Verify the presence / absence of embedded blocks in the compressed stream,
29 # as well as the receiving file system.
32 verify_runnable "both"
34 log_assert "Verify that compressed streams can contain embedded blocks."
35 log_onexit cleanup_pool $POOL2
37 typeset objs obj recsize
38 typeset sendfs=$POOL2/sendfs
39 typeset recvfs=$POOL2/recvfs
40 typeset stream=$BACKDIR/stream
41 typeset dump=$BACKDIR/dump
42 typeset recvfs2=$POOL2/recvfs2
43 typeset stream2=$BACKDIR/stream2
44 typeset dump2=$BACKDIR/dump2
45 log_must zfs create -o compress=lz4 $sendfs
46 log_must zfs create -o compress=lz4 $recvfs
47 log_must zfs create -o compress=lz4 $recvfs2
48 typeset dir=$(get_prop mountpoint $sendfs)
50 # Populate the send dataset with compressible data and embedded block files.
51 write_compressible $dir 16m
52 for recsize in "${recsize_prop_vals[@]}"; do
53 # For lz4, this method works for blocks up to 16k, but not larger
54 [[ $recsize -eq $((32 * 1024)) ]] && break
56 log_must mkholes -h 0:$((recsize - 8)) -d $((recsize - 8)):8 \
57 $dir/$recsize
58 done
60 # Generate the streams and zstreamdump output.
61 log_must zfs snapshot $sendfs@now
62 log_must eval "zfs send -c $sendfs@now >$stream"
63 log_must eval "zstreamdump -v <$stream >$dump"
64 log_must eval "zfs recv -d $recvfs <$stream"
65 cmp_ds_cont $sendfs $recvfs
66 verify_stream_size $stream $sendfs
67 log_mustnot stream_has_features $stream embed_data
69 log_must eval "zfs send -c -e $sendfs@now >$stream2"
70 log_must eval "zstreamdump -v <$stream2 >$dump2"
71 log_must eval "zfs recv -d $recvfs2 <$stream2"
72 cmp_ds_cont $sendfs $recvfs2
73 verify_stream_size $stream2 $sendfs
74 log_must stream_has_features $stream2 embed_data
76 # Verify embedded blocks are present only when expected.
77 for recsize in "${recsize_prop_vals[@]}"; do
78 [[ $recsize -eq $((32 * 1024)) ]] && break
80 typeset send_obj=$(get_objnum $(get_prop mountpoint $sendfs)/$recsize)
81 typeset recv_obj=$(get_objnum \
82 $(get_prop mountpoint $recvfs/sendfs)/$recsize)
83 typeset recv2_obj=$(get_objnum \
84 $(get_prop mountpoint $recvfs2/sendfs)/$recsize)
86 log_must eval "zdb -ddddd $sendfs $send_obj >$BACKDIR/sendfs.zdb"
87 log_must eval "zdb -ddddd $recvfs/sendfs $recv_obj >$BACKDIR/recvfs.zdb"
88 log_must eval "zdb -ddddd $recvfs2/sendfs $recv2_obj >$BACKDIR/recvfs2.zdb"
90 grep -q "EMBEDDED" $BACKDIR/sendfs.zdb || \
91 log_fail "Obj $send_obj not embedded in $sendfs"
92 grep -q "EMBEDDED" $BACKDIR/recvfs.zdb || \
93 log_fail "Obj $recv_obj not embedded in $recvfs"
94 grep -q "EMBEDDED" $BACKDIR/recvfs2.zdb || \
95 log_fail "Obj $recv2_obj not embedded in $recvfs2"
97 grep -q "WRITE_EMBEDDED object = $send_obj offset = 0" $dump && \
98 log_fail "Obj $obj embedded in zstreamdump output"
99 grep -q "WRITE_EMBEDDED object = $send_obj offset = 0" $dump2 || \
100 log_fail "Obj $obj not embedded in zstreamdump output"
101 done
103 log_pass "Compressed streams can contain embedded blocks."