From e721e4442cef9d5aaaacdf4a7a301bec1c6fa247 Mon Sep 17 00:00:00 2001
From: anserper <anserper>
Date: Thu, 28 Aug 2008 11:50:24 +0000
Subject: [PATCH] Branch b1_6 b=16646 i=ZhiYong Tian(tianzy@sun.com) i=Sergey
 Glushchenko(deen@sun.com) i=Johann Lombardi(johann@sun.com)

lfs to put * when a limit is reached
---
 lustre/tests/sanity-quota.sh | 34 ++++++++++++++++++++++++++++------
 lustre/utils/lfs.c           |  8 ++++----
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh
index 9dcc8e1bf9..54aaf6b119 100644
--- a/lustre/tests/sanity-quota.sh
+++ b/lustre/tests/sanity-quota.sh
@@ -1477,12 +1477,9 @@ test_18a() {
 }
 run_test_with_stat 18a "run for fixing bug14840 ==========="
 
-test_19() {
-	# 1 Mb bunit per each MDS/OSS
-	LIMIT=$((($OSTCOUNT + 1) * 1024))
-	TESTFILE="$DIR/$tdir/$tfile"
-	mkdir -p $DIR/$tdir
-
+run_to_block_limit() {
+	local LIMIT=$((($OSTCOUNT + 1) * 1024))
+	local TESTFILE=$1
 	wait_delete_completed
 
 	# set 1 Mb quota unit size
@@ -1507,6 +1504,14 @@ test_19() {
 	cancel_lru_locks osc
 	$RUNAS dd if=/dev/zero of=$TESTFILE seek=1028 bs=$BLK_SZ count=1 && \
 		error "(usr) write success, should be EDQUOT"
+}
+
+test_19() {
+	# 1 Mb bunit per each MDS/OSS
+	local TESTFILE="$DIR/$tdir/$tfile"
+	mkdir -p $DIR/$tdir
+
+	run_to_block_limit $TESTFILE
 	$SHOW_QUOTA_USER
 
 	# cleanup
@@ -1697,6 +1702,23 @@ test_23() {
 }
 run_test_with_stat 23 "run for fixing bug16125 ==========="
 
+test_24() {
+	local TESTFILE="$DIR/$tdir/$tfile"
+	mkdir -p $DIR/$tdir
+
+	run_to_block_limit $TESTFILE
+	$SHOW_QUOTA_USER | grep '*' || error "no matching *"
+
+	# cleanup
+	rm -f $TESTFILE
+	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+
+	set_blk_unitsz $((128 * 1024))
+	set_blk_tunesz $((128 * 1024 / 2))
+        
+}
+run_test_with_stat 24 "test if lfs draws an asterix when limit is reached (16646) ==========="
+
 # turn off quota
 test_99()
 {
diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c
index 7d7944f56d..887e79324b 100644
--- a/lustre/utils/lfs.c
+++ b/lustre/utils/lfs.c
@@ -1889,10 +1889,10 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type)
                 struct obd_dqblk *dqb = &qctl->qc_dqblk;
 
                 if (dqb->dqb_bhardlimit &&
-                    toqb(dqb->dqb_curspace) > dqb->dqb_bhardlimit) {
+                    toqb(dqb->dqb_curspace) >= dqb->dqb_bhardlimit) {
                         bover = 1;
                 } else if (dqb->dqb_bsoftlimit &&
-                           toqb(dqb->dqb_curspace) > dqb->dqb_bsoftlimit) {
+                           toqb(dqb->dqb_curspace) >= dqb->dqb_bsoftlimit) {
                         if (dqb->dqb_btime > now) {
                                 bover = 2;
                         } else {
@@ -1901,10 +1901,10 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type)
                 }
 
                 if (dqb->dqb_ihardlimit &&
-                    dqb->dqb_curinodes > dqb->dqb_ihardlimit) {
+                    dqb->dqb_curinodes >= dqb->dqb_ihardlimit) {
                         iover = 1;
                 } else if (dqb->dqb_isoftlimit &&
-                           dqb->dqb_curinodes > dqb->dqb_isoftlimit) {
+                           dqb->dqb_curinodes >= dqb->dqb_isoftlimit) {
                         if (dqb->dqb_btime > now) {
                                 iover = 2;
                         } else {
-- 
GitLab