From: Hongchao Zhang Date: Thu, 24 Apr 2025 00:37:59 +0000 (+0800) Subject: LU-18612 quota: update usage in glimpse AST X-Git-Tag: 2.16.56~52 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=752e3660c1736ff08ab7c19ab65ae9a2a492139d;p=fs%2Flustre-release.git LU-18612 quota: update usage in glimpse AST In the quota ID glimpse AST, update the quota usage in case of the qunit has been changed on QMT. Signed-off-by: Hongchao Zhang Change-Id: I1acae2731b11d70de21b47658fcea2e987167e04 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57638 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Sergey Cheremencev Reviewed-by: Oleg Drokin --- diff --git a/lustre/quota/qsd_internal.h b/lustre/quota/qsd_internal.h index e9463e9..fc34e89 100644 --- a/lustre/quota/qsd_internal.h +++ b/lustre/quota/qsd_internal.h @@ -86,16 +86,17 @@ struct qsd_instance { * enforced here (via procfs) */ int qsd_timeout; + /* count of qunit updates during glimpse */ + int qsd_glimpse_refresh; + unsigned long qsd_is_md:1, /* managing quota for mdt */ qsd_started:1, /* instance is now started */ - qsd_prepared:1, /* qsd_prepare() successfully - * called */ + qsd_prepared:1, /* qsd_prepare() succeeded */ qsd_exp_valid:1,/* qsd_exp is now valid */ qsd_stopping:1, /* qsd_instance is stopping */ qsd_updating:1, /* qsd is updating record */ qsd_exclusive:1, /* upd exclusive with reint */ qsd_root_prj_enable:1; - }; /* diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c index 2cc7ebe..476d359 100644 --- a/lustre/quota/qsd_lib.c +++ b/lustre/quota/qsd_lib.c @@ -73,13 +73,15 @@ static int qsd_state_seq_show(struct seq_file *m, void *data) /* TODO: further pool ID should be removed or * replaced with pool Name */ seq_printf(m, "target name: %s\n" - "pool ID: %d\n" - "type: %s\n" - "quota enabled: %s\n" - "conn to master: %s\n", + "pool ID: %d\n" + "type: %s\n" + "quota enabled: %s\n" + "conn to master: %s\n" + "glimpse_refresh: %d\n", qsd->qsd_svname, 0, qsd->qsd_is_md ? "md" : "dt", enabled, - qsd->qsd_exp_valid ? "setup" : "not setup yet"); + qsd->qsd_exp_valid ? "setup" : "not setup yet", + qsd->qsd_glimpse_refresh); if (qsd->qsd_prepared) { memset(enabled, 0, sizeof(enabled)); diff --git a/lustre/quota/qsd_lock.c b/lustre/quota/qsd_lock.c index 4fbd136..ea1c54e 100644 --- a/lustre/quota/qsd_lock.c +++ b/lustre/quota/qsd_lock.c @@ -381,26 +381,11 @@ static int qsd_id_blocking_ast(struct ldlm_lock *lock, * up or eviction) */ if (!(lock->l_flags & LDLM_FL_LOCAL_ONLY)) { - /* allocate environment */ - OBD_ALLOC_PTR(env); - if (!env) { - lqe_putref(lqe); + env = lu_env_find(); + if (env) + rc = qsd_adjust(env, lqe); + else rc = -ENOMEM; - break; - } - - /* initialize environment */ - rc = lu_env_init(env, LCT_DT_THREAD); - if (rc) { - OBD_FREE_PTR(env); - lqe_putref(lqe); - break; - } - - rc = qsd_adjust(env, lqe); - - lu_env_fini(env); - OBD_FREE_PTR(env); } /* release lqe reference grabbed by qsd_id_ast_data_get() */ @@ -446,11 +431,19 @@ static int qsd_id_glimpse_ast(struct ldlm_lock *lock, void *data) lqe_write_lock(lqe); lvb->lvb_id_rel = 0; if (desc->gl_qunit != 0 && desc->gl_qunit != lqe->lqe_qunit) { + struct lu_env *env; long long space; /* extract new qunit from glimpse request */ qsd_set_qunit(lqe, desc->gl_qunit); + lqe_write_unlock(lqe); + env = lu_env_find(); + if (env) + qsd_refresh_usage(env, lqe); + lqe_write_lock(lqe); + lqe2qqi(lqe)->qqi_qsd->qsd_glimpse_refresh++; + space = lqe->lqe_granted - lqe->lqe_pending_rel; space -= lqe->lqe_usage; space -= lqe->lqe_pending_write + lqe->lqe_waiting_write;