Whamcloud - gitweb
LU-15277 quota: don't print extra default quota info
authorHongchao Zhang <hongchao@whamcloud.com>
Wed, 20 Mar 2024 14:14:27 +0000 (22:14 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 8 May 2024 05:57:13 +0000 (05:57 +0000)
While getting quota info by "lfs quota", it's better to include
default quota to the quota output of the specific quota ID.

Lustre-change: https://review.whamcloud.com/45725
Lustre-commit: 0a97a8a41796caa52ef27b0cc00b11ee5889c1fe

Signed-off-by: Hongchao Zhang <hongchao@whamcloud.com>
Change-Id: I6726888b8857f9a45a96c83db0a546b29507cf8a
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55029
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/sanity-quota.sh
lustre/utils/lfs.c

index f6bef6c..a87b1ec 100755 (executable)
@@ -478,6 +478,14 @@ reset_quota_settings() {
        resetquota -g $TSTUSR2
        resetquota -g $TSTID2
        resetquota -p $TSTPRJID
+
+       $LFS setquota -U -b 0 -B 0 -i 0 -I 0 $MOUNT ||
+               error "failed to reset default user quota"
+       $LFS setquota -G -b 0 -B 0 -i 0 -I 0 $MOUNT ||
+               error "failed to reset default group quota"
+       is_project_quota_supported &&
+               $LFS setquota -P -b 0 -B 0 -i 0 -I 0 $MOUNT ||
+                       error "failed to reset default project quota"
 }
 
 get_quota_on_qsd() {
@@ -3849,6 +3857,56 @@ test_41() {
 }
 run_test 41 "df should return projid-specific values"
 
+test_lfs_quota()
+{
+       local qdtype=$1
+       local qtype=$2
+       local bsl
+       local bhl
+       local isl
+       local ihl
+
+       eval $($LFS quota $qtype 2147483647 $MOUNT |
+           awk 'NR = 2 {printf("bsl=%d;bhl=%d;isl=%d;ihl=%d;", \
+                               $3, $4, $7, $8)}')
+
+       (( $bsl != 0 || $bhl != 0 || $isl != 0 || $ihl != 0 )) &&
+               skip "qid 2147483647 is already used"
+
+       $LFS setquota $qdtype -b 100M -B 200M $MOUNT ||
+               error "fail to set default quota"
+
+       eval $($LFS quota $qtype 2147483647 $MOUNT |
+           awk 'NR = 2 {printf("bsl=%d;bhl=%d;isl=%d;ihl=%d;", \
+                               $3, $4, $7, $8)}')
+
+       [ $bsl -ne 102400 -o $bhl -ne 204800 ] &&
+               error "fail to include default block quota"
+
+       $LFS setquota $qdtype -i 10K -I 20K $MOUNT ||
+               error "fail to set default quota"
+
+       eval $($LFS quota $qtype 2147483647 $MOUNT |
+           awk 'NR = 2 {printf("bsl=%d;bhl=%d;isl=%d;ihl=%d;", \
+                               $3, $4, $7, $8)}')
+
+       [ $isl -ne 10240 -o $ihl -ne 20480 ] &&
+               error "fail to include default file quota"
+}
+
+test_42()
+{
+       setup_quota_test || error "setup quota failed with $?"
+       quota_init
+
+       test_lfs_quota "-U" "-u"
+       test_lfs_quota "-G" "-g"
+       is_project_quota_supported && test_lfs_quota "-P" "-p"
+
+       cleanup_quota_test
+}
+run_test 42 "lfs quota should include default quota info"
+
 test_delete_qid()
 {
        local qslv_file=$1
index 52e6ac8..4b4c82b 100644 (file)
@@ -8734,8 +8734,6 @@ static int get_print_quota(char *mnt, char *name, struct if_quotactl *qctl,
        char *obd_type = (char *)qctl->obd_type;
        char *obd_uuid = (char *)qctl->obd_uuid.uuid;
        __u64 total_ialloc = 0, total_balloc = 0;
-       bool use_default_for_blk = false;
-       bool use_default_for_file = false;
        int inacc;
 
        rc1 = llapi_quotactl(mnt, qctl);
@@ -8768,16 +8766,12 @@ static int get_print_quota(char *mnt, char *name, struct if_quotactl *qctl,
        }
 
        if (qctl->qc_dqblk.dqb_valid & QIF_BTIME &&
-           LQUOTA_FLAG(qctl->qc_dqblk.dqb_btime) & LQUOTA_FLAG_DEFAULT) {
-               use_default_for_blk = true;
+           LQUOTA_FLAG(qctl->qc_dqblk.dqb_btime) & LQUOTA_FLAG_DEFAULT)
                qctl->qc_dqblk.dqb_btime &= LQUOTA_GRACE_MASK;
-       }
 
        if (qctl->qc_dqblk.dqb_valid & QIF_ITIME &&
-           LQUOTA_FLAG(qctl->qc_dqblk.dqb_itime) & LQUOTA_FLAG_DEFAULT) {
-               use_default_for_file = true;
+           LQUOTA_FLAG(qctl->qc_dqblk.dqb_itime) & LQUOTA_FLAG_DEFAULT)
                qctl->qc_dqblk.dqb_itime &= LQUOTA_GRACE_MASK;
-       }
 
        if ((qctl->qc_cmd == LUSTRE_Q_GETQUOTA ||
             qctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL ||
@@ -8813,14 +8807,6 @@ static int get_print_quota(char *mnt, char *name, struct if_quotactl *qctl,
                       (uintmax_t)total_ialloc, strbuf);
        }
 
-       if (use_default_for_blk)
-               printf("%cid %u is using default block quota setting\n",
-                      *qtype_name(qctl->qc_type), qctl->qc_id);
-
-       if (use_default_for_file)
-               printf("%cid %u is using default file quota setting\n",
-                      *qtype_name(qctl->qc_type), qctl->qc_id);
-
        if (rc1 || rc2 || rc3 || inacc)
                printf("Some errors happened when getting quota info. Some devices may be not working or deactivated. The data in \"[]\" is inaccurate.\n");
 out: