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-16978 vos: fix issue in VOS pool recreation on faulty device rep… #15771

Open
wants to merge 1 commit into
base: master
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
8 changes: 4 additions & 4 deletions src/bio/bio_context.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.
* (C) Copyright 2018-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -539,13 +539,13 @@ bio_blob_create(uuid_t uuid, struct bio_xs_context *xs_ctxt, uint64_t blob_sz,
if (bio_nvme_configured(SMD_DEV_TYPE_META)) {
if (flags & BIO_MC_FL_RDB)
rc = smd_rdb_add_tgt(uuid, xs_ctxt->bxc_tgt_id, ba->bca_id, st,
blob_sz);
blob_sz, flags & BIO_MC_FL_RECREATE);
else
rc = smd_pool_add_tgt(uuid, xs_ctxt->bxc_tgt_id, ba->bca_id, st,
blob_sz, scm_sz);
blob_sz, scm_sz, flags & BIO_MC_FL_RECREATE);
} else {
rc = smd_pool_add_tgt(uuid, xs_ctxt->bxc_tgt_id, ba->bca_id, st, blob_sz,
0);
0, flags & BIO_MC_FL_RECREATE);
}

if (rc != 0) {
Expand Down
22 changes: 14 additions & 8 deletions src/bio/smd/smd_pool.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.
* (C) Copyright 2018-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -59,7 +59,8 @@ smd_pool_find_tgt(struct smd_pool *pool, int tgt_id)
}

static int
pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id, char *table_name, uint64_t blob_sz)
pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id, char *table_name, uint64_t blob_sz,
bool recreate)
{
struct smd_pool pool;
struct d_uuid id;
Expand Down Expand Up @@ -94,7 +95,8 @@ pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id, char *table_name
pool.sp_tgts[pool.sp_tgt_cnt] = tgt_id;
pool.sp_blobs[pool.sp_tgt_cnt] = blob_id;
pool.sp_tgt_cnt += 1;
if (!strncmp(table_name, TABLE_POOLS[SMD_DEV_TYPE_META], SMD_DEV_NAME_MAX))
if (!strncmp(table_name, TABLE_POOLS[SMD_DEV_TYPE_META], SMD_DEV_NAME_MAX) &&
!recreate)
pool.sp_flags |= SMD_POOL_IN_CREATION;

} else if (rc == -DER_NONEXIST) {
Expand All @@ -103,7 +105,8 @@ pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id, char *table_name
pool.sp_tgt_cnt = 1;
pool.sp_blob_sz = blob_sz;
pool.sp_flags = 0;
if (!strncmp(table_name, TABLE_POOLS[SMD_DEV_TYPE_META], SMD_DEV_NAME_MAX))
if (!strncmp(table_name, TABLE_POOLS[SMD_DEV_TYPE_META], SMD_DEV_NAME_MAX) &&
!recreate)
pool.sp_flags |= SMD_POOL_IN_CREATION;

} else {
Expand All @@ -122,15 +125,17 @@ pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id, char *table_name

int
smd_pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id,
enum smd_dev_type st, uint64_t blob_sz, uint64_t scm_sz)
enum smd_dev_type st, uint64_t blob_sz, uint64_t scm_sz,
bool recreate)
{
struct smd_pool_meta meta = { 0 };
struct d_uuid id;
int rc;

smd_db_lock();

rc = pool_add_tgt(pool_id, tgt_id, blob_id, TABLE_POOLS[st], blob_sz);
rc = pool_add_tgt(pool_id, tgt_id, blob_id, TABLE_POOLS[st], blob_sz,
recreate);
if (rc || scm_sz == 0) {
smd_db_unlock();
return rc;
Expand Down Expand Up @@ -163,12 +168,13 @@ smd_pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id,

int
smd_rdb_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id,
enum smd_dev_type st, uint64_t blob_sz)
enum smd_dev_type st, uint64_t blob_sz, bool recreate)
{
int rc;

smd_db_lock();
rc = pool_add_tgt(pool_id, tgt_id, blob_id, TABLE_RDBS[st], blob_sz);
rc = pool_add_tgt(pool_id, tgt_id, blob_id, TABLE_RDBS[st], blob_sz,
recreate);
smd_db_unlock();

return rc;
Expand Down
20 changes: 10 additions & 10 deletions src/bio/smd/tests/smd_ut.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2023 Intel Corporation.
* (C) Copyright 2018-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -363,32 +363,32 @@ ut_pool(void **state)

for (i = 0; i < 6; i++) {
st = (i < 4) ? SMD_DEV_TYPE_DATA : SMD_DEV_TYPE_DATA + i - 3;
rc = smd_pool_add_tgt(id1, i, i << 10, st, 100, 0);
rc = smd_pool_add_tgt(id1, i, i << 10, st, 100, 0, false);
assert_rc_equal(rc, 0);

if (st == SMD_DEV_TYPE_META)
rc = smd_pool_add_tgt(id2, i, i << 20, st, 200, 50);
rc = smd_pool_add_tgt(id2, i, i << 20, st, 200, 50, false);
else
rc = smd_pool_add_tgt(id2, i, i << 20, st, 200, 0);
rc = smd_pool_add_tgt(id2, i, i << 20, st, 200, 0, false);
assert_rc_equal(rc, 0);
}

rc = smd_pool_add_tgt(id1, 0, 5000, SMD_DEV_TYPE_DATA, 100, 0);
rc = smd_pool_add_tgt(id1, 0, 5000, SMD_DEV_TYPE_DATA, 100, 0, false);
assert_rc_equal(rc, -DER_EXIST);

rc = smd_pool_add_tgt(id1, 4, 4 << 10, SMD_DEV_TYPE_DATA, 200, 0);
rc = smd_pool_add_tgt(id1, 4, 4 << 10, SMD_DEV_TYPE_DATA, 200, 0, false);
assert_rc_equal(rc, -DER_INVAL);

rc = smd_pool_add_tgt(id1, 4, 5000, SMD_DEV_TYPE_META, 100, 0);
rc = smd_pool_add_tgt(id1, 4, 5000, SMD_DEV_TYPE_META, 100, 0, false);
assert_rc_equal(rc, -DER_EXIST);

rc = smd_pool_add_tgt(id1, 0, 4 << 10, SMD_DEV_TYPE_META, 200, 0);
rc = smd_pool_add_tgt(id1, 0, 4 << 10, SMD_DEV_TYPE_META, 200, 0, false);
assert_rc_equal(rc, -DER_INVAL);

rc = smd_pool_add_tgt(id1, 5, 5000, SMD_DEV_TYPE_WAL, 100, 0);
rc = smd_pool_add_tgt(id1, 5, 5000, SMD_DEV_TYPE_WAL, 100, 0, false);
assert_rc_equal(rc, -DER_EXIST);

rc = smd_pool_add_tgt(id1, 0, 4 << 10, SMD_DEV_TYPE_WAL, 200, 0);
rc = smd_pool_add_tgt(id1, 0, 4 << 10, SMD_DEV_TYPE_WAL, 200, 0, false);
assert_rc_equal(rc, -DER_INVAL);

rc = smd_pool_get_info(id1, &pool_info);
Expand Down
3 changes: 2 additions & 1 deletion src/include/daos_srv/bio.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.
* (C) Copyright 2018-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -1010,6 +1010,7 @@ int bio_copy(struct bio_io_context *ioctxt, struct umem_instance *umem,

enum bio_mc_flags {
BIO_MC_FL_RDB = (1UL << 0), /* for RDB */
BIO_MC_FL_RECREATE = (1UL << 1), /* to identify recreate (e.g., in replace op) */
};

/*
Expand Down
8 changes: 5 additions & 3 deletions src/include/daos_srv/smd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2023 Intel Corporation.
* (C) Copyright 2016-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -172,15 +172,17 @@ int smd_dev_replace(uuid_t old_id, uuid_t new_id, unsigned int old_roles);
* \param [IN] smd_type SMD type
* \param [IN] blob_sz Blob size in bytes
* \param [IN] scm_sz VOS file size in bytes
* \param [IN] recreate is recreate (in replace) or not
*
* \return Zero on success, negative value on error
*/
int smd_pool_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id,
enum smd_dev_type smd_type, uint64_t blob_sz, uint64_t scm_sz);
enum smd_dev_type smd_type, uint64_t blob_sz, uint64_t scm_sz,
bool recreate);

