Whamcloud - gitweb
LU-18727 target: reference transaction early 12/58112/3
authorAlex Zhuravlev <bzzz@whamcloud.com>
Tue, 18 Feb 2025 09:14:08 +0000 (12:14 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 28 Feb 2025 08:16:13 +0000 (08:16 +0000)
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 <bzzz@whamcloud.com>
Change-Id: I12546b1bce3b3f0fe3c74a99bb589bee39768754
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58112
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
lustre/target/update_trans.c

index 449be98..2aa234f 100644 (file)
@@ -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);