From bfd24f0a697b12b0b8da8200ff650d5640bc8c38 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Thu, 22 Jul 2021 13:56:24 +0300 Subject: [PATCH] LU-15048 quota: check that qti_lqes has been inited qti_lqes_resotre_{init,fini}() should check that qti_lqes has been inited before address qti_lqes_count. Fix helps against following panic: qti_lqes_restore_fini() ASSERTION(qmt_info(env)->qti_lqes_rstr) Lustre-change: https://review.whamcloud.com/45102 Lustre-commit: d2e8208e22f21bb7354a9207f381217c222d3df3 HPE-bug-id: LUS-10239 Change-Id: Ic93d87535f615fe419b2c3a2453506c515837031 Reviewed-by: Alexander Boyko Reviewed-by: Shaun Tancheff Tested-by: Elena Gryaznova Signed-off-by: Sergey Cheremencev Reviewed-by: Shaun Tancheff Reviewed-on: https://review.whamcloud.com/46788 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Hongchao Zhang Reviewed-by: Andreas Dilger --- lustre/quota/qmt_entry.c | 5 +++-- lustre/quota/qmt_handler.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lustre/quota/qmt_entry.c b/lustre/quota/qmt_entry.c index 43aeec7..007ac78 100644 --- a/lustre/quota/qmt_entry.c +++ b/lustre/quota/qmt_entry.c @@ -956,6 +956,7 @@ void qti_lqes_fini(const struct lu_env *env) qti->qti_lqes_num * sizeof(struct lquota_entry *)); qti->qti_lqes_num = 0; + qti->qti_lqes_cnt = 0; } int qti_lqes_min_qunit(const struct lu_env *env) @@ -987,7 +988,7 @@ int qti_lqes_restore_init(const struct lu_env *env) { int rc = 0; - if (qti_lqes_cnt(env) > QMT_MAX_POOL_NUM) { + if (qti_lqes_inited(env) && qti_lqes_cnt(env) > QMT_MAX_POOL_NUM) { OBD_ALLOC(qmt_info(env)->qti_lqes_rstr, qti_lqes_cnt(env) * sizeof(struct qmt_lqe_restore)); if (!qti_lqes_rstr(env)) @@ -999,7 +1000,7 @@ int qti_lqes_restore_init(const struct lu_env *env) void qti_lqes_restore_fini(const struct lu_env *env) { - if (qti_lqes_cnt(env) > QMT_MAX_POOL_NUM) + if (qti_lqes_inited(env) && qti_lqes_cnt(env) > QMT_MAX_POOL_NUM) OBD_FREE(qmt_info(env)->qti_lqes_rstr, qti_lqes_cnt(env) * sizeof(struct qmt_lqe_restore)); } diff --git a/lustre/quota/qmt_handler.c b/lustre/quota/qmt_handler.c index f967dd4..31d3af2 100644 --- a/lustre/quota/qmt_handler.c +++ b/lustre/quota/qmt_handler.c @@ -263,9 +263,11 @@ out: lqe_write_unlock(lqe); out_nolock: - qti_lqes_restore_fini(env); - if (th != NULL && !IS_ERR(th)) - dt_trans_stop(env, qmt->qmt_child, th); + if (!is_updated) { + if (th != NULL && !IS_ERR(th)) + dt_trans_stop(env, qmt->qmt_child, th); + qti_lqes_restore_fini(env); + } if (rc == 0 && dirtied) { qmt_glb_lock_notify(env, lqe, ver); -- 1.8.3.1