/* Assign a blob to a RDB pool target */
int smd_rdb_add_tgt(uuid_t pool_id, uint32_t tgt_id, uint64_t blob_id,
enum smd_dev_type smd_type, uint64_t blob_sz);
enum smd_dev_type smd_type, uint64_t blob_sz, bool recreate);

/**
* Unassign a VOS pool target
Expand Down
4 changes: 3 additions & 1 deletion src/include/daos_srv/vos_types.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2015-2024 Intel Corporation.
* (C) Copyright 2015-2025 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
Expand Down Expand Up @@ -97,6 +97,8 @@ enum vos_pool_open_flags {
VOS_POF_FOR_CHECK_QUERY = (1 << 6),
/** Open the pool for feature fetch/update, that will skip VEA load */
VOS_POF_FOR_FEATURE_FLAG = (1 << 7),
/** To identify this is a recreate operation. */
VOS_POF_FOR_RECREATE = (1 << 8),
};

enum vos_oi_attr {
Expand Down
3 changes: 1 addition & 2 deletions src/pool/srv_target.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* (C) Copyright 2016-2024 Intel Corporation.

Check failure on line 2 in src/pool/srv_target.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
/**
Expand Down Expand Up @@ -460,7 +459,7 @@
rc = vos_pool_create(path, child->spc_uuid, 0 /* scm_sz */,
pool_info->spi_blob_sz[SMD_DEV_TYPE_DATA],
pool_info->spi_blob_sz[SMD_DEV_TYPE_META],
0 /* flags */, vos_df_version, NULL);
VOS_POF_FOR_RECREATE/* flags */, vos_df_version, NULL);
if (rc)
DL_ERROR(rc, DF_UUID": Create VOS pool failed.", DP_UUID(child->spc_uuid));

Expand Down
4 changes: 2 additions & 2 deletions src/utils/ddb/ddb_vos.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2022-2024 Intel Corporation.
* (C) Copyright 2022-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -1775,7 +1775,7 @@ sync_cb(struct ddbs_sync_info *info, void *cb_args)
D_WARN("delete target failed: " DF_RC "\n", DP_RC(rc));

rc = smd_pool_add_tgt(pool_id, info->dsi_hdr->bbh_vos_id,
info->dsi_hdr->bbh_blob_id, st, blob_size, 0);
info->dsi_hdr->bbh_blob_id, st, blob_size, 0, false);
if (!SUCCESS(rc)) {
D_ERROR("add target failed: "DF_RC"\n", DP_RC(rc));
args->sync_rc = rc;
Expand Down
5 changes: 4 additions & 1 deletion src/vos/vos_pool.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2024 Intel Corporation.
* (C) Copyright 2016-2025 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
Expand Down Expand Up @@ -795,6 +795,9 @@ vos2mc_flags(unsigned int vos_flags)
if (vos_flags & VOS_POF_RDB)
mc_flags |= BIO_MC_FL_RDB;

if (vos_flags & VOS_POF_FOR_RECREATE)
mc_flags |= BIO_MC_FL_RECREATE;

return mc_flags;
}

Expand Down
Loading