Whamcloud - gitweb
LU-16340 quota: notify only global lqe 39/49239/12
authorSergey Cheremencev <sergey.cheremencev@hpe.com>
Mon, 25 Apr 2022 18:49:55 +0000 (21:49 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 May 2023 07:04:34 +0000 (07:04 +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
Change-Id: Idb091a10894e9db9f67d215baef2926723d6c65d
Signed-off-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-on: https://es-gerrit.dev.cray.com/160536
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Alexander Boyko <c17825@cray.com>
Tested-by: Elena Gryaznova <elena.gryaznova@hpe.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49239
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Oleg Drokin <green@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 b9132d1..b9d5a34 100755 (executable)
@@ -5784,7 +5784,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 a8f0672..b17b19a 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);
 }
@@ -971,7 +971,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 8eb2824..ba4edf4 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 c551aa8..9d2e01a 100644 (file)
@@ -915,8 +915,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 &&
@@ -999,7 +1000,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 decd399..bd00257 100644 (file)
@@ -902,7 +902,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 58e8899..34df60f 100755 (executable)
@@ -2150,7 +2150,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 e3c2386..65465a7 100755 (executable)
@@ -1708,7 +1708,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 \
@@ -3219,6 +3218,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"