From: Alex Zhuravlev Date: Tue, 18 Feb 2025 09:14:08 +0000 (+0300) Subject: LU-18727 target: reference transaction early X-Git-Tag: 2.16.53~81 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=72792d8dbfd4d7f3227d94514e0fd96399535d20;p=fs%2Flustre-release.git LU-18727 target: reference transaction early grab a reference to distrubuted transaction handle before putting on the list, otherwize the concurrent commit thread can find it and release, thus the original thread will be accessing just freed structure. Test-Parameters: testlist=replay-single,replay-dual Test-Parameters: testlist=replay-single,replay-dual Test-Parameters: testlist=replay-single,replay-dual Signed-off-by: Alex Zhuravlev Change-Id: I12546b1bce3b3f0fe3c74a99bb589bee39768754 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58112 Reviewed-by: Mikhail Pershin Reviewed-by: Oleg Drokin Reviewed-by: Lai Siyao Tested-by: Maloo Tested-by: jenkins --- diff --git a/lustre/target/update_trans.c b/lustre/target/update_trans.c index 449be98..2aa234f 100644 --- a/lustre/target/update_trans.c +++ b/lustre/target/update_trans.c @@ -670,6 +670,9 @@ void distribute_txn_insert_by_batchid(struct top_multiple_thandle *new) LASSERT(dt != NULL); tdtd = dt2lu_dev(dt)->ld_site->ls_tgt->lut_tdtd; + /* have a reference so the competing commit thread can't release it*/ + top_multiple_thandle_get(new); + spin_lock(&tdtd->tdtd_batchid_lock); list_for_each_entry_reverse(tmt, &tdtd->tdtd_list, tmt_commit_list) { if (new->tmt_batchid > tmt->tmt_batchid) { @@ -688,7 +691,6 @@ void distribute_txn_insert_by_batchid(struct top_multiple_thandle *new) sub_thandle_register_commit_cb(st, new); } - top_multiple_thandle_get(new); top_multiple_thandle_dump(new, D_INFO); if (new->tmt_committed && at_head && tdtd->tdtd_commit_task) wake_up_process(tdtd->tdtd_commit_task);