1f38cb554SJohn Wren Kennedy#!/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# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23f38cb554SJohn Wren Kennedy# Use is subject to license terms. 24f38cb554SJohn Wren Kennedy# 25f38cb554SJohn Wren Kennedy 26f38cb554SJohn Wren Kennedy# 27*1d32ba66SJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 28f38cb554SJohn Wren Kennedy# 29f38cb554SJohn Wren Kennedy 30f38cb554SJohn Wren Kennedy# 31*1d32ba66SJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 32f38cb554SJohn Wren Kennedy# 33f38cb554SJohn Wren Kennedy 34f38cb554SJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 35f38cb554SJohn Wren Kennedy. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib 36f38cb554SJohn Wren Kennedy 37f38cb554SJohn Wren Kennedy# 38f38cb554SJohn Wren Kennedy# DESCRIPTION: 39f38cb554SJohn Wren Kennedy# xattr file sizes count towards normal disk usage 40f38cb554SJohn Wren Kennedy# 41f38cb554SJohn Wren Kennedy# STRATEGY: 42f38cb554SJohn Wren Kennedy# 1. Create a file, and check pool and filesystem usage 43f38cb554SJohn Wren Kennedy# 2. Create a 200mb xattr in that file 44f38cb554SJohn Wren Kennedy# 3. Check pool and filesystem usage, to ensure it reflects the size 45f38cb554SJohn Wren Kennedy# of the xattr 46f38cb554SJohn Wren Kennedy# 47f38cb554SJohn Wren Kennedy 48f38cb554SJohn Wren Kennedyfunction cleanup { 49*1d32ba66SJohn Wren Kennedy log_must rm $TESTDIR/myfile.$$ 50f38cb554SJohn Wren Kennedy} 51f38cb554SJohn Wren Kennedy 52f38cb554SJohn Wren Kennedyfunction get_pool_size { 53f38cb554SJohn Wren Kennedy poolname=$1 54*1d32ba66SJohn Wren Kennedy psize=$(zpool list -H -o allocated $poolname) 55f38cb554SJohn Wren Kennedy if [[ $psize == *[mM] ]] 56f38cb554SJohn Wren Kennedy then 57*1d32ba66SJohn Wren Kennedy returnvalue=$(echo $psize | sed -e 's/m//g' -e 's/M//g') 58f38cb554SJohn Wren Kennedy returnvalue=$((returnvalue * 1024)) 59f38cb554SJohn Wren Kennedy else 60*1d32ba66SJohn Wren Kennedy returnvalue=$(echo $psize | sed -e 's/k//g' -e 's/K//g') 61f38cb554SJohn Wren Kennedy fi 62f38cb554SJohn Wren Kennedy echo $returnvalue 63f38cb554SJohn Wren Kennedy} 64f38cb554SJohn Wren Kennedy 65f38cb554SJohn Wren Kennedylog_assert "xattr file sizes count towards normal disk usage" 66f38cb554SJohn Wren Kennedylog_onexit cleanup 67f38cb554SJohn Wren Kennedy 68*1d32ba66SJohn Wren Kennedylog_must touch $TESTDIR/myfile.$$ 69f38cb554SJohn Wren Kennedy 70f38cb554SJohn Wren KennedyPOOL_SIZE=0 71f38cb554SJohn Wren KennedyNEW_POOL_SIZE=0 72f38cb554SJohn Wren Kennedy 73f38cb554SJohn Wren Kennedyif is_global_zone 74f38cb554SJohn Wren Kennedythen 75f38cb554SJohn Wren Kennedy # get pool and filesystem sizes. Since we're starting with an empty 76f38cb554SJohn Wren Kennedy # pool, the usage should be small - a few k. 77f38cb554SJohn Wren Kennedy POOL_SIZE=$(get_pool_size $TESTPOOL) 78f38cb554SJohn Wren Kennedyfi 79f38cb554SJohn Wren Kennedy 80*1d32ba66SJohn Wren KennedyFS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS) 81f38cb554SJohn Wren Kennedy 82*1d32ba66SJohn Wren Kennedylog_must runat $TESTDIR/myfile.$$ mkfile 200m xattr 83f38cb554SJohn Wren Kennedy 84f38cb554SJohn Wren Kennedy#Make sure the newly created file is counted into zpool usage 85*1d32ba66SJohn Wren Kennedylog_must sync 86f38cb554SJohn Wren Kennedy 87f38cb554SJohn Wren Kennedy# now check to see if our pool disk usage has increased 88f38cb554SJohn Wren Kennedyif is_global_zone 89f38cb554SJohn Wren Kennedythen 90f38cb554SJohn Wren Kennedy NEW_POOL_SIZE=$(get_pool_size $TESTPOOL) 91f38cb554SJohn Wren Kennedy (($NEW_POOL_SIZE <= $POOL_SIZE)) && \ 92f38cb554SJohn Wren Kennedy log_fail "The new pool size $NEW_POOL_SIZE was less \ 93f38cb554SJohn Wren Kennedy than or equal to the old pool size $POOL_SIZE." 94f38cb554SJohn Wren Kennedy 95f38cb554SJohn Wren Kennedyfi 96f38cb554SJohn Wren Kennedy 97f38cb554SJohn Wren Kennedy# also make sure our filesystem usage has increased 98*1d32ba66SJohn Wren KennedyNEW_FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS) 99f38cb554SJohn Wren Kennedy(($NEW_FS_SIZE <= $FS_SIZE)) && \ 100f38cb554SJohn Wren Kennedy log_fail "The new filesystem size $NEW_FS_SIZE was less \ 101f38cb554SJohn Wren Kennedy than or equal to the old filesystem size $FS_SIZE." 102f38cb554SJohn Wren Kennedy 103f38cb554SJohn Wren Kennedylog_pass "xattr file sizes count towards normal disk usage" 104