Skip to content

Commit

Permalink
DAOS-15045 vos: vos_pool_kill should not be done in main thread
Browse files Browse the repository at this point in the history
vos_pool_kill should be executed in system xstream.

Required-githooks: true

Signed-off-by: Di Wang <di.wang@intel.com>
  • Loading branch information
Di Wang committed Jan 22, 2024
1 parent 8b5ffa6 commit 0596828
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/mgmt/srv_target.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2016-2022 Intel Corporation.
* (C) Copyright 2016-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -171,12 +171,17 @@ struct tgt_destroy_args {
int tda_rc;
};

struct tgt_kill_arg {
uuid_t pool_uuid;
unsigned int flags;
};

static inline int
tgt_kill_pool(void *args)
tgt_kill_pool(void *data)
{
struct d_uuid *id = args;
struct tgt_kill_arg *arg = data;

return vos_pool_kill(id->uuid, 0);
return vos_pool_kill(arg->pool_uuid, arg->flags);
}

/**
Expand Down Expand Up @@ -268,20 +273,24 @@ struct dead_pool {
static int
cleanup_leftover_cb(uuid_t uuid, void *arg)
{
d_list_t *dead_list = arg;
struct dead_pool *dp;
int rc;
struct d_uuid id;
d_list_t *dead_list = arg;
struct dead_pool *dp;
struct tgt_kill_arg kill_arg;
int rc;

/* destroy blobIDs */
D_DEBUG(DB_MGMT, "Clear SPDK blobs for pool "DF_UUID"\n", DP_UUID(uuid));
rc = vos_pool_kill(uuid, VOS_POF_RDB);
uuid_copy(kill_arg.pool_uuid, uuid);
kill_arg.flags = VOS_POF_RDB;
/* This maybe called from main thread, so let's execute the kill on system xtream */
rc = dss_ult_execute(tgt_kill_pool, &kill_arg, NULL, NULL, DSS_XS_SYS, 0, 0);
if (rc != 0) {
D_ERROR(DF_UUID": kill pool service VOS pool: "DF_RC"\n", DP_UUID(uuid), DP_RC(rc));
return rc;
}
uuid_copy(id.uuid, uuid);
rc = dss_thread_collective(tgt_kill_pool, &id, 0);

kill_arg.flags = 0;
rc = dss_thread_collective(tgt_kill_pool, &kill_arg, 0);
if (rc != 0) {
D_ERROR("tgt_kill_pool, rc: "DF_RC"\n", DP_RC(rc));
return rc;
Expand Down Expand Up @@ -452,7 +461,6 @@ recreate_pooltgts()
int rc = 0;
int pool_list_cnt;
daos_size_t rdb_blob_sz = 0;
struct d_uuid id;

D_ASSERT(bio_nvme_configured(SMD_DEV_TYPE_META));
D_INIT_LIST_HEAD(&pool_list);
Expand All @@ -466,10 +474,13 @@ recreate_pooltgts()
/* Cleanup Newborns */
if ((pool_info->spi_blob_sz[SMD_DEV_TYPE_META] == 0) ||
(pool_info->spi_flags[SMD_DEV_TYPE_META] & SMD_POOL_IN_CREATION)) {
struct tgt_kill_arg arg;

D_INFO("cleaning up newborn pool "DF_UUID"\n",
DP_UUID(pool_info->spi_id));
uuid_copy(id.uuid, pool_info->spi_id);
rc = dss_thread_collective(tgt_kill_pool, &id, 0);
uuid_copy(arg.pool_uuid, pool_info->spi_id);
arg.flags = 0;
rc = dss_thread_collective(tgt_kill_pool, &arg, 0);
if (rc) {
D_ERROR("failed to cleanup newborn pool "DF_UUID": "DF_RC"\n",
DP_UUID(pool_info->spi_id), DP_RC(rc));
Expand Down Expand Up @@ -1196,15 +1207,18 @@ static int
tgt_destroy(uuid_t pool_uuid, char *path)
{
struct tgt_destroy_args tda = {0};
struct tgt_kill_arg arg;
pthread_t thread;
int rc;

/* destroy blobIDs first */
uuid_copy(tda.tda_id.uuid, pool_uuid);
rc = dss_thread_collective(tgt_kill_pool, &tda.tda_id, 0);
uuid_copy(arg.pool_uuid, pool_uuid);
arg.flags = 0;
rc = dss_thread_collective(tgt_kill_pool, &arg, 0);
if (rc && rc != -DER_BUSY)
goto out;

uuid_copy(tda.tda_id.uuid, pool_uuid);
tda.tda_path = path;
tda.tda_rc = rc;
tda.tda_dx = dss_current_xstream();
Expand Down

0 comments on commit 0596828

Please sign in to comment.