Whamcloud - gitweb
LU-16340 quota: notify only global lqe
authorSergey Cheremencev <sergey.cheremencev@hpe.com>
Mon, 25 Apr 2022 18:49:55 +0000 (21:49 +0300)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 6 Jul 2023 04:12:38 +0000 (04:12 +0000)
Don't notify slaves with new limits when set new
limits to the pools. Do this only for lqes that
belong to the global pool.

The fix helps to avoid a case when slaves do not
apply new limit because slaves` data version is
greater than the one comes from the MDT. It was
possible, if set a lot of times different limits to PQ.
After that new limits from the global pool could not
be be applied:

qsd_upd_schedule()) lustre-OST0000: discarding glb
update from glimpse ver:7 local ver:203

For details about the problem see "check indexes versions"
test in sanity-quota.sh.

Add test 25 "check indexes versions" into sanity-quota.
Without the fix it reproduces above problem.

Fix checkpatch to don't print "Invalid vsprintf pointer
extension" for %px.

HPE-bug-id: LUS-10705
Signed-off-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Lustre-change: https://review.whamcloud.com/c/fs/lustre-release/+/49239/
Lustre-commit: 513b1cdbca58913249eb524a37374c418fdec44f

Change-Id: Idb091a10894e9db9f67d215baef2926723d6c65d
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51551
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
contrib/scripts/checkpatch.pl
lustre/quota/qmt_entry.c
lustre/quota/qmt_handler.c
lustre/quota/qmt_lock.c
lustre/quota/qmt_pool.c
lustre/tests/replay-single.sh
lustre/tests/sanity-quota.sh

index 763c205..dfc9f9e 100755 (executable)
@@ -5766,7 +5766,7 @@ sub process {
                        for (my $count = $linenr; $count <= $lc; $count++) {
                                my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0));
                                $fmt =~ s/%%//g;
-                               if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNO]).)/) {
+                               if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNOx]).)/) {
                                        $bad_extension = $1;
                                        last;
                                }
index 7a3905f..05a593f 100644 (file)
@@ -115,6 +115,9 @@ static int qmt_lqe_read(const struct lu_env *env, struct lquota_entry *lqe,
 
        LASSERT(lqe_is_master(lqe));
 
+       if (qmt_pool_global(pool))
+               lqe->lqe_is_global = 1;
+
        /* read record from disk */
        rc = lquota_disk_read(env, pool->qpi_glb_obj[lqe->lqe_site->lqs_qtype],
                              &lqe->lqe_id, (struct dt_rec *)&qti->qti_glb_rec);
@@ -153,9 +156,6 @@ static int qmt_lqe_read(const struct lu_env *env, struct lquota_entry *lqe,
        else
                lqe->lqe_enforced  = true;
 
-       if (qmt_pool_global(pool))
-               lqe->lqe_is_global = 1;
-
        LQUOTA_DEBUG(lqe, "read");
        RETURN(0);
 }
@@ -951,7 +951,7 @@ int qti_lqes_add(const struct lu_env *env, struct lquota_entry *lqe)
         * extra reference that is put in qti_lqes_fini */
        qpi_getref(lqe2qpi(lqe));
 
-       CDEBUG(D_QUOTA, "LQE %p %lu is added, lqe_cnt %d lqes_num %d\n",
+       CDEBUG(D_QUOTA, "LQE %px %lu is added, lqe_cnt %d lqes_num %d\n",
                         lqe, (long unsigned)lqe->lqe_id.qid_uid,
                         qti->qti_lqes_cnt, qti->qti_lqes_num);
        LASSERT(qti->qti_lqes_num != 0);
index 3446229..330f3cc 100644 (file)
@@ -262,7 +262,7 @@ quota_write:
                                qmt_restore(lqe, &qti_lqes_rstr(env)[0]);
                                GOTO(out, rc);
                        }
-               } else {
+               } else if (lqe->lqe_is_global) {
                        ver = dt_version_get(env, LQE_GLB_OBJ(lqe));
                }
 
@@ -283,7 +283,8 @@ out_nolock:
        }
 
        if (rc == 0 && dirtied) {
-               qmt_glb_lock_notify(env, lqe, ver);
+               if (lqe->lqe_is_global)
+                       qmt_glb_lock_notify(env, lqe, ver);
                if (lqe->lqe_id.qid_uid == 0) {
                        struct qmt_entry_iter_data iter_data;
 
index 52f5d8b..4da6aa5 100644 (file)
@@ -937,8 +937,9 @@ static void qmt_id_lock_glimpse(const struct lu_env *env,
        lqe_write_unlock(lqe);
 
        /* issue glimpse callback to slaves */
-       qmt_glimpse_lock(env, qmt, res, &qti->qti_gl_desc,
-                        qmt_id_lock_cb, lqe);
+       if (lqe->lqe_glbl_data)
+               qmt_glimpse_lock(env, qmt, res, &qti->qti_gl_desc,
+                                qmt_id_lock_cb, lqe);
 
        lqe_write_lock(lqe);
        if (lqe->lqe_revoke_time == 0 &&
@@ -1021,7 +1022,11 @@ static int qmt_reba_thread(void *_args)
                        list_del_init(&lqe->lqe_link);
                        spin_unlock(&qmt->qmt_reba_lock);
 
-                       if (!kthread_should_stop())
+                       /* lqe_ref == 1 means we hold the last ref,
+                        * so no need to send glimpse callbacks.
+                        */
+                       if (!kthread_should_stop() &&
+                           atomic_read(&lqe->lqe_ref) > 1)
                                qmt_id_lock_glimpse(env, qmt, lqe, NULL);
 
                        lqe_putref(lqe);
index fc525a1..ea23606 100644 (file)
@@ -914,7 +914,7 @@ int qmt_pool_lqes_lookup_spec(const struct lu_env *env, struct qmt_device *qmt,
                        continue;
                }
                qti_lqes_add(env, lqe);
-               CDEBUG(D_QUOTA, "adding lqe %p from pool %s\n",
+               CDEBUG(D_QUOTA, "adding lqe %px from pool %s\n",
                                 lqe, pos->qpi_name);
        }
        up_read(&qmt->qmt_pool_lock);
index 9556162..73dce59 100755 (executable)
@@ -2165,7 +2165,7 @@ test_70c () {
        local elapsed
        local start_ts=$(date +%s)
 
-       trap cleanup_70c EXIT
+       stack_trap cleanup_70c EXIT
        (
                while [ ! -e $DIR/replay-single.70c.lck ]; do
                        test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
index 88d2c19..f18e650 100755 (executable)
@@ -1610,7 +1610,6 @@ test_3c() {
        pool_add_targets $qpool2 0 1 ||
                error "pool_add_targets failed"
 
-
        $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
                $MAX_IQ_TIME $DIR || error "set user grace time failed"
        $LFS setquota -t -u --block-grace $grace1 \
@@ -3127,6 +3126,47 @@ test_24() {
 }
 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
 
+test_25()
+{
+       local limit=10  # 10M
+       local testfile="$DIR/$tdir/$tfile-0"
+       local qpool="qpool1"
+
+       mds_supports_qp
+       setup_quota_test || error "setup quota failed with $?"
+
+       # enable ost quota
+       set_ost_qtype $QTYPE || error "enable ost quota failed"
+
+       $LFS setquota -u $TSTUSR -b 0 -B 50T -i 0 -I 0 $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool || error "pool_add failed"
+       pool_add_targets $qpool 0 $((OSTCOUNT - 1)) ||
+               error "pool_add_targets failed"
+
+       # increase ost index version to +200
+       for i in {1..200}; do
+               $LFS setquota -u $TSTUSR -B ${i}G --pool $qpool $DIR ||
+                       error "set user quota failed"
+       done
+       $LFS setquota -u $TSTUSR -b 0 -B 0 --pool $qpool $DIR ||
+               error "set user quota failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
+               error "set user quota failed"
+
+       local used=$(getquota -u $TSTUSR global curspace)
+       (( used == 0)) || error "Used space($used) for user $TSTUSR isn't 0."
+
+       $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
+       chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
+
+       test_1_check_write $testfile "user" $limit
+       return 0
+}
+run_test 25 "check indexes versions"
+
 test_27a() { # b19612
        $LFS quota $TSTUSR $DIR &&
                error "lfs succeeded with no type, but should have failed"