Skip to content

Commit

Permalink
DAOS-14105 placement: pack target information into object layout
Browse files Browse the repository at this point in the history
Then it bypasses pool_map_find_target() when need to locate DAOS
target according to object layout.

Signed-off-by: Fan Yong <fan.yong@intel.com>
  • Loading branch information
Nasf-Fan committed Dec 5, 2023
1 parent 6e968f5 commit 19a0fc8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/include/daos/placement.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2022 Intel Corporation.
* (C) Copyright 2016-2023 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -63,7 +63,9 @@ struct pl_obj_shard {
uint32_t po_shard; /* shard identifier */
uint32_t po_target; /* target id */
uint32_t po_fseq; /* The latest failure sequence */
uint32_t po_rebuilding:1, /* rebuilding status */
uint16_t po_rank; /* The rank on which the shard exists */
uint8_t po_index; /* The target index inside the node */
uint8_t po_rebuilding:1, /* rebuilding status */
po_reintegrating:1; /* reintegrating status */
};

Expand Down
20 changes: 8 additions & 12 deletions src/object/srv_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -5571,7 +5571,6 @@ obj_coll_punch_prep(struct obj_coll_punch_in *ocpi, struct dtx_coll_entry **p_dc
struct daos_coll_shard *dcs;
struct dtx_daos_target *ddt;
struct dtx_target_group *dtg;
struct pool_target *tgt;
struct daos_obj_md md = { 0 };
uint32_t *tmp;
uint32_t rank_nr;
Expand Down Expand Up @@ -5631,11 +5630,8 @@ obj_coll_punch_prep(struct obj_coll_punch_in *ocpi, struct dtx_coll_entry **p_dc
if (layout->ol_shards[i].po_target == -1 || layout->ol_shards[i].po_shard == -1)
continue;

rc = pool_map_find_target(map->pl_poolmap, layout->ol_shards[i].po_target, &tgt);
D_ASSERT(rc == 1);

dct = &dcts[tgt->ta_comp.co_rank];
dct->dct_rank = tgt->ta_comp.co_rank;
dct = &dcts[layout->ol_shards[i].po_rank];
dct->dct_rank = layout->ol_shards[i].po_rank;

if (max_rank < dct->dct_rank)
max_rank = dct->dct_rank;
Expand Down Expand Up @@ -5667,11 +5663,11 @@ obj_coll_punch_prep(struct obj_coll_punch_in *ocpi, struct dtx_coll_entry **p_dc
if (dct->dct_tgt_nr == 0) {
/* Assign the first available shard to the hint for this engine. */
if (dce->dce_hints != NULL)
dce->dce_hints[dct->dct_rank] = tgt->ta_comp.co_index;
dce->dce_hints[dct->dct_rank] = layout->ol_shards[i].po_index;
rank_nr++;
}

if (tgt->ta_comp.co_id == ocpi->ocpi_leader_id) {
if (layout->ol_shards[i].po_target == ocpi->ocpi_leader_id) {
if (ocpi->ocpi_flags & ORF_LEADER)
D_ASSERTF(myrank == dct->dct_rank,
"Unmatched leader rank %u vs %u\n",
Expand Down Expand Up @@ -5713,7 +5709,7 @@ obj_coll_punch_prep(struct obj_coll_punch_in *ocpi, struct dtx_coll_entry **p_dc
}

/* Only collect targets bitmap and shards for current engine. */
if (tgt->ta_comp.co_rank != myrank)
if (layout->ol_shards[i].po_rank != myrank)
continue;

if (dct->dct_bitmap == NULL) {
Expand All @@ -5733,9 +5729,9 @@ obj_coll_punch_prep(struct obj_coll_punch_in *ocpi, struct dtx_coll_entry **p_dc
D_GOTO(out, rc = -DER_NOMEM);
}

dcs = &dct->dct_shards[tgt->ta_comp.co_index];
dcs = &dct->dct_shards[layout->ol_shards[i].po_index];

if (unlikely(isset(dct->dct_bitmap, tgt->ta_comp.co_index))) {
if (unlikely(isset(dct->dct_bitmap, layout->ol_shards[i].po_index))) {
/* More than one shards reside on the same vos target. */
D_ASSERT(dcs->dcs_nr >= 1);

Expand All @@ -5754,7 +5750,7 @@ obj_coll_punch_prep(struct obj_coll_punch_in *ocpi, struct dtx_coll_entry **p_dc
D_ASSERT(dcs->dcs_nr == 0);

dcs->dcs_buf = &dcs->dcs_inline;
setbit(dct->dct_bitmap, tgt->ta_comp.co_index);
setbit(dct->dct_bitmap, layout->ol_shards[i].po_index);
}

dcs->dcs_buf[dcs->dcs_nr++] = layout->ol_shards[i].po_shard;
Expand Down
2 changes: 2 additions & 0 deletions src/placement/jump_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ get_object_layout(struct pl_jump_map *jmap, uint32_t layout_ver, struct pl_obj_l
layout->ol_shards[k].po_target = target->ta_comp.co_id;
layout->ol_shards[k].po_fseq = target->ta_comp.co_fseq;
layout->ol_shards[k].po_shard = k;
layout->ol_shards[k].po_rank = target->ta_comp.co_rank;
layout->ol_shards[k].po_index = target->ta_comp.co_index;

/** If target is failed queue it for remap*/
if (need_remap_comp(&target->ta_comp, allow_status)) {
Expand Down
2 changes: 2 additions & 0 deletions src/placement/pl_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct failed_shard {
uint32_t fs_shard_idx;
uint32_t fs_fseq;
uint32_t fs_tgt_id;
uint16_t fs_rank;
uint8_t fs_index;
uint8_t fs_status;
};

Expand Down
6 changes: 6 additions & 0 deletions src/placement/pl_map_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ remap_alloc_one(d_list_t *remap_list, unsigned int shard_idx,
D_INIT_LIST_HEAD(&f_new->fs_list);
f_new->fs_shard_idx = shard_idx;
f_new->fs_fseq = tgt->ta_comp.co_fseq;
f_new->fs_rank = tgt->ta_comp.co_rank;
f_new->fs_index = tgt->ta_comp.co_index;
f_new->fs_status = tgt->ta_comp.co_status;
f_new->fs_data = data;

Expand Down Expand Up @@ -321,6 +323,8 @@ determine_valid_spares(struct pool_target *spare_tgt, struct daos_obj_md *md,
/* The selected spare target is up and ready */
l_shard->po_target = spare_tgt->ta_comp.co_id;
l_shard->po_fseq = f_shard->fs_fseq;
l_shard->po_rank = spare_tgt->ta_comp.co_rank;
l_shard->po_index = spare_tgt->ta_comp.co_index;

/*
* Mark the shard as 'rebuilding' so that read will
Expand Down Expand Up @@ -421,6 +425,8 @@ pl_map_extend(struct pl_obj_layout *layout, d_list_t *extended_list)
new_shards[grp_idx].po_fseq = f_shard->fs_fseq;
new_shards[grp_idx].po_shard = f_shard->fs_shard_idx;
new_shards[grp_idx].po_target = f_shard->fs_tgt_id;
new_shards[grp_idx].po_rank = f_shard->fs_rank;
new_shards[grp_idx].po_index = f_shard->fs_index;
if (f_shard->fs_status != PO_COMP_ST_DRAIN)
new_shards[grp_idx].po_rebuilding = 1;

Expand Down
6 changes: 4 additions & 2 deletions src/placement/ring_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,9 +1076,11 @@ ring_obj_layout_fill(struct pl_map *map, struct daos_obj_md *md,
pos = plts[idx].pt_pos;

tgt = &tgts[pos];
layout->ol_shards[k].po_shard = rop->rop_shard_id + k;
layout->ol_shards[k].po_shard = rop->rop_shard_id + k;
layout->ol_shards[k].po_target = tgt->ta_comp.co_id;
layout->ol_shards[k].po_fseq = tgt->ta_comp.co_fseq;
layout->ol_shards[k].po_fseq = tgt->ta_comp.co_fseq;
layout->ol_shards[k].po_rank = tgt->ta_comp.co_rank;
layout->ol_shards[k].po_index = tgt->ta_comp.co_index;

if (pool_target_unavail(tgt, for_reint)) {
rc = remap_alloc_one(remap_list, k, tgt, for_reint, NULL);
Expand Down

0 comments on commit 19a0fc8

Please sign in to comment.