Skip to content
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
1 change: 1 addition & 0 deletions ci/test_files_to_stash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ build/*/*/src/engine/tests/drpc_listener_tests,
build/*/*/src/mgmt/tests/srv_drpc_tests,
build/*/*/src/object/tests/cli_checksum_tests,
build/*/*/src/object/tests/srv_checksum_tests,
build/*/*/src/object/tests/srv_ec_agg_tests,
build/*/*/src/pool/tests/pool_cli_tests,
build/*/*/src/security/tests/cli_security_tests,
build/*/*/src/security/tests/srv_acl_tests,
Expand Down
25 changes: 20 additions & 5 deletions src/container/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,11 @@ cont_child_alloc_ref(void *co_uuid, unsigned int ksize, void *po_uuid,
if (cont == NULL)
return -DER_NOMEM;

/* What was written without DTX before is not known. The write timestamp cache of the keys
* can be older than this container child: it belongs to the xstream.
*/
cont->sc_ec_nontx_timestamp = d_hlc_get();

rc = ABT_mutex_create(&cont->sc_open_mutex);
if (rc != ABT_SUCCESS) {
rc = dss_abterr2der(rc);
Expand Down Expand Up @@ -2832,13 +2837,16 @@ ds_cont_eph_report(struct ds_pool *pool)
(min_ec_agg_eph != 0 && ec_eph->cte_last_ec_agg_epoch != 0 &&
min_ec_agg_eph <= ec_eph->cte_last_ec_agg_epoch &&
min_stable_eph <= ec_eph->cte_last_stable_epoch)) {
/* The EC aggregation epoch of a target can go back: a scan finds a replica
* to be visited again below it, or a forced scan reports its ranges one by
* one. Only the stable epoch is not expected to.
*/
if (min_ec_agg_eph > 0 && min_stable_eph > 0 &&
(min_ec_agg_eph < ec_eph->cte_last_ec_agg_epoch ||
min_stable_eph < ec_eph->cte_last_stable_epoch))
D_ERROR("ignore for now, min_ec_agg_eph " DF_X64 " < " DF_X64 ", "
"or min_stable_eph " DF_X64 " < " DF_X64 ", " DF_UUID "\n",
min_ec_agg_eph, ec_eph->cte_last_ec_agg_epoch,
min_stable_eph < ec_eph->cte_last_stable_epoch)
D_ERROR("ignore for now, min_stable_eph " DF_X64 " < " DF_X64 ", "
"min_ec_agg_eph " DF_X64 "/" DF_X64 ", " DF_UUID "\n",
min_stable_eph, ec_eph->cte_last_stable_epoch,
min_ec_agg_eph, ec_eph->cte_last_ec_agg_epoch,
DP_UUID(ec_eph->cte_cont_uuid));
else
D_DEBUG(DB_MD,
Expand Down Expand Up @@ -2963,3 +2971,10 @@ ds_cont_ec_timestamp_update(struct ds_cont_child *cont)
{
cont->sc_ec_update_timestamp = d_hlc_get();
}

void
ds_cont_ec_nontx_timestamp_update(struct ds_cont_child *cont)
{
cont->sc_ec_update_timestamp = d_hlc_get();
cont->sc_ec_nontx_timestamp = cont->sc_ec_update_timestamp;
}
7 changes: 7 additions & 0 deletions src/include/daos_srv/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ struct ds_cont_child {
* if it needs to do EC aggregate.
*/
uint64_t sc_ec_update_timestamp;
/* Timestamp of the last EC update without DTX (migration), it is not seen by the write
* timestamp cache of the keys. In memory only, starts as the time the container child
* was created.
*/
uint64_t sc_ec_nontx_timestamp;

/* The objects with committable DTXs in DRAM. */
daos_handle_t sc_dtx_cos_hdl;
Expand Down Expand Up @@ -307,6 +312,8 @@ int
void ds_cont_track_eph_free(struct ds_pool *pool);

void ds_cont_ec_timestamp_update(struct ds_cont_child *cont);
void
ds_cont_ec_nontx_timestamp_update(struct ds_cont_child *cont);

typedef int(*cont_rdb_iter_cb_t)(uuid_t pool_uuid, uuid_t cont_uuid, struct rdb_tx *tx, void *arg);
int ds_cont_rdb_iterate(struct cont_svc *svc, cont_rdb_iter_cb_t iter_cb, void *cb_arg);
Expand Down
8 changes: 7 additions & 1 deletion src/include/daos_srv/vos_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,14 @@ enum {
VOS_IT_FOR_AGG = (1 << 9),
/** Checking whether the target is aborted or not. */
VOS_IT_FOR_CHECK = (1 << 10),
/** The filter callback gets the epoch of the latest write as id_agg_write, rather than the
* stored timestamp of the writes which need aggregation, which is not maintained for
* every write. Object: vo_max_write. Key: the write timestamp cache, which a write
* without DTX does not update. DAOS_EPOCH_MAX if it is not known.
*/
VOS_IT_AGG_LAST_WRITE = (1 << 11),
/** Mask for all flags */
VOS_IT_MASK = (1 << 11) - 1,
VOS_IT_MASK = (1 << 12) - 1,
};

typedef struct {
Expand Down
194 changes: 194 additions & 0 deletions src/object/srv_ec_agg_range.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/**
* (C) Copyright 2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
/**
* How EC aggregation of a container shard goes over the epoch ranges of a round, see
* cont_ec_aggregate_cb(). It does not depend on the engine, so that unit tests can drive it.
*
* The EC aggregation epoch of the shard (sc_ec_agg_eph) says that everything at or below it was
* processed. The epoch reported for the boundary is derived from it, and a rebuild or a degraded
* fetch reads the data of the shard at that boundary, so the epoch must not pass a replica which
* was not visited.
*/

#ifndef __SRV_EC_AGG_RANGE_H__
#define __SRV_EC_AGG_RANGE_H__

#include <daos_types.h>

enum ec_agg_range_act {
/** Iterate the objects of the range. */
EC_AGG_RANGE_SCAN,
/** Nothing was written since the range was processed, it is done without iteration. */
EC_AGG_RANGE_IDLE,
/** Leave the range to a later round, the aggregation epoch is not changed. */
EC_AGG_RANGE_SKIP,
};

/** Result of a range. Not zero: end the round without error, a forced scan is not done. */
enum ec_agg_range_res {
/** The range is done. */
EC_AGG_RANGE_DONE = 0,
/** The scan does not count (pool map updated, no boundary yet), nothing is changed. */
EC_AGG_RANGE_VOID = 1,
/** Something is to be visited again at or below the aggregation epoch, it is reported. */
EC_AGG_RANGE_HELD = 2,
};

/** One epoch range of a round, i.e. one call of cont_ec_aggregate_cb(). */
struct ec_agg_range {
/** Upper bound of the range. */
daos_epoch_t ar_hi;
/** EC aggregation epoch when the range was started. */
daos_epoch_t ar_agg_eph;
/** Pool map version when the range was started. */
uint32_t ar_map_ver;
/** Forced scan: what is below the aggregation epoch is verified again. */
bool ar_force;
/** Nothing to do for an object which was last written at or below this epoch. */
daos_epoch_t ar_filter_eph;
/** The write timestamp cache of the keys can be relied on, see ec_agg_range_skip_key(). */
bool ar_key_filter;
};

/**
* An object is left out if its last write is known, and is covered by what was processed.
*
* \param[in] last_write Epoch of the last write of the object, zero or DAOS_EPOCH_MAX
* if it is not known.
*/
static inline bool
ec_agg_range_skip_obj(const struct ec_agg_range *ar, daos_epoch_t last_write)
{
return last_write != 0 && last_write <= ar->ar_filter_eph;
}

/**
* A key of an object which passed is left out by its last write in the write timestamp cache.
*
* The cache does not see a write without DTX (migration), so it is only relied on once what was
* processed covers the last of those writes, see ar_key_filter.
*
* \param[in] last_write What the cache has for the key, DAOS_EPOCH_MAX on a miss.
*/
static inline bool
ec_agg_range_skip_key(const struct ec_agg_range *ar, daos_epoch_t last_write)
{
return ar->ar_key_filter && last_write != 0 && last_write <= ar->ar_filter_eph;
}

/**
* Start a range.
*
* \param[in] epr The range, the lower bound is inclusive.
* \param[in] force_scan Scan forced from the lower bound of the range, the aggregation
* epoch does not say what was processed for this scan.
* \param[in] agg_eph EC aggregation epoch of the shard.
* \param[in] map_ver Pool map version of the target.
* \param[in] now Current HLC.
* \param[in] nontx_ts Timestamp of the last update without DTX of the container shard,
* or of the creation of the container child if that is later. Zero
* if it is not known.
* \param[in,out] update_ts Timestamp of the last update of the container shard, kept in
* memory only.
*/
static inline enum ec_agg_range_act
ec_agg_range_begin(struct ec_agg_range *ar, const daos_epoch_range_t *epr, bool force_scan,
daos_epoch_t agg_eph, uint32_t map_ver, daos_epoch_t now, daos_epoch_t nontx_ts,
daos_epoch_t *update_ts)
{
/* Not known after a restart. Whatever was written before is older than now, and is not
* skipped until the aggregation epoch passes it.
*/
if (*update_ts == 0)
*update_ts = now;

ar->ar_hi = epr->epr_hi;
ar->ar_agg_eph = agg_eph;
ar->ar_map_ver = map_ver;
ar->ar_force = force_scan;
ar->ar_filter_eph = 0;
ar->ar_key_filter = false;

/* Only a range which continues what was processed can move the aggregation epoch. The
* range before this one was not completed, or the epoch was reset: an incremental scan
* of a later round covers this range.
*/
if (epr->epr_lo > agg_eph && epr->epr_lo - agg_eph > 1)
return EC_AGG_RANGE_SKIP;

/* The lower bound is inclusive: what was written at it is not processed yet. */
if (!force_scan)
ar->ar_filter_eph = agg_eph;
else if (epr->epr_lo > 0)
ar->ar_filter_eph = epr->epr_lo - 1;

if (ar->ar_filter_eph != 0 && ar->ar_filter_eph >= *update_ts)
return EC_AGG_RANGE_IDLE;

ar->ar_key_filter = nontx_ts != 0 && ar->ar_filter_eph >= nontx_ts;

return EC_AGG_RANGE_SCAN;
}

/** The boundary of the container is not known yet, nothing can be scanned. */
static inline int
ec_agg_range_no_boundary(bool force_scan)
{
return force_scan ? EC_AGG_RANGE_VOID : EC_AGG_RANGE_DONE;
}

/**
* Settle a range which was scanned without error, or was idle.
*
* \param[in] map_ver Pool map version of the target.
* \param[in] min_unagg Lowest epoch which was visited and has to be visited again,
* DAOS_EPOCH_MAX if there is none.
* \param[in,out] agg_eph EC aggregation epoch of the shard.
* \param[out] report Epoch to be reported for the boundary, optional.
*
* \return See enum ec_agg_range_res.
*/
static inline int
ec_agg_range_end(const struct ec_agg_range *ar, uint32_t map_ver, daos_epoch_t min_unagg,
daos_epoch_t *agg_eph, daos_epoch_t *report)
{
daos_epoch_t done;
daos_epoch_t held;

/* A pool map update since ec_agg_range_begin() resets the aggregation epoch to the
* boundary, possibly to the same value: what was scanned with the old layout does not
* count. A scan which was retried after a yield is still one scan.
*/
if (*agg_eph != ar->ar_agg_eph || map_ver != ar->ar_map_ver)
return EC_AGG_RANGE_VOID;

/* what has to be visited again holds the epoch back */
done = min_unagg - 1 < ar->ar_hi ? min_unagg - 1 : ar->ar_hi;
if (done > *agg_eph)
*agg_eph = done;
if (report != NULL) {
/* The boundary is the epoch which a recovery reads at, inclusive: below what has
* to be visited again, also when the aggregation epoch is not.
*/
held = min_unagg - 1;
*report = held < *agg_eph ? held : *agg_eph;
/* A forced scan does not report over what it verified so far: a later range of it
* can still find something to be visited again below the aggregation epoch.
*/
if (ar->ar_force && *report > ar->ar_hi)
*report = ar->ar_hi;
}

/* E.g. a scan forced from zero found a replica left for the leader. The epoch is not moved
* back; the round ends so that the next range does not report over the lower epoch.
*/
if (min_unagg <= ar->ar_agg_eph)
return EC_AGG_RANGE_HELD;

return EC_AGG_RANGE_DONE;
}

#endif /* __SRV_EC_AGG_RANGE_H__ */
Loading
Loading