1 #!/usr/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 2009 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 #
  29 # Copyright (c) 2013 by Delphix. All rights reserved.
  30 #
  31 
  32 . $STF_SUITE/include/libtest.shlib
  33 . $STF_SUITE/tests/functional/userquota/userquota_common.kshlib
  34 
  35 #
  36 # DESCRIPTION:
  37 #       the userquota and groupquota will not change during zfs actions, such as
  38 #       snapshot,clone,rename,upgrade,send,receive.
  39 #
  40 #
  41 # STRATEGY:
  42 #       1. Create a pool, and create fs with preset user,group quota
  43 #       2. Check set user|group quota via zfs snapshot|clone|list -o
  44 #       3. Check the user|group quota can not change during zfs rename|upgrade|promote
  45 #       4. Check the user|group quota can not change during zfs clone
  46 #       5. Check the user|group quota can not change during zfs send/receive
  47 #
  48 
  49 function cleanup
  50 {
  51         for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do
  52                 if datasetexists $ds; then
  53                         log_must $ZFS destroy -rRf $ds
  54                 fi
  55         done
  56 }
  57 
  58 log_onexit cleanup
  59 
  60 log_assert \
  61         "the userquota and groupquota can't change during zfs actions"
  62 
  63 cleanup
  64 
  65 log_must $ZFS create -o userquota@$QUSER1=$UQUOTA_SIZE \
  66         -o groupquota@$QGROUP=$GQUOTA_SIZE $TESTPOOL/fs
  67 
  68 log_must $ZFS snapshot $TESTPOOL/fs@snap
  69 log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
  70         $TESTPOOL >/dev/null 2>&1"
  71 
  72 log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs@snap "$UQUOTA_SIZE"
  73 log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs@snap "$GQUOTA_SIZE"
  74 
  75 
  76 log_note "clone fs gets its parent's userquota/groupquota initially"
  77 log_must $ZFS clone  -o userquota@$QUSER1=$UQUOTA_SIZE \
  78                 -o groupquota@$QGROUP=$GQUOTA_SIZE \
  79                 $TESTPOOL/fs@snap $TESTPOOL/fs-clone
  80 
  81 log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
  82         $TESTPOOL >/dev/null 2>&1"
  83 
  84 log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE"
  85 log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE"
  86 
  87 log_must eval "$ZFS list -o userquota@$QUSER1,groupquota@$QGROUP \
  88         $TESTPOOL/fs-clone >/dev/null 2>&1"
  89 
  90 log_note "zfs promote can not change the previously set user|group quota"
  91 log_must $ZFS promote $TESTPOOL/fs-clone
  92 
  93 log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
  94         $TESTPOOL >/dev/null 2>&1"
  95 
  96 log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE"
  97 log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE"
  98 
  99 log_note "zfs send receive can not change the previously set user|group quota"
 100 log_must $ZFS send $TESTPOOL/fs-clone@snap | $ZFS receive $TESTPOOL/fs-rev
 101 
 102 log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
 103         $TESTPOOL >/dev/null 2>&1"
 104 
 105 log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rev "$UQUOTA_SIZE"
 106 log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rev "$GQUOTA_SIZE"
 107 
 108 log_note "zfs rename can not change the previously set user|group quota"
 109 log_must $ZFS rename $TESTPOOL/fs-rev $TESTPOOL/fs-rename
 110 
 111 log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
 112         $TESTPOOL  >/dev/null 2>&1"
 113 
 114 log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rename "$UQUOTA_SIZE"
 115 log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE"
 116 
 117 log_note "zfs upgrade can not change the previously set user|group quota"
 118 log_must $ZFS upgrade $TESTPOOL/fs-rename
 119 
 120 log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
 121         $TESTPOOL >/dev/null 2>&1"
 122 
 123 log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rename "$UQUOTA_SIZE"
 124 log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE"
 125 
 126 log_pass \
 127         "the userquota and groupquota can't change during zfs actions"