xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/large_dnode/large_dnode_005_pos.ksh (revision d3b5f56344d8bfcdd6cfb82446af0e5e55ad9ebe)
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	if datasetexists $TEST_SEND_FS ; then
44		log_must zfs destroy -r $TEST_SEND_FS
45	fi
46
47	if datasetexists $TEST_RECV_FS ; then
48		log_must zfs destroy -r $TEST_RECV_FS
49	fi
50
51	rm -f $TEST_STREAM
52	rm -f $TEST_STREAMINCR
53}
54
55log_onexit cleanup
56
57log_assert "zfs send stream with large dnodes accepted by new pool"
58
59log_must zfs create -o dnodesize=1k $TEST_SEND_FS
60log_must touch /$TEST_SEND_FS/$TEST_FILE
61log_must zfs snap $TEST_SNAP
62log_must zfs send $TEST_SNAP > $TEST_STREAM
63log_must rm -f /$TEST_SEND_FS/$TEST_FILE
64log_must touch /$TEST_SEND_FS/$TEST_FILEINCR
65log_must zfs snap $TEST_SNAPINCR
66log_must zfs send -i $TEST_SNAP $TEST_SNAPINCR > $TEST_STREAMINCR
67
68log_must eval "zfs recv $TEST_RECV_FS < $TEST_STREAM"
69inode=$(ls -li /$TEST_RECV_FS/$TEST_FILE | awk '{print $1}')
70dnsize=$(zdb -dddd $TEST_RECV_FS $inode | awk '/ZFS plain file/ {print $6}')
71if [[ "$dnsize" != "1K" ]]; then
72	log_fail "dnode size is $dnsize (expected 1K)"
73fi
74
75log_must eval "zfs recv -F $TEST_RECV_FS < $TEST_STREAMINCR"
76log_must diff -r /$TEST_SEND_FS /$TEST_RECV_FS
77log_must zfs umount $TEST_SEND_FS
78log_must zfs umount $TEST_RECV_FS
79
80log_pass
81