1#!/bin/ksh
2
3#
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.
8#
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.
12#
13
14#
15# Copyright (c) 2021 by Delphix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
19
20#
21# Description:
22# Verify edge case when midbufid is equal to minbufid for the bug fixed by
23# https://github.com/openzfs/zfs/pull/11297 (Fix kernel panic induced by
24# redacted send)
25#
26
27typeset ds_name="panic"
28typeset sendfs="$POOL/$ds_name"
29typeset recvfs="$POOL2/$ds_name"
30typeset clone="$POOL/${ds_name}_clone"
31typeset stream=$(mktemp $TEST_BASE_DIR/stream.XXXX)
32
33function cleanup
34{
35	redacted_cleanup $sendfs $recvfs
36	rm -f $stream
37}
38
39log_onexit cleanup
40
41log_must zfs create -o recsize=8k $sendfs
42log_must dd if=/dev/urandom of=/$sendfs/file bs=1024k count=2048
43log_must zfs snapshot $sendfs@init
44log_must zfs clone $sendfs@init $clone
45log_must stride_dd -i /dev/urandom -o /$clone/file -b 8192 -s 2 -c 7226
46log_must zfs snapshot $clone@init
47log_must zfs redact $sendfs@init book_init $clone@init
48log_must eval "zfs send --redact $sendfs#book_init $sendfs@init >$stream"
49log_must eval "zfs recv $recvfs <$stream"
50log_pass
51