From 0a97a8a41796caa52ef27b0cc00b11ee5889c1fe Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Wed, 20 Mar 2024 22:14:27 +0800 Subject: [PATCH] LU-15277 quota: don't print extra default quota info 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 Change-Id: I6726888b8857f9a45a96c83db0a546b29507cf8a Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/45725 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Sergey Cheremencev Reviewed-by: Andreas Dilger --- lustre/tests/sanity-quota.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++ lustre/utils/lfs.c | 18 ++------------ 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 7f2db1f..52dc8eb 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -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 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 2e24d3f..cc65076 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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); -- 1.8.3.1