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 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33 34# 35# DESCRIPTION: 36# Verify recursive snapshotting could not break ZFS. 37# 38# STRATEGY: 39# 1. Create deeply-nested filesystems until it is too long to create snap 40# 2. Verify zfs snapshot -r pool@snap will not break ZFS 41# 42 43verify_runnable "both" 44 45function cleanup 46{ 47 datasetexists $initfs && destroy_dataset $initfs -rf 48} 49 50log_assert "Verify recursive snapshotting could not break ZFS." 51log_onexit cleanup 52 53initfs=$TESTPOOL/$TESTFS/$TESTFS 54basefs=$initfs 55typeset -i ret=0 len snaplen 56while ((ret == 0)); do 57 zfs create $basefs 58 zfs snapshot $basefs@snap1 59 ret=$? 60 61 if ((ret != 0)); then 62 len=${#basefs} 63 log_note "The deeply-nested filesystem len: $len" 64 65 # 66 # Make sure there are at least 2 characters left 67 # for snapshot name space, otherwise snapshot name 68 # is incorrect 69 # 70 if ((len >= 255)); then 71 datasetexists $basefs && destroy_dataset $basefs -r 72 basefs=${basefs%/*} 73 len=${#basefs} 74 fi 75 break 76 fi 77 78 basefs=$basefs/$TESTFS 79done 80 81# Make snapshot name is longer than the max length 82((snaplen = 256 - len + 10)) 83snap=$(gen_dataset_name $snaplen "s") 84log_mustnot zfs snapshot -r $TESTPOOL@$snap 85 86log_must datasetnonexists $TESTPOOL@$snap 87while [[ $basefs != $TESTPOOL ]]; do 88 log_must datasetnonexists $basefs@$snap 89 basefs=${basefs%/*} 90done 91 92log_pass "Verify recursive snapshotting could not break ZFS." 93