1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or https://opensource.org/licenses/CDDL-1.0.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2022, George Amanakis. All rights reserved.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/rsend/rsend.kshlib
29
30#
31# Description:
32# Receiving a snapshot with large blocks and raw sending it succeeds.
33#
34# Strategy:
35# 1) Create a set of files each containing some file data in an
36#	encrypted filesystem with recordsize=1m.
37# 2) Snapshot and send with large_blocks enabled to a new filesystem.
38# 3) Raw send to a file. If the large_blocks feature is not activated
39#	in the filesystem created in (2) the raw send will fail.
40#
41
42verify_runnable "both"
43
44log_assert "Receiving and raw sending a snapshot with large blocks succeeds"
45
46backup=$TEST_BASE_DIR/backup
47raw_backup=$TEST_BASE_DIR/raw_backup
48
49function cleanup
50{
51	log_must rm -f $backup $raw_backup $ibackup $unc_backup
52	destroy_pool pool_lb
53	log_must rm -f $TESTDIR/vdev_a
54}
55
56log_onexit cleanup
57
58typeset passphrase="password"
59typeset file="/pool_lb/fs/$TESTFILE0"
60
61# Create pool
62truncate -s $MINVDEVSIZE $TESTDIR/vdev_a
63log_must zpool create -f -o feature@large_blocks=enabled pool_lb $TESTDIR/vdev_a
64
65log_must eval "echo $passphrase > /pool_lb/pwd"
66
67log_must zfs create -o recordsize=1m pool_lb/fs
68log_must dd if=/dev/urandom of=$file bs=1024 count=1024
69log_must zfs snapshot pool_lb/fs@snap1
70
71log_must eval "zfs send -L pool_lb/fs@snap1 > $backup"
72log_must eval "zfs recv -o encryption=aes-256-ccm -o keyformat=passphrase \
73    -o keylocation=file:///pool_lb/pwd -o primarycache=none \
74    -o recordsize=1m pool_lb/testfs5 < $backup"
75
76log_must eval "zfs send --raw pool_lb/testfs5@snap1 > $raw_backup"
77
78log_pass "Receiving and raw sending a snapshot with large blocks succeeds"
79