From 8089ca3aacee5ac059cd708c99c23c3a8da9e7b9 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Wed, 13 Nov 2024 00:21:19 -0800 Subject: [PATCH] LU-17974 quota: fix qmt_pool_lqes_lookup_spec Return 0 from qmt_pool_lqes_lookup_spec if between found lqes exists global lqe. And return -ENOENT if * no lqes have been found * no global lqe between found lqes This patch aimed to prevent below panic: (qmt_lock.c:957:qmt_id_lock_notify()) ASSERTION( lqe->lqe_is_global ) failed: (qmt_lock.c:957:qmt_id_lock_notify()) LBUG ... Call Trace TBD: libcfs_call_trace+0x6f/0xa0 [libcfs] lbug_with_loc+0x3f/0x70 [libcfs] qmt_id_lock_notify+0x1ee/0x330 [lquota] qmt_site_recalc_cb+0x34b/0x550 [lquota] cfs_hash_for_each_tight+0x122/0x310 [libcfs] qmt_pool_recalc+0x375/0xa80 [lquota] kthread+0x134/0x150 ret_from_fork+0x35/0x40 Kernel panic - not syncing: LBUG Lustre-change: https://review.whamcloud.com/55535 Lustre-commit: c97b327758f06f6bf3229126e9aa7b36865e7b92 Signed-off-by: Sergey Cheremencev Change-Id: I62a2175b7b05c49f28b4e87c36ed653d1b9a71cc Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55536 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/quota/qmt_pool.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index e5cc151..6154980 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -871,11 +871,21 @@ void qmt_lqes_sort(const struct lu_env *env) } } +/* + * Find lqes with a given qid through the all pools. Add found lqes + * into qti lqes array. Call qti_lqes_fini after this function to + * cleanup qmt_thread_info despite of the retval. + * + * \retval 0 found at least one global lqe + * \retval -ENOENT no global lqe is found or no lqes at all + */ + int qmt_pool_lqes_lookup_spec(const struct lu_env *env, struct qmt_device *qmt, int rtype, int qtype, union lquota_id *qid) { - struct qmt_pool_info *pos; - struct lquota_entry *lqe; + struct qmt_pool_info *pos; + struct lquota_entry *lqe; + bool glbl_found = false; qti_lqes_init(env); down_read(&qmt->qmt_pool_lock); @@ -901,12 +911,14 @@ int qmt_pool_lqes_lookup_spec(const struct lu_env *env, struct qmt_device *qmt, lqe_putref(lqe); continue; } + if (lqe->lqe_is_global) + glbl_found = true; qti_lqes_add(env, lqe); CDEBUG(D_QUOTA, "adding lqe %p from pool %s\n", lqe, pos->qpi_name); } up_read(&qmt->qmt_pool_lock); - RETURN(qti_lqes_cnt(env) ? 0 : -ENOENT); + RETURN(qti_lqes_cnt(env) && glbl_found ? 0 : -ENOENT); } /** -- 1.8.3.1