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 http://www.opensolaris.org/os/licensing.
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) 2016 by Lawrence Livermore National Security, LLC.
25# Use is subject to license terms.
26#
27
28. $STF_SUITE/include/libtest.shlib
29
30verify_runnable "both"
31
32TEST_SEND_FS=$TESTPOOL/send_large_dnode
33TEST_RECV_FS=$TESTPOOL/recv_large_dnode
34TEST_SNAP=$TEST_SEND_FS@ldnsnap
35TEST_SNAPINCR=$TEST_SEND_FS@ldnsnap_incr
36TEST_STREAM=$TESTDIR/ldnsnap
37TEST_STREAMINCR=$TESTDIR/ldnsnap_incr
38TEST_FILE=foo
39TEST_FILEINCR=bar
40
41function cleanup
42{
43	datasetexists $TEST_SEND_FS && destroy_dataset $TEST_SEND_FS -r
44	datasetexists $TEST_RECV_FS && destroy_dataset $TEST_RECV_FS -r
45
46	rm -f $TEST_STREAM
47	rm -f $TEST_STREAMINCR
48}
49
50log_onexit cleanup
51
52log_assert "zfs send stream with large dnodes accepted by new pool"
53
54log_must zfs create -o dnodesize=1k $TEST_SEND_FS
55log_must touch /$TEST_SEND_FS/$TEST_FILE
56log_must zfs snap $TEST_SNAP
57log_must zfs send $TEST_SNAP > $TEST_STREAM
58log_must rm -f /$TEST_SEND_FS/$TEST_FILE
59log_must touch /$TEST_SEND_FS/$TEST_FILEINCR
60log_must zfs snap $TEST_SNAPINCR
61log_must zfs send -i $TEST_SNAP $TEST_SNAPINCR > $TEST_STREAMINCR
62
63log_must eval "zfs recv $TEST_RECV_FS < $TEST_STREAM"
64inode=$(ls -li /$TEST_RECV_FS/$TEST_FILE | awk '{print $1}')
65dnsize=$(zdb -dddd $TEST_RECV_FS $inode | awk '/ZFS plain file/ {print $6}')
66if [[ "$dnsize" != "1K" ]]; then
67	log_fail "dnode size is $dnsize (expected 1K)"
68fi
69
70log_must eval "zfs recv -F $TEST_RECV_FS < $TEST_STREAMINCR"
71log_must directory_diff /$TEST_SEND_FS /$TEST_RECV_FS
72log_must zfs umount $TEST_SEND_FS
73log_must zfs umount $TEST_RECV_FS
74
75log_pass
76