Skip to content

Commit 0be3b9f

Browse files
authored
DAOS-17534 dtx: avoid repeatedly adding item into batched commit list - b26 (#16726)
DTX logic maintains batched commit list. Each opened container has each own 'dtx_batched_cont_args' (dbca) item in such list. If some container is already in such list, then do not re-add it; otherwise such list may be broken. Signed-off-by: Fan Yong <fan.yong@hpe.com>
1 parent 25cc8d7 commit 0be3b9f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/dtx/dtx_common.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ dtx_free_dbca(struct dtx_batched_cont_args *dbca)
147147
if (dbca->dbca_agg_req != NULL)
148148
sched_req_put(dbca->dbca_agg_req);
149149

150+
D_ASSERTF(d_list_empty(&dbca->dbca_sys_link), "dbca (%p) for " DF_UUID " is still linked\n",
151+
dbca, DP_UUID(dbca->dbca_cont->sc_uuid));
152+
150153
D_FREE(dbca);
151154
cont->sc_dtx_registered = 0;
152155
ds_cont_child_put(cont);
@@ -620,8 +623,6 @@ dtx_batched_commit_one(void *arg)
620623
DAOS_EPOCH_MAX, false, &dtes, NULL, &dce);
621624
if (cnt == 0) {
622625
if (dbca->dbca_flush_pending) {
623-
D_ASSERT(!dtx_cont_opened(cont));
624-
625626
dbca->dbca_flush_pending = 0;
626627
if (likely(dbca->dbca_deregister == 0))
627628
d_list_del_init(&dbca->dbca_sys_link);
@@ -712,8 +713,7 @@ dtx_batched_commit(void *arg)
712713

713714
dtx_get_dbca(dbca);
714715
cont = dbca->dbca_cont;
715-
d_list_move_tail(&dbca->dbca_sys_link,
716-
&dmi->dmi_dtx_batched_cont_open_list);
716+
d_list_move_tail(&dbca->dbca_sys_link, &dmi->dmi_dtx_batched_cont_open_list);
717717
dtx_stat(cont, &stat);
718718

719719
if (dbca->dbca_commit_req != NULL && dbca->dbca_commit_done) {
@@ -1652,7 +1652,7 @@ dtx_flush_on_close(struct dss_module_info *dmi, struct dtx_batched_cont_args *db
16521652
out:
16531653
if (rc < 0) {
16541654
D_ERROR(DF_UUID ": Fail to flush CoS cache: rc = %d\n", DP_UUID(cont->sc_uuid), rc);
1655-
if (likely(!dtx_cont_opened(cont) && dbca->dbca_deregister == 0))
1655+
if (likely(d_list_empty(&dbca->dbca_sys_link) && dbca->dbca_deregister == 0))
16561656
/* Add it to the batched commit for further handling asynchronously. */
16571657
d_list_add_tail(&dbca->dbca_sys_link, &dmi->dmi_dtx_batched_cont_open_list);
16581658
} else {
@@ -1890,12 +1890,14 @@ dtx_cont_open(struct ds_cont_child *cont)
18901890
if (rc != 0)
18911891
return rc;
18921892

1893-
dbca->dbca_flush_pending = 0;
18941893
if (unlikely(dbca->dbca_deregister == 1))
18951894
return -DER_SHUTDOWN;
18961895

1897-
d_list_add_tail(&dbca->dbca_sys_link,
1898-
&dmi->dmi_dtx_batched_cont_open_list);
1896+
if (dbca->dbca_flush_pending)
1897+
dbca->dbca_flush_pending = 0;
1898+
else
1899+
d_list_add_tail(&dbca->dbca_sys_link,
1900+
&dmi->dmi_dtx_batched_cont_open_list);
18991901
return 0;
19001902
}
19011903
}
@@ -1927,10 +1929,8 @@ dtx_cont_close(struct ds_cont_child *cont, bool force)
19271929
stop_dtx_reindex_ult(cont, force);
19281930

19291931
/* To handle potentially re-open by race. */
1930-
if (unlikely(dtx_cont_opened(cont))) {
1931-
dtx_put_dbca(dbca);
1932-
return;
1933-
}
1932+
if (unlikely(dtx_cont_opened(cont)))
1933+
goto put;
19341934

19351935
if (unlikely(dbca->dbca_deregister == 1))
19361936
goto put;

0 commit comments

Comments
 (0)