From e43a97b64b837f45b01547e1f92cda9a67386be8 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Mon, 25 Apr 2022 21:49:55 +0300 Subject: [PATCH] LU-16340 quota: notify only global lqe 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 Lustre-change: https://review.whamcloud.com/c/fs/lustre-release/+/49239/ Lustre-commit: 513b1cdbca58913249eb524a37374c418fdec44f Change-Id: Idb091a10894e9db9f67d215baef2926723d6c65d Reviewed-by: Andreas Dilger Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51551 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev --- contrib/scripts/checkpatch.pl | 2 +- lustre/quota/qmt_entry.c | 8 ++++---- lustre/quota/qmt_handler.c | 5 +++-- lustre/quota/qmt_lock.c | 11 ++++++++--- lustre/quota/qmt_pool.c | 2 +- lustre/tests/replay-single.sh | 2 +- lustre/tests/sanity-quota.sh | 42 +++++++++++++++++++++++++++++++++++++++++- 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index 763c205..dfc9f9e 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -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; } diff --git a/lustre/quota/qmt_entry.c b/lustre/quota/qmt_entry.c index 7a3905f..05a593f 100644 --- a/lustre/quota/qmt_entry.c +++ b/lustre/quota/qmt_entry.c @@ -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); diff --git a/lustre/quota/qmt_handler.c b/lustre/quota/qmt_handler.c index 3446229..330f3cc 100644 --- a/lustre/quota/qmt_handler.c +++ b/lustre/quota/qmt_handler.c @@ -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; diff --git a/lustre/quota/qmt_lock.c b/lustre/quota/qmt_lock.c index 52f5d8b..4da6aa5 100644 --- a/lustre/quota/qmt_lock.c +++ b/lustre/quota/qmt_lock.c @@ -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); diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index fc525a1..ea23606 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -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); diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 9556162..73dce59 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -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 diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 88d2c19..f18e650 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -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" -- 1.8.3.1