-test_30()
-{
- local output
- local LIMIT=1024
- local TESTFILE="$DIR/$tdir/$tfile"
- local GRACE=10
-
- set_blk_tunesz 512
- set_blk_unitsz 1024
-
- mkdir -p $DIR/$tdir
- chmod 0777 $DIR/$tdir
-
- $LFS setstripe $TESTFILE -i 0 -c 1
- chown $TSTUSR.$TSTUSR $TESTFILE
-
- $LFS setquota -t -u --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR
- $LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
- $RUNAS dd if=/dev/zero of=$TESTFILE bs=1024 count=$((LIMIT * 2)) || true
- cancel_lru_locks osc
- sleep $GRACE
- $LFS setquota -u $TSTUSR -B 0 $DIR
- # over-quota flag has not yet settled since we do not trigger async events
- # based on grace time period expiration
- $SHOW_QUOTA_USER
- $RUNAS dd if=/dev/zero of=$TESTFILE conv=notrunc oflag=append bs=1048576 count=1 || true
- cancel_lru_locks osc
- # now over-quota flag should be settled and further writes should fail
- $SHOW_QUOTA_USER
- $RUNAS dd if=/dev/zero of=$TESTFILE conv=notrunc oflag=append bs=1048576 count=1 && error "grace times were reset"
- rm -f $TESTFILE
- resetquota -u $TSTUSR
- $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
-
- set_blk_unitsz $((128 * 1024))
- set_blk_tunesz $((128 * 1024 / 2))
-}
-run_test_with_stat 30 "hard limit updates should not reset grace times ================"
-
-# test duplicate quota releases b=18630
-test_31() {
- mkdir -p $DIR/$tdir
- chmod 0777 $DIR/$tdir
-
- LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
- TESTFILE="$DIR/$tdir/$tfile-0"
- TESTFILE2="$DIR/$tdir/$tfile-1"
-
- wait_delete_completed
-
- log " User quota (limit: $LIMIT kbytes)"
- $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-
- $LFS setstripe $TESTFILE -i 0 -c 1
- chown $TSTUSR.$TSTUSR $TESTFILE
- $LFS setstripe $TESTFILE2 -i 0 -c 1
- chown $TSTUSR.$TSTUSR $TESTFILE2
-
- log " step1: write out of block quota ..."
- $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=5120
- $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=5120
-
- #define OBD_FAIL_QUOTA_DELAY_SD 0xA04
- #define OBD_FAIL_SOME 0x10000000 /* fail N times */
- lustre_fail ost $((0x00000A04 | 0x10000000)) 1
-
- log " step2: delete two files so that triggering duplicate quota release ..."
- rm -f $TESTFILE $TESTFILE2
- sync; sleep 5; sync # OBD_FAIL_QUOTA_DELAY_SD will delay for 5 seconds
- wait_delete_completed
-
- log " step3: verify if the ost failed"
- do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
- watchdog=`awk '/test 31/ {start = 1;}
- /release quota error/ {
- if (start) {
- print;
- }
- }' $TMP/lustre-log-${TESTNAME}.log`
- [ "$watchdog" ] && error "$watchdog"
- rm -f $TMP/lustre-log-${TESTNAME}.log
-
- lustre_fail ost 0
- resetquota -u $TSTUSR
-}
-run_test_with_stat 31 "test duplicate quota releases ==="
-
-# check hash_cur_bits
-check_quota_hash_cur_bits() {
- local bits=$1
-
- # check quota_hash_cur_bits on all obdfilters
- for num in `seq $OSTCOUNT`; do
- cb=`do_facet ost$num "cat /sys/module/lquota/parameters/hash_lqs_cur_bits"`
- if [ $cb -gt $bits ]; then
- echo "hash_lqs_cur_bits of ost$num is too large(cur_bits=$cb)"
- return 1;
- fi
- done
- # check quota_hash_cur_bits on mds
- cb=`do_facet $SINGLEMDS "cat /sys/module/lquota/parameters/hash_lqs_cur_bits"`
- if [ $cb -gt $bits ]; then
- echo "hash_lqs_cur_bits of mds is too large(cur_bits=$cb)"
- return 1;
- fi
- return 0;
-}
-
-# check lqs hash
-check_lqs_hash() {
- # check distribution of all obdfilters
- for num in `seq $OSTCOUNT`; do
- do_facet ost$num "lctl get_param obdfilter.${FSNAME}-OST*.hash_stats | grep LQS_HASH" | while read line; do
- rehash_count=`echo $line | awk '{print $9}'`
- if [ $rehash_count -eq 0 ]; then
- echo -e "ost$num:\n $line"
- error "Rehearsh didn't happen"
- fi
- done
- done
- # check distribution of mds
- do_facet $SINGLEMDS "lctl get_param mdt.${FSNAME}-MDT*.hash_stats | grep LQS_HASH" | while read line; do
- rehash_count=`echo $line | awk '{print $9}'`
- if [ $rehash_count -eq 0 ]; then
- echo -e "mdt:\n $line"
- error "Rehearsh didn't happen"
- fi
- done
+test_39() {
+ local TESTFILE="$DIR/$tdir/project"
+ ! is_project_quota_supported &&
+ skip "Project quota is not supported" && return 0
+
+ setup_quota_test || error "setup quota failed with $?"
+
+ touch $TESTFILE
+ projectid=$(lsattr -p $TESTFILE | awk '{print $1}')
+ [ $projectid -ne 0 ] &&
+ error "Project id should be 0 not $projectid"
+ change_project -p 1024 $TESTFILE
+ projectid=$(lsattr -p $TESTFILE | awk '{print $1}')
+ [ $projectid -ne 1024 ] &&
+ error "Project id should be 1024 not $projectid"
+
+ stopall || error "failed to stopall (1)"
+ mount
+ setupall
+ projectid=$(lsattr -p $TESTFILE | awk '{print $1}')
+ [ $projectid -ne 1024 ] &&
+ error "Project id should be 1024 not $projectid"
+
+ cleanup_quota_test
+}
+run_test 39 "Project ID interface works correctly"
+
+test_40a() {
+ ! is_project_quota_supported &&
+ skip "Project quota is not supported" && return 0
+ local dir1="$DIR/$tdir/dir1"
+ local dir2="$DIR/$tdir/dir2"
+
+ setup_quota_test || error "setup quota failed with $?"
+
+ mkdir -p $dir1 $dir2
+ change_project +P $dir1 && change_project -p 1 -d $dir1 && touch $dir1/1
+ change_project +P $dir2 && change_project -p 2 -d $dir2
+
+ ln $dir1/1 $dir2/1_link &&
+ error "Hard link across different project quota should fail"
+ rm -rf $dir1 $dir2
+
+ cleanup_quota_test
+}
+run_test 40a "Hard link across different project ID"
+
+test_40b() {
+ ! is_project_quota_supported &&
+ skip "Project quota is not supported" && return 0
+ local dir1="$DIR/$tdir/dir1"
+ local dir2="$DIR/$tdir/dir2"
+
+ setup_quota_test || error "setup quota failed with $?"
+ mkdir -p $dir1 $dir2
+ change_project +P $dir1 && change_project -p 1 -d $dir1 && touch $dir1/1
+ change_project +P $dir2 && change_project -p 2 -d $dir2
+
+ mv $dir1/1 $dir2/2 || error "mv failed $?"
+ local projid=$(lsattr -p $dir2/2 | awk '{print $1}')
+ if [ "$projid" != "2" ]; then
+ error "project id expected 2 not $projid"
+ fi
+ rm -rf $dir1 $dir2
+ cleanup_quota_test
+}
+run_test 40b "Mv across different project ID"
+
+test_40c() {
+ [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
+ ! is_project_quota_supported &&
+ skip "Project quota is not supported" && return 0
+
+ setup_quota_test || error "setup quota failed with $?"
+ local dir="$DIR/$tdir/dir"
+
+ mkdir -p $dir && change_project +P $dir && change_project -dp 1 $dir
+ $LFS mkdir -i 1 $dir/remote_dir || error "create remote dir failed"
+ local projid=$(lsattr -dp $dir/remote_dir | awk '{print $1}')
+ [ "$projid" != "1" ] && error "projid id expected 1 not $projid"
+ touch $dir/remote_dir/file
+ #verify inherit works file for remote dir.
+ local projid=$(lsattr -dp $dir/remote_dir/file | awk '{print $1}')
+ [ "$projid" != "1" ] &&
+ error "file under remote dir expected 1 not $projid"
+
+ #Agent inode should be ignored for project quota
+ USED=$(getquota -p 1 global curinodes)
+ [ "$USED" != "3" ] &&
+ error "file count expected 3 got $USED"
+
+ rm -rf $dir
+ cleanup_quota_test
+ return 0