From c2e6fa41aac428222770a4fc2826567a74a6dbc6 Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Wed, 11 Sep 2024 00:14:21 +0800 Subject: [PATCH] LU-18214 ldlm: change flock deadlock detection The flock deadlock detection code thought request lock same as blocking lock is a bug. In fact, this is a case of cycling chain. So we should treat it as a deadlock case. Also clean up the reprocess code. Signed-off-by: Yang Sheng Change-Id: Icf0df4ac281c2cdb6cc57cb79db137d39ecef9e6 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56319 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Mikhail Pershin Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_flock.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index 9d15816..5eee474 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -203,14 +203,11 @@ ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock) bl_exp_conn = bl_exp->exp_connection; if (bl_exp->exp_flock_hash != NULL) { - int found; - - found = obd_nid_export_for_each(bl_exp->exp_obd, - &bl_exp_conn->c_peer.nid, - ldlm_flock_lookup_cb, - &cb_data); - if (found) - lock = cb_data.lock; + obd_nid_export_for_each(bl_exp->exp_obd, + &bl_exp_conn->c_peer.nid, + ldlm_flock_lookup_cb, + &cb_data); + lock = cb_data.lock; } if (lock == NULL) break; @@ -218,7 +215,6 @@ ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock) class_export_put(bl_exp); bl_exp = cb_data.exp; - LASSERT(req != lock); flock = &lock->l_policy_data.l_flock; LASSERT(flock->owner == bl_owner); bl_owner = flock->blocking_owner; @@ -228,12 +224,16 @@ ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock) cfs_hash_put(bl_exp->exp_flock_hash, &lock->l_exp_flock_hash); bl_exp = bl_exp_new; + if (req == lock) { + class_export_put(bl_exp); + return 1; + } if (bl_exp->exp_failed) break; if (bl_owner == req_owner && nid_same(&bl_exp_conn->c_peer.nid, - &req_exp->exp_connection->c_peer.nid)) { + &req_exp->exp_connection->c_peer.nid)) { class_export_put(bl_exp); return 1; } -- 1.8.3.1