12fae26bdSAlan Somers#!/usr/local/bin/ksh93 -p 22fae26bdSAlan Somers# 32fae26bdSAlan Somers# CDDL HEADER START 42fae26bdSAlan Somers# 52fae26bdSAlan Somers# The contents of this file are subject to the terms of the 62fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 72fae26bdSAlan Somers# You may not use this file except in compliance with the License. 82fae26bdSAlan Somers# 92fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 112fae26bdSAlan Somers# See the License for the specific language governing permissions 122fae26bdSAlan Somers# and limitations under the License. 132fae26bdSAlan Somers# 142fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 152fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 172fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 182fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 192fae26bdSAlan Somers# 202fae26bdSAlan Somers# CDDL HEADER END 212fae26bdSAlan Somers# 222fae26bdSAlan Somers 232fae26bdSAlan Somers# 242fae26bdSAlan Somers# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 252fae26bdSAlan Somers# Use is subject to license terms. 262fae26bdSAlan Somers 272fae26bdSAlan Somers. $STF_SUITE/include/libtest.kshlib 282fae26bdSAlan Somers 292fae26bdSAlan Somers################################################################################# 302fae26bdSAlan Somers# 312fae26bdSAlan Somers# __stc_assertion_start 322fae26bdSAlan Somers# 332fae26bdSAlan Somers# ID: refquota_002_pos 342fae26bdSAlan Somers# 352fae26bdSAlan Somers# DESCRIPTION: 362fae26bdSAlan Somers# Quotas are enforced using the minimum of the two properties: 372fae26bdSAlan Somers# quota & refquota 382fae26bdSAlan Somers# 392fae26bdSAlan Somers# STRATEGY: 402fae26bdSAlan Somers# 1. Set value for quota and refquota. Quota less than refquota. 412fae26bdSAlan Somers# 2. Creating file which should be limited by quota. 422fae26bdSAlan Somers# 3. Switch the value of quota and refquota. 432fae26bdSAlan Somers# 4. Verify file should be limited by refquota. 442fae26bdSAlan Somers# 452fae26bdSAlan Somers# TESTABILITY: explicit 462fae26bdSAlan Somers# 472fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated 482fae26bdSAlan Somers# 492fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2007-11-02) 502fae26bdSAlan Somers# 512fae26bdSAlan Somers# __stc_assertion_end 522fae26bdSAlan Somers# 532fae26bdSAlan Somers################################################################################ 542fae26bdSAlan Somers 552fae26bdSAlan Somersverify_runnable "both" 562fae26bdSAlan Somers 572fae26bdSAlan Somersfunction cleanup 582fae26bdSAlan Somers{ 592fae26bdSAlan Somers log_must $ZFS destroy -rf $TESTPOOL/$TESTFS 602fae26bdSAlan Somers log_must $ZFS create $TESTPOOL/$TESTFS 612fae26bdSAlan Somers log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 622fae26bdSAlan Somers} 632fae26bdSAlan Somers 642fae26bdSAlan Somerslog_assert "Quotas are enforced using the minimum of the two properties" 652fae26bdSAlan Somerslog_onexit cleanup 662fae26bdSAlan Somers 672fae26bdSAlan Somersfs=$TESTPOOL/$TESTFS 682fae26bdSAlan Somerslog_must $ZFS set quota=15M $fs 692fae26bdSAlan Somerslog_must $ZFS set refquota=25M $fs 702fae26bdSAlan Somers 712fae26bdSAlan Somersmntpnt=$(get_prop mountpoint $fs) 722fae26bdSAlan Somerslog_mustnot $MKFILE 20M $mntpnt/$TESTFILE 732fae26bdSAlan Somerstypeset -i used quota 742fae26bdSAlan Somersused=$(get_prop used $fs) 752fae26bdSAlan Somersquota=$(get_prop quota $fs) 762fae26bdSAlan Somers((used = used / (1024 * 1024))) 772fae26bdSAlan Somers((quota = quota / (1024 * 1024))) 782fae26bdSAlan Somersif [[ $used -ne $quota ]]; then 792fae26bdSAlan Somers log_fail "ERROR: $used -ne $quota Quotas are not limited by quota" 802fae26bdSAlan Somersfi 812fae26bdSAlan Somers 822fae26bdSAlan Somers# 832fae26bdSAlan Somers# Switch the value of them and try again 842fae26bdSAlan Somers# 852fae26bdSAlan Somers[ -f $mntpnt/$TESTFILE ] && log_must $RM $mntpnt/$TESTFILE 862fae26bdSAlan Somerslog_must $ZFS set quota=25M $fs 872fae26bdSAlan Somerslog_must $ZFS set refquota=15M $fs 882fae26bdSAlan Somers 892fae26bdSAlan Somerslog_mustnot $MKFILE 20M $mntpnt/$TESTFILE 902fae26bdSAlan Somersused=$(get_prop used $fs) 912fae26bdSAlan Somersrefquota=$(get_prop refquota $fs) 922fae26bdSAlan Somers((used = used / (1024 * 1024))) 932fae26bdSAlan Somers((refquota = refquota / (1024 * 1024))) 942fae26bdSAlan Somersif [[ $used -ne $refquota ]]; then 952fae26bdSAlan Somers log_fail "ERROR: $used -ne $refquota Quotas are not limited by refquota" 962fae26bdSAlan Somersfi 972fae26bdSAlan Somers 982fae26bdSAlan Somerslog_pass "Quotas are enforced using the minimum of the two properties" 99