Whamcloud - gitweb
LU-15694 quota: keep grace time while setting default limits 35/46935/11
authorHongchao Zhang <hongchao@whamcloud.com>
Thu, 28 Jul 2022 13:54:00 +0000 (21:54 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 1 Sep 2022 05:53:54 +0000 (05:53 +0000)
The quota grace time should only be changed by "lfs setquota -t",
and it should be kept while setting default quota limits.

This patch also fixes an issue of not saving the grace time while
writing glboal quota record.

Signed-off-by: Hongchao Zhag <hongchao@whamcloud.com>
Change-Id: I89ca49d09dc41deffe4bc77e53721b5bb4f4be37
Reviewed-on: https://review.whamcloud.com/46935
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/quota/qmt_entry.c
lustre/quota/qmt_handler.c
lustre/tests/sanity-quota.sh
lustre/utils/lfs.c

index a37bf48..92d83b6 100644 (file)
@@ -354,7 +354,8 @@ int qmt_glb_write(const struct lu_env *env, struct thandle *th,
        if (lqe->lqe_is_default) {
                rec->qbr_hardlimit = 0;
                rec->qbr_softlimit = 0;
        if (lqe->lqe_is_default) {
                rec->qbr_hardlimit = 0;
                rec->qbr_softlimit = 0;
-               rec->qbr_time      = LQUOTA_GRACE_FLAG(0, LQUOTA_FLAG_DEFAULT);
+               rec->qbr_time      = LQUOTA_GRACE_FLAG(lqe->lqe_gracetime,
+                                                      LQUOTA_FLAG_DEFAULT);
        } else {
                rec->qbr_hardlimit = lqe->lqe_hardlimit;
                rec->qbr_softlimit = lqe->lqe_softlimit;
        } else {
                rec->qbr_hardlimit = lqe->lqe_hardlimit;
                rec->qbr_softlimit = lqe->lqe_softlimit;
index d2789ce..6ef8377 100644 (file)
@@ -205,6 +205,10 @@ int qmt_set_with_lqe(const struct lu_env *env, struct qmt_device *qmt,
                /* change quota limits */
                lqe->lqe_hardlimit = hard;
                lqe->lqe_softlimit = soft;
                /* change quota limits */
                lqe->lqe_hardlimit = hard;
                lqe->lqe_softlimit = soft;
+               if (is_default) {
+                       dirtied = true;
+                       GOTO(quota_write, 0);
+               }
 
 quota_set:
                /* recompute qunit in case it was never initialized */
 
 quota_set:
                /* recompute qunit in case it was never initialized */
@@ -248,6 +252,7 @@ quota_set:
                dirtied = true;
        }
 
                dirtied = true;
        }
 
+quota_write:
        if (dirtied) {
                if (!is_updated) {
                        /* write new quota settings to disk */
        if (dirtied) {
                if (!is_updated) {
                        /* write new quota settings to disk */
index 3d8c5aa..f55c009 100755 (executable)
@@ -5557,6 +5557,50 @@ test_82()
 }
 run_test 82 "verify more than 8 qids for single operation"
 
 }
 run_test 82 "verify more than 8 qids for single operation"
 
+test_grace_with_default_quota()
+{
+       local qtype=$1
+       local qdtype=$2
+       local bgrace
+       local igrace
+       local bgrace2
+       local igrace2
+       echo "ttt1"
+       $LFS setquota $qdtype -b 0 -B 0 -i 0 -I 0 $DIR ||
+               error "clear default quota [$qdtype] failed"
+       echo "ttt2"
+       $LFS setquota -t $qtype --block-grace 1w --inode-grace 1w $DIR ||
+               error "reset quota [$qdtype] grace failed"
+       echo "ttt3"
+
+       eval $($LFS quota -t $qtype $DIR | awk -F "[; ]" \
+                       '{printf("bgrace=%s;igrace=%s;", $4, $9)}')
+       echo "ttt4"
+
+       $LFS setquota $qdtype -B 10G -i 10k $DIR
+       echo "ttt5"
+
+       eval $($LFS quota -t $qtype $DIR | awk -F "[; ]" \
+                       '{printf("bgrace2=%s;igrace2=%s;", $4, $9)}')
+
+       [ "$bgrace" == "$bgrace2" ] ||
+                       error "set default quota shouldn't affect block grace"
+       [ "$igrace" == "$igrace2" ] ||
+                       error "set default quota shouldn't affect inode grace"
+
+}
+
+test_83()
+{
+       setup_quota_test || error "setup quota failed with $?"
+       test_grace_with_default_quota "-u" "-U"
+       test_grace_with_default_quota "-g" "-G"
+
+       is_project_quota_supported || return 0
+       test_grace_with_default_quota "-p" "-P"
+}
+run_test 83 "Setting default quota shouldn't affect grace time"
+
 quota_fini()
 {
        do_nodes $(comma_list $(nodes_list)) \
 quota_fini()
 {
        do_nodes $(comma_list $(nodes_list)) \
index 111e4af..e80814d 100644 (file)
@@ -8121,6 +8121,9 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type,
                char timebuf[40];
                char strbuf[STRBUF_LEN];
 
                char timebuf[40];
                char strbuf[STRBUF_LEN];
 
+               dqb->dqb_btime &= LQUOTA_GRACE_MASK;
+               dqb->dqb_itime &= LQUOTA_GRACE_MASK;
+
                if (dqb->dqb_bhardlimit &&
                    lustre_stoqb(dqb->dqb_curspace) >= dqb->dqb_bhardlimit) {
                        bover = 1;
                if (dqb->dqb_bhardlimit &&
                    lustre_stoqb(dqb->dqb_curspace) >= dqb->dqb_bhardlimit) {
                        bover = 1;
@@ -8146,11 +8149,11 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type,
                else
                        printf("%15s", mnt);
 
                else
                        printf("%15s", mnt);
 
-               if (bover)
-                       diff2str(dqb->dqb_btime, timebuf, now);
-               else if (show_default)
+               if (show_default)
                        snprintf(timebuf, sizeof(timebuf), "%llu",
                                 (unsigned long long)dqb->dqb_btime);
                        snprintf(timebuf, sizeof(timebuf), "%llu",
                                 (unsigned long long)dqb->dqb_btime);
+               else if (bover)
+                       diff2str(dqb->dqb_btime, timebuf, now);
 
                kbytes2str(lustre_stoqb(dqb->dqb_curspace),
                           strbuf, sizeof(strbuf), h);
 
                kbytes2str(lustre_stoqb(dqb->dqb_curspace),
                           strbuf, sizeof(strbuf), h);
@@ -8178,11 +8181,11 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type,
                               numbuf[0], bover ? '*' : ' ', numbuf[1],
                               numbuf[2], bover > 1 ? timebuf : "-");
 
                               numbuf[0], bover ? '*' : ' ', numbuf[1],
                               numbuf[2], bover > 1 ? timebuf : "-");
 
-               if (iover)
-                       diff2str(dqb->dqb_itime, timebuf, now);
-               else if (show_default)
+               if (show_default)
                        snprintf(timebuf, sizeof(timebuf), "%llu",
                                 (unsigned long long)dqb->dqb_itime);
                        snprintf(timebuf, sizeof(timebuf), "%llu",
                                 (unsigned long long)dqb->dqb_itime);
+               else if (iover)
+                       diff2str(dqb->dqb_itime, timebuf, now);
 
                snprintf(numbuf[0], sizeof(numbuf),
                         (dqb->dqb_valid & QIF_INODES) ? "%ju" : "[%ju]",
 
                snprintf(numbuf[0], sizeof(numbuf),
                         (dqb->dqb_valid & QIF_INODES) ? "%ju" : "[%ju]",