5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# This file and its contents are supplied under the terms of the
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Common Development and Distribution License ("CDDL"), version 1.0.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# You may only use this file in accordance with the terms of version
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# 1.0 of the CDDL.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# A full copy of the text of the CDDL should have accompanied this
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# source. A copy of the CDDL is also available via the Internet at
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Copyright (c) 2015 by Delphix. All rights reserved.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Description:
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Verify that compressed streams can contain embedded blocks.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# 1. Create a filesystem with compressible data and embedded blocks.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# 2. Verify the created streams can be received correctly.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# 3. Verify the presence / absence of embedded blocks in the compressed stream,
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# as well as the receiving file system.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmellog_assert "Verify that compressed streams can contain embedded blocks."
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Populate the send dataset with compressible data and embedded block files.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel # For lz4, this method works for blocks up to 16k, but not larger
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_must mkholes -h 0:$((recsize - 8)) -d $((recsize - 8)):8 \
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Generate the streams and zstreamdump output.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmellog_mustnot stream_has_features $stream embed_data
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmellog_must eval "zfs send -c -e $sendfs@now >$stream2"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel# Verify embedded blocks are present only when expected.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel typeset send_obj=$(get_objnum $(get_prop mountpoint $sendfs)/$recsize)
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_must eval "zdb -ddddd $sendfs $send_obj >$BACKDIR/sendfs.zdb"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_must eval "zdb -ddddd $recvfs/sendfs $recv_obj >$BACKDIR/recvfs.zdb"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_must eval "zdb -ddddd $recvfs2/sendfs $recv2_obj >$BACKDIR/recvfs2.zdb"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_fail "Obj $recv2_obj not embedded in $recvfs2"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel grep -q "WRITE_EMBEDDED object = $send_obj offset = 0" $dump && \
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_fail "Obj $obj embedded in zstreamdump output"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel grep -q "WRITE_EMBEDDED object = $send_obj offset = 0" $dump2 || \
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel log_fail "Obj $obj not embedded in zstreamdump output"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmellog_pass "Compressed streams can contain embedded blocks."