+ $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}M -B 0 -i 0 -I 0 $DIR
+ $RUNAS $DD of=$TESTFILE 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 of=$TESTFILE conv=notrunc oflag=append count=1 || true
+ cancel_lru_locks osc
+ # now over-quota flag should be settled and further writes should fail
+ $SHOW_QUOTA_USER
+ $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 &&
+ error "grace times were reset"
+ # cleanup
+ cleanup_quota_test
+ resetquota -u $TSTUSR
+ $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
+ $MAX_IQ_TIME $DIR
+}
+run_test 30 "Hard limit updates should not reset grace times"
+
+# basic usage tracking for user & group
+test_33() {
+ local INODES=10 # 10 files
+ local BLK_CNT=2 # of 2M each
+ local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
+
+ setup_quota_test
+ trap cleanup_quota_test EXIT
+
+ # make sure the system is clean
+ local USED=$(getquota -u $TSTID global curspace)
+ [ $USED -ne 0 ] &&
+ error "Used space ($USED) for user $TSTID isn't 0."
+ USED=$(getquota -g $TSTID global curspace)
+ [ $USED -ne 0 ] &&
+ error "Used space ($USED) for group $TSTID isn't 0."
+
+ echo "Write files..."
+ for i in `seq 0 $INODES`; do
+ $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
+ error "write failed"
+ echo "Iteration $i/$INODES completed"
+ done
+ cancel_lru_locks osc
+ sync; sync_all_data || true
+
+ echo "Verify disk usage after write"
+ USED=$(getquota -u $TSTID global curspace)
+ [ $USED -lt $TOTAL_BLKS ] &&
+ error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
+ USED=$(getquota -g $TSTID global curspace)
+ [ $USED -lt $TOTAL_BLKS ] &&
+ error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
+
+ echo "Verify inode usage after write"
+ USED=$(getquota -u $TSTID global curinodes)
+ [ $USED -lt $INODES ] &&
+ error "Used inode for user $TSTID is $USED, expected $INODES"
+ USED=$(getquota -g $TSTID global curinodes)
+ [ $USED -lt $INODES ] &&
+ error "Used inode for group $TSTID is $USED, expected $INODES"
+
+ cleanup_quota_test
+
+ echo "Verify disk usage after delete"
+ USED=$(getquota -u $TSTID global curspace)
+ [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
+ USED=$(getquota -u $TSTID global curinodes)
+ [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
+ USED=$(getquota -g $TSTID global curspace)
+ [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
+ USED=$(getquota -g $TSTID global curinodes)
+ [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"