Skip to content
Draft
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
426 changes: 331 additions & 95 deletions src/container/srv_container.c

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/container/srv_epoch.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* (C) Copyright 2016-2023 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP

Check failure on line 3 in src/container/srv_epoch.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -694,7 +694,7 @@
ABT_rwlock_rdlock(svc->cs_lock);
rc = cont_lookup(&tx, svc, cont_uuid, &cont);
if (rc != 0) {
DL_ERROR(rc, DF_CONT " cont_lookup failed", DP_CONT(pool_uuid, cont_uuid));
DL_INFO(rc, DF_CONT ": cont_lookup", DP_CONT(pool_uuid, cont_uuid));
D_GOTO(out_lock, rc);
}

Expand Down Expand Up @@ -741,8 +741,7 @@
ABT_rwlock_rdlock(svc->cs_lock);
rc = cont_lookup(&tx, svc, cont_uuid, &cont);
if (rc != 0) {
D_ERROR(DF_CONT": Failed to look container: %d\n",
DP_CONT(svc->cs_pool_uuid, cont_uuid), rc);
DL_INFO(rc, DF_CONT ": cont_lookup", DP_CONT(svc->cs_pool_uuid, cont_uuid));
goto out_lock;
}

Expand Down
14 changes: 12 additions & 2 deletions src/container/srv_layout.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* (C) Copyright 2016-2023 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -96,6 +96,9 @@ struct container_hdl {
*
* All keys are strings. Value types are specified for each key below.
*
* The ds_cont_prop_ghce property had always been uint64_t value 0 before being
* repurposed for container_flags_t.
*
* IMPORTANT! Please add new keys to this KVS like this:
*
* extern d_iov_t ds_cont_prop_new_key; comment_on_value_type
Expand All @@ -104,7 +107,8 @@ struct container_hdl {
* usage shall be described above in this comment following existing
* examples. If the value is another KVS, its type shall be the KVS name.
*/
extern d_iov_t ds_cont_prop_ghce; /* uint64_t */
/* clang-format off */
extern d_iov_t ds_cont_prop_ghce; /* container_flags_t */
extern d_iov_t ds_cont_prop_alloced_oid; /* uint64_t */
extern d_iov_t ds_cont_prop_label; /* string */
extern d_iov_t ds_cont_prop_layout_type; /* uint64_t */
Expand Down Expand Up @@ -139,8 +143,14 @@ extern d_iov_t ds_cont_prop_cont_obj_version; /* uint32_t */
extern d_iov_t ds_cont_prop_nhandles; /* uint32_t */
extern d_iov_t ds_cont_prop_oit_oids; /* snapshot OIT OID KVS */
extern d_iov_t ds_cont_prop_ec_agg_eph; /* uint64_t */
/* clang-format on */
/* Please read the IMPORTANT notes above before adding new keys. */

/* Container flags (e.g., CONTAINER_F_DESTROYING) */
typedef uint64_t container_flags_t;

#define CONTAINER_F_DESTROYING (1ULL << 0) /* being destroyed */

struct co_md_times {
uint64_t otime; /* container open time */
uint64_t mtime; /* container metadata modify time */
Expand Down
7 changes: 0 additions & 7 deletions src/container/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,13 +1357,6 @@ cont_child_destroy_one(void *vin)
if (rc != 0)
D_GOTO(out_pool, rc);

if (cont->sc_open > 0) {
D_ERROR(DF_CONT": Container is still in open(%d)\n",
DP_CONT(cont->sc_pool->spc_uuid, cont->sc_uuid), cont->sc_open);
cont_child_put(tls->dt_cont_cache, cont);
D_GOTO(out_pool, rc = -DER_BUSY);
}

if (cont->sc_destroying) {
D_DEBUG(DB_MD, DF_CONT ": Container is already being destroyed\n",
DP_CONT(cont->sc_pool->spc_uuid, cont->sc_uuid));
Expand Down
12 changes: 6 additions & 6 deletions src/gurt/tests/test_gurt.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* (C) Copyright 2016-2024 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -130,11 +130,11 @@ test_d_errstr(void **state)
assert_string_equal(value, "DER_UNKNOWN");

/* Check the end of the DAOS error numbers. */
value = d_errstr(-DER_CONT_NONEXIST);
assert_string_equal(value, "DER_CONT_NONEXIST");
value = d_errstr(-2050);
assert_string_equal(value, "DER_CONT_NONEXIST");
value = d_errstr(-(DER_CONT_NONEXIST + 1));
value = d_errstr(-DER_CONT_DESTROYING);
assert_string_equal(value, "DER_CONT_DESTROYING");
value = d_errstr(-2051);
assert_string_equal(value, "DER_CONT_DESTROYING");
value = d_errstr(-(DER_CONT_DESTROYING + 1));
assert_string_equal(value, "DER_UNKNOWN");
}

Expand Down
5 changes: 4 additions & 1 deletion src/include/daos/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ daos_der2errno(int err)
case -DER_SUCCESS: return 0;
case -DER_NO_PERM:
case -DER_EP_RO:
case -DER_EP_OLD: return EPERM;
case -DER_EP_OLD:
case -DER_CONT_DESTROYING:
return EPERM;
case -DER_ENOENT:
case -DER_NONEXIST: return ENOENT;
case -DER_INVAL:
Expand Down Expand Up @@ -915,6 +917,7 @@ enum {
#define DAOS_POOL_EVICT_FAIL (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xa0)
#define DAOS_POOL_RFCHECK_FAIL (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xa1)
#define DAOS_POOL_REINT_SLOW (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xa2)
#define DAOS_CONT_DESTROY_FAIL_POST (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xa3)

#define DAOS_CHK_CONT_ORPHAN (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xb0)
#define DAOS_CHK_CONT_BAD_LABEL (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xb1)
Expand Down
5 changes: 3 additions & 2 deletions src/include/daos_errno.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* (C) Copyright 2016-2024 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -213,7 +213,8 @@ extern "C" {
/** Target is overload, retry RPC */ \
ACTION(DER_OVERLOAD_RETRY, retry later because of overloaded service) \
ACTION(DER_NOT_RESUME, Cannot resume former DAOS check instance) \
ACTION(DER_CONT_NONEXIST, The specified container does not exist)
ACTION(DER_CONT_NONEXIST, The specified container does not exist) \
ACTION(DER_CONT_DESTROYING, The specified container is being destroyed)

/* clang-format on */

Expand Down
6 changes: 4 additions & 2 deletions src/include/daos_srv/container.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2015-2024 Intel Corporation.
* (C) Copyright 2025 Google LLC
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -39,7 +39,9 @@ int
daos_prop_t *prop);
int
ds_cont_svc_refresh_agg_eph(uuid_t pool_uuid);
int ds_cont_list(uuid_t pool_uuid, struct daos_pool_cont_info **conts, uint64_t *ncont);
int
ds_cont_list(uuid_t pool_uuid, bool include_destroying, struct daos_pool_cont_info **conts,
uint64_t *ncont);
int ds_cont_filter(uuid_t pool_uuid, daos_pool_cont_filter_t *filt,
struct daos_pool_cont_info2 **conts, uint64_t *ncont);
int ds_cont_upgrade(uuid_t pool_uuid, struct cont_svc *svc);
Expand Down
6 changes: 3 additions & 3 deletions src/pool/srv_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -5144,7 +5144,7 @@ pool_list_cont_handler(crt_rpc_t *rpc, int handler_version)
}

/* Call container service to get the list */
rc = ds_cont_list(in->plci_op.pi_uuid, &cont_buf, &ncont);
rc = ds_cont_list(in->plci_op.pi_uuid, false /* include_destroying */, &cont_buf, &ncont);
if (rc != 0) {
D_GOTO(out_svc, rc);
} else if ((ncont_in > 0) && (ncont > ncont_in)) {
Expand All @@ -5161,7 +5161,7 @@ pool_list_cont_handler(crt_rpc_t *rpc, int handler_version)
DP_UUID(in->plci_op.pi_uuid), DP_UUID(in->plci_op.pi_hdl), ncont);

/* Send any results only if client provided a handle */
if (cont_buf && (ncont_in > 0) && (bulk != CRT_BULK_NULL))
if (ncont > 0 && (ncont_in > 0) && (bulk != CRT_BULK_NULL))
rc = transfer_cont_buf(cont_buf, nbytes, svc, rpc, bulk);
}

Expand Down Expand Up @@ -8117,7 +8117,7 @@ pool_recov_cont(crt_context_t ctx, struct pool_svc *svc, struct pool_target_addr
if (rc != 0)
goto out;

rc = ds_cont_list(svc->ps_uuid, &dpci, &cont_nr);
rc = ds_cont_list(svc->ps_uuid, false /* include_destroying */, &dpci, &cont_nr);
if (rc != 0)
D_GOTO(out, rc);

Expand Down
40 changes: 39 additions & 1 deletion src/tests/suite/daos_container.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* (C) Copyright 2016-2024 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -4039,6 +4039,43 @@ co_op_dup_timing(void **state)
test_teardown((void **)&arg);
}

/* Opening a DESTROYING container should fail. */
static void
co_open_destroying(void **state)
{
test_arg_t *arg = *state;
char *label = "c_open_destroying";
uuid_t uuid;
daos_handle_t coh;
int rc;

par_barrier(PAR_COMM_WORLD);

if (arg->myrank != 0)
goto out;

rc = daos_cont_create_with_label(arg->pool.poh, label, NULL, &uuid, NULL);
assert_rc_equal(rc, 0);
print_message("created container '%s' (" DF_UUIDF ")\n", label, DP_UUID(uuid));

print_message("destroying container '%s' with fault injection\n", label);
test_set_engine_fail_loc(arg, CRT_NO_RANK, DAOS_CONT_DESTROY_FAIL_POST | DAOS_FAIL_ALWAYS);
rc = daos_cont_destroy(arg->pool.poh, label, 1 /* force */, NULL);
assert_rc_equal(rc, -DER_NOMEM);

print_message("attempting to open DESTROYING container '%s'\n", label);
rc = daos_cont_open(arg->pool.poh, label, DAOS_COO_RW, &coh, NULL, NULL);
assert_rc_equal(rc, -DER_NONEXIST);

print_message("destroying container '%s'\n", label);
test_set_engine_fail_loc(arg, CRT_NO_RANK, 0);
rc = daos_cont_destroy(arg->pool.poh, label, 1 /* force */, NULL);
assert_rc_equal(rc, 0);

out:
par_barrier(PAR_COMM_WORLD);
}

static int
co_setup_sync(void **state)
{
Expand Down Expand Up @@ -4111,6 +4148,7 @@ static const struct CMUnitTest co_tests[] = {
{"CONT33: exclusive open", co_exclusive_open, NULL, test_case_teardown},
{"CONT34: evict handles", co_evict_hdls, NULL, test_case_teardown},
{"CONT35: container duplicate op detection timing", co_op_dup_timing, NULL, test_case_teardown},
{"CONT36: open DESTROYING", co_open_destroying, NULL, test_case_teardown},
};

int
Expand Down
Loading