1#!/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) 2017 by Fan Yong. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib 33 34# 35# DESCRIPTION: 36# Check the basic function project{obj}used 37# 38# 39# STRATEGY: 40# 1. Write data to fs with some project then check the project{obj}used 41# 42 43function cleanup 44{ 45 cleanup_projectquota 46} 47 48if ! lsattr -pd > /dev/null 2>&1; then 49 log_unsupported "Current e2fsprogs does not support set/show project ID" 50fi 51 52log_onexit cleanup 53 54log_assert "Check the basic function of project{obj}used" 55 56sync_pool 57typeset project_used=$(get_value "projectused@$PRJID1" $QFS) 58typeset file_size='10m' 59 60if [[ $project_used != 0 ]]; then 61 log_fail "FAIL: projectused is $project_used, should be 0" 62fi 63 64mkmount_writable $QFS 65log_must user_run $PUSER mkdir $PRJDIR 66log_must chattr +P -p $PRJID1 $PRJDIR 67log_must user_run $PUSER mkfile $file_size $PRJDIR/qf 68sync_pool 69project_used=$(get_value "projectused@$PRJID1" $QFS) 70# get_value() reads the exact byte value which is slightly more than 10m 71if [[ "$(($project_used/1024/1024))m" != "$file_size" ]]; then 72 log_note "project $PRJID1 used is $project_used" 73 log_fail "projectused for project $PRJID1 expected to be $file_size, " \ 74 "not $project_used" 75fi 76 77log_must rm -rf $PRJDIR 78typeset project_obj_used=$(get_value "projectobjused@$PRJID2" $QFS) 79typeset file_count=100 80 81if [[ $project_obj_used != 0 ]]; then 82 log_fail "FAIL: projectobjused is $project_obj_used, should be 0" 83fi 84 85log_must zfs set xattr=sa $QFS 86log_must user_run $PUSER mkdir $PRJDIR 87log_must chattr +P -p $PRJID2 $PRJDIR 88# $PRJDIR has already used one object with the $PRJID2 89log_must user_run $PUSER mkfiles $PRJDIR/qf_ $((file_count - 1)) 90sync_pool 91project_obj_used=$(get_value "projectobjused@$PRJID2" $QFS) 92if [[ $project_obj_used != $file_count ]]; then 93 log_note "project $PRJID2 used is $project_obj_used" 94 log_fail "projectobjused for project $PRJID2 expected to be " \ 95 "$file_count, not $project_obj_used" 96fi 97 98log_pass "Check the basic function of project{obj}used pass as expect" 99