Skip to content

Commit

Permalink
DAOS-14535 pool: start/stop ds_pool_child individually (daos-stack#13347
Browse files Browse the repository at this point in the history
)

Reorganize ds_pool_child start/stop code to make it able to be
started/stopped individually:

- Introduced four states for ds_pool_child: NEW, STARTING, STARTED
  and STOPPING.
- ds_pool_child is added/removed to/from cache through the collective
  call of pool_child_add/delete_one(), now the cache doesn't hold the
  ds_pool_child reference anymore.
- Introduced ds_pool_child_start/stop() for callers to start/stop
  ds_pool_child individually, ds_pool_child_state() to query the state
  of ds_pool_child.
- Removed ds_pool_child_get();

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: shiying <yshi1210@gmail.com>
  • Loading branch information
NiuYawei authored and yyyshi committed Nov 22, 2023
1 parent f6c571b commit fdd5144
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 114 deletions.
4 changes: 1 addition & 3 deletions src/container/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,6 @@ ds_cont_child_stop_all(struct ds_pool_child *pool_child)
DP_UUID(pool_child->spc_uuid),
dss_get_module_info()->dmi_tgt_id);

D_ASSERT(d_list_empty(&pool_child->spc_list));

cont_list = &pool_child->spc_cont_list;
while (!d_list_empty(cont_list)) {
cont_child = d_list_entry(cont_list->next,
Expand Down Expand Up @@ -1532,7 +1530,7 @@ ds_cont_local_open(uuid_t pool_uuid, uuid_t cont_hdl_uuid, uuid_t cont_uuid,
if (ddra == NULL)
D_GOTO(err_dtx, rc = -DER_NOMEM);

ddra->pool = ds_pool_child_get(hdl->sch_cont->sc_pool);
ddra->pool = ds_pool_child_lookup(hdl->sch_cont->sc_pool->spc_uuid);
uuid_copy(ddra->co_uuid, cont_uuid);
rc = dss_ult_create(ds_dtx_resync, ddra, DSS_XS_SELF,
0, 0, NULL);
Expand Down
20 changes: 18 additions & 2 deletions src/include/daos_srv/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct ds_pool {
ABT_cond sp_fetch_hdls_cond;
ABT_cond sp_fetch_hdls_done_cond;
struct ds_iv_ns *sp_iv_ns;
uint32_t *sp_states; /* pool child state array */

/* structure related to EC aggregate epoch query */
d_list_t sp_ec_ephs_list;
Expand Down Expand Up @@ -128,6 +129,13 @@ struct ds_pool_hdl {
struct ds_pool_hdl *ds_pool_hdl_lookup(const uuid_t uuid);
void ds_pool_hdl_put(struct ds_pool_hdl *hdl);

enum pool_child_state {
POOL_CHILD_NEW = 0,
POOL_CHILD_STARTING,
POOL_CHILD_STARTED,
POOL_CHILD_STOPPING,
};

/*
* Per-thread pool object
*
Expand Down Expand Up @@ -160,8 +168,9 @@ struct ds_pool_child {
int spc_ref;
ABT_eventual spc_ref_eventual;

uint64_t spc_discard_done:1;
uint32_t spc_discard_done:1;
uint32_t spc_reint_mode;
uint32_t *spc_state; /* Pointer to ds_pool->sp_states[i] */
/**
* Per-pool per-module metrics, see ${modname}_pool_metrics for the
* actual structure. Initialized only for modules that specified a
Expand All @@ -182,9 +191,16 @@ struct ds_pool_svc_op_val {
char ov_resvd[60];
};

/* Find ds_pool_child in cache, hold one reference */
struct ds_pool_child *ds_pool_child_lookup(const uuid_t uuid);
struct ds_pool_child *ds_pool_child_get(struct ds_pool_child *child);
/* Put the reference held by ds_pool_child_lookup() */
void ds_pool_child_put(struct ds_pool_child *child);
/* Start ds_pool child */
int ds_pool_child_start(uuid_t pool_uuid);
/* Stop ds_pool_child */
int ds_pool_child_stop(uuid_t pool_uuid);
/* Query pool child state */
uint32_t ds_pool_child_state(struct ds_pool *pool, uint32_t tgt_id);

int ds_pool_bcast_create(crt_context_t ctx, struct ds_pool *pool,
enum daos_module_id module, crt_opcode_t opcode,
Expand Down
Loading

0 comments on commit fdd5144

Please sign in to comment.