Whamcloud - gitweb
LU-15277 quota: don't print extra default quota info 25/45725/14
authorHongchao Zhang <hongchao@whamcloud.com>
Wed, 20 Mar 2024 14:14:27 +0000 (22:14 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 30 Apr 2024 06:52:35 +0000 (06:52 +0000)
While getting quota info by "lfs quota", it's better to include
default quota to the quota output of the specific quota ID.

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

index 7f2db1f..52dc8eb 100755 (executable)
@@ -494,6 +494,14 @@ reset_quota_settings() {
        [[ $(id -g $TSTUSR2) == $TSTID2 ]] || resetquota_one -g $TSTID2
        is_project_quota_supported && resetquota_one -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"
+
        sleep 1
 }
 
@@ -3958,6 +3966,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 2e24d3f..cc65076 100644 (file)
@@ -9117,8 +9117,6 @@ static int print_one_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;
 
        if (!show_default && qctl->qc_id == 0) {
@@ -9132,16 +9130,12 @@ static int print_one_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 (!show_qid && (qctl->qc_cmd == LUSTRE_Q_GETQUOTA ||
             qctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL ||
@@ -9178,14 +9172,6 @@ static int print_one_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 (!show_qid && (rc || rc1 || rc2 || inacc))
                printf("%d Some errors happened when getting quota info. Some devices may be not working or deactivated. The data in \"[]\" is inaccurate.\n", inacc);