Skip to content

Commit

Permalink
DAOS-15045 vos: check tls before accessing
Browse files Browse the repository at this point in the history
Check vos tls in vos_pool_hhash_get(), since it maybe
called in the system xstream.

Required-githooks: true

Signed-off-by: Di Wang <di.wang@intel.com>
  • Loading branch information
Di Wang committed Jan 19, 2024
1 parent b502cb6 commit fd8ad35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/vos/vos_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,14 @@ pool_link(struct vos_pool *pool, struct d_uuid *ukey, daos_handle_t *poh)
static int
pool_lookup(struct d_uuid *ukey, struct vos_pool **pool)
{
struct d_ulink *hlink;
struct d_ulink *hlink = NULL;
bool is_sysdb = uuid_compare(ukey->uuid, *vos_db_pool_uuid()) == 0 ?
true : false;
struct d_hash_table *htable;

hlink = d_uhash_link_lookup(vos_pool_hhash_get(is_sysdb), ukey, NULL);
htable = vos_pool_hhash_get(is_sysdb);
if (htable != NULL)
hlink = d_uhash_link_lookup(htable, ukey, NULL);
if (hlink == NULL) {
D_DEBUG(DB_MGMT, "can't find "DF_UUID"\n", DP_UUID(ukey->uuid));
return -DER_NONEXIST;
Expand Down
9 changes: 8 additions & 1 deletion src/vos/vos_tls.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2023 Intel Corporation.
* (C) Copyright 2016-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -74,6 +74,13 @@ struct vos_tls *vos_tls_get(bool standalone);
static inline struct d_hash_table *
vos_pool_hhash_get(bool is_sysdb)
{
#ifndef VOS_STANDALONE
/* main thread doesn't have TLS and XS context or service thread
* is not initialized yet.
*/
if (dss_tls_get() == NULL)
return NULL;
#endif
return vos_tls_get(is_sysdb)->vtl_pool_hhash;
}

Expand Down

0 comments on commit fd8ad35

Please sign in to comment.