1f38cb554SJohn Wren Kennedy#!/usr/bin/ksh -p 2f38cb554SJohn Wren Kennedy# 3f38cb554SJohn Wren Kennedy# CDDL HEADER START 4f38cb554SJohn Wren Kennedy# 5f38cb554SJohn Wren Kennedy# The contents of this file are subject to the terms of the 6f38cb554SJohn Wren Kennedy# Common Development and Distribution License (the "License"). 7f38cb554SJohn Wren Kennedy# You may not use this file except in compliance with the License. 8f38cb554SJohn Wren Kennedy# 9f38cb554SJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10f38cb554SJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing. 11f38cb554SJohn Wren Kennedy# See the License for the specific language governing permissions 12f38cb554SJohn Wren Kennedy# and limitations under the License. 13f38cb554SJohn Wren Kennedy# 14f38cb554SJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each 15f38cb554SJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16f38cb554SJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the 17f38cb554SJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying 18f38cb554SJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner] 19f38cb554SJohn Wren Kennedy# 20f38cb554SJohn Wren Kennedy# CDDL HEADER END 21f38cb554SJohn Wren Kennedy# 22f38cb554SJohn Wren Kennedy 23f38cb554SJohn Wren Kennedy# 24f38cb554SJohn Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25f38cb554SJohn Wren Kennedy# Use is subject to license terms. 26f38cb554SJohn Wren Kennedy# 27f38cb554SJohn Wren Kennedy 28f38cb554SJohn Wren Kennedy# 29*1d32ba66SJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 30f38cb554SJohn Wren Kennedy# 31f38cb554SJohn Wren Kennedy 32f38cb554SJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 33f38cb554SJohn Wren Kennedy. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib 34f38cb554SJohn Wren Kennedy 35f38cb554SJohn Wren Kennedy# 36f38cb554SJohn Wren Kennedy# DESCRIPTION: 37f38cb554SJohn Wren Kennedy# the userquota and groupquota will not change during zfs actions, such as 38f38cb554SJohn Wren Kennedy# snapshot,clone,rename,upgrade,send,receive. 39f38cb554SJohn Wren Kennedy# 40f38cb554SJohn Wren Kennedy# 41f38cb554SJohn Wren Kennedy# STRATEGY: 42f38cb554SJohn Wren Kennedy# 1. Create a pool, and create fs with preset user,group quota 43f38cb554SJohn Wren Kennedy# 2. Check set user|group quota via zfs snapshot|clone|list -o 44f38cb554SJohn Wren Kennedy# 3. Check the user|group quota can not change during zfs rename|upgrade|promote 45f38cb554SJohn Wren Kennedy# 4. Check the user|group quota can not change during zfs clone 46f38cb554SJohn Wren Kennedy# 5. Check the user|group quota can not change during zfs send/receive 47f38cb554SJohn Wren Kennedy# 48f38cb554SJohn Wren Kennedy 49f38cb554SJohn Wren Kennedyfunction cleanup 50f38cb554SJohn Wren Kennedy{ 51f38cb554SJohn Wren Kennedy for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do 52f38cb554SJohn Wren Kennedy if datasetexists $ds; then 53*1d32ba66SJohn Wren Kennedy log_must zfs destroy -rRf $ds 54f38cb554SJohn Wren Kennedy fi 55f38cb554SJohn Wren Kennedy done 56f38cb554SJohn Wren Kennedy} 57f38cb554SJohn Wren Kennedy 58f38cb554SJohn Wren Kennedylog_onexit cleanup 59f38cb554SJohn Wren Kennedy 60f38cb554SJohn Wren Kennedylog_assert \ 61f38cb554SJohn Wren Kennedy "the userquota and groupquota can't change during zfs actions" 62f38cb554SJohn Wren Kennedy 63f38cb554SJohn Wren Kennedycleanup 64f38cb554SJohn Wren Kennedy 65*1d32ba66SJohn Wren Kennedylog_must zfs create -o userquota@$QUSER1=$UQUOTA_SIZE \ 66f38cb554SJohn Wren Kennedy -o groupquota@$QGROUP=$GQUOTA_SIZE $TESTPOOL/fs 67f38cb554SJohn Wren Kennedy 68*1d32ba66SJohn Wren Kennedylog_must zfs snapshot $TESTPOOL/fs@snap 69*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -r -o userquota@$QUSER1,groupquota@$QGROUP \ 70f38cb554SJohn Wren Kennedy $TESTPOOL >/dev/null 2>&1" 71f38cb554SJohn Wren Kennedy 72f38cb554SJohn Wren Kennedylog_must check_quota "userquota@$QUSER1" $TESTPOOL/fs@snap "$UQUOTA_SIZE" 73f38cb554SJohn Wren Kennedylog_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs@snap "$GQUOTA_SIZE" 74f38cb554SJohn Wren Kennedy 75f38cb554SJohn Wren Kennedy 76f38cb554SJohn Wren Kennedylog_note "clone fs gets its parent's userquota/groupquota initially" 77*1d32ba66SJohn Wren Kennedylog_must zfs clone -o userquota@$QUSER1=$UQUOTA_SIZE \ 78f38cb554SJohn Wren Kennedy -o groupquota@$QGROUP=$GQUOTA_SIZE \ 79f38cb554SJohn Wren Kennedy $TESTPOOL/fs@snap $TESTPOOL/fs-clone 80f38cb554SJohn Wren Kennedy 81*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -r -o userquota@$QUSER1,groupquota@$QGROUP \ 82f38cb554SJohn Wren Kennedy $TESTPOOL >/dev/null 2>&1" 83f38cb554SJohn Wren Kennedy 84f38cb554SJohn Wren Kennedylog_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE" 85f38cb554SJohn Wren Kennedylog_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE" 86f38cb554SJohn Wren Kennedy 87*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -o userquota@$QUSER1,groupquota@$QGROUP \ 88f38cb554SJohn Wren Kennedy $TESTPOOL/fs-clone >/dev/null 2>&1" 89f38cb554SJohn Wren Kennedy 90f38cb554SJohn Wren Kennedylog_note "zfs promote can not change the previously set user|group quota" 91*1d32ba66SJohn Wren Kennedylog_must zfs promote $TESTPOOL/fs-clone 92f38cb554SJohn Wren Kennedy 93*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -r -o userquota@$QUSER1,groupquota@$QGROUP \ 94f38cb554SJohn Wren Kennedy $TESTPOOL >/dev/null 2>&1" 95f38cb554SJohn Wren Kennedy 96f38cb554SJohn Wren Kennedylog_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE" 97f38cb554SJohn Wren Kennedylog_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE" 98f38cb554SJohn Wren Kennedy 99f38cb554SJohn Wren Kennedylog_note "zfs send receive can not change the previously set user|group quota" 100*1d32ba66SJohn Wren Kennedylog_must zfs send $TESTPOOL/fs-clone@snap | zfs receive $TESTPOOL/fs-rev 101f38cb554SJohn Wren Kennedy 102*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -r -o userquota@$QUSER1,groupquota@$QGROUP \ 103f38cb554SJohn Wren Kennedy $TESTPOOL >/dev/null 2>&1" 104f38cb554SJohn Wren Kennedy 105f38cb554SJohn Wren Kennedylog_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rev "$UQUOTA_SIZE" 106f38cb554SJohn Wren Kennedylog_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rev "$GQUOTA_SIZE" 107f38cb554SJohn Wren Kennedy 108f38cb554SJohn Wren Kennedylog_note "zfs rename can not change the previously set user|group quota" 109*1d32ba66SJohn Wren Kennedylog_must zfs rename $TESTPOOL/fs-rev $TESTPOOL/fs-rename 110f38cb554SJohn Wren Kennedy 111*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -r -o userquota@$QUSER1,groupquota@$QGROUP \ 112f38cb554SJohn Wren Kennedy $TESTPOOL >/dev/null 2>&1" 113f38cb554SJohn Wren Kennedy 114f38cb554SJohn Wren Kennedylog_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rename "$UQUOTA_SIZE" 115f38cb554SJohn Wren Kennedylog_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE" 116f38cb554SJohn Wren Kennedy 117f38cb554SJohn Wren Kennedylog_note "zfs upgrade can not change the previously set user|group quota" 118*1d32ba66SJohn Wren Kennedylog_must zfs upgrade $TESTPOOL/fs-rename 119f38cb554SJohn Wren Kennedy 120*1d32ba66SJohn Wren Kennedylog_must eval "zfs list -r -o userquota@$QUSER1,groupquota@$QGROUP \ 121f38cb554SJohn Wren Kennedy $TESTPOOL >/dev/null 2>&1" 122f38cb554SJohn Wren Kennedy 123f38cb554SJohn Wren Kennedylog_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rename "$UQUOTA_SIZE" 124f38cb554SJohn Wren Kennedylog_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE" 125f38cb554SJohn Wren Kennedy 126f38cb554SJohn Wren Kennedylog_pass \ 127f38cb554SJohn Wren Kennedy "the userquota and groupquota can't change during zfs actions" 128