Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-16559 container: fix race of concurrent container destroy #15132

Open
wants to merge 1 commit into
base: release/2.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/common/lru.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ lru_hop_rec_decref(struct d_hash_table *htable, d_list_t *link)
D_ASSERT(llink->ll_ref > 0);
llink->ll_ref--;

/* eviction waiter is the last one holds refcount */
if (llink->ll_wait_evict &&
llink->ll_ops->lop_wakeup && daos_lru_is_last_user(llink))
/* someone is waiting for eviction of this element, no one else takes refcount
* except the hash table.
*/
if (llink->ll_wait_evict > 0 &&
llink->ll_wait_evict + 1 == llink->ll_ref &&
llink->ll_ops->lop_wakeup)
llink->ll_ops->lop_wakeup(llink);

/* Delete from hash only if no more references */
Expand Down Expand Up @@ -289,15 +292,17 @@ daos_lru_ref_evict_wait(struct daos_lru_cache *lcache, struct daos_llink *llink)
if (!llink->ll_evicted)
daos_lru_ref_evict(lcache, llink);

if (lcache->dlc_ops->lop_wait && !daos_lru_is_last_user(llink)) {
/* Wait until I'm the last one.
* XXX: the implementation can only support one waiter for now, if there
* is a secondary ULT calls this function on the same item, it will hit
* the assertion.
*/
D_ASSERT(!llink->ll_wait_evict);
llink->ll_wait_evict = 1;
/* - hash table has +1 ll_ref, myself also has +1 ll_ref (reason of 2).
* - each eviction caller has +1 ll_ref, also has +1 ll_wait_evict.
* - each active user has +1 ll_ref.
*
* if (ll_ref - ll_wait_evict) == 2, it means there is no active user on
* container, I don't need to wait anymore.
*/
if (llink->ll_ref - llink->ll_wait_evict > 2 && lcache->dlc_ops->lop_wait) {
llink->ll_wait_evict++;
lcache->dlc_ops->lop_wait(llink);
llink->ll_wait_evict = 0;
D_ASSERT(llink->ll_wait_evict > 0);
llink->ll_wait_evict--;
}
}
4 changes: 2 additions & 2 deletions src/include/daos/lru.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ struct daos_llink {
d_list_t ll_link; /**< LRU hash link */
d_list_t ll_qlink; /**< Temp link for traverse */
uint32_t ll_ref; /**< refcount for this ref */
uint32_t ll_evicted:1; /**< has been evicted */
uint32_t ll_wait_evict:1; /**< wait for completion of eviction */
uint32_t ll_wait_evict:24, /**< wait for completion of eviction */
ll_evicted:1; /**< has been evicted */
struct daos_llink_ops *ll_ops; /**< ops to maintain refs */
};

Expand Down
Loading