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