diff --git a/src/cart/crt_iv.c b/src/cart/crt_iv.c index 9c36164b57e..ff96424ec7a 100644 --- a/src/cart/crt_iv.c +++ b/src/cart/crt_iv.c @@ -344,7 +344,6 @@ crt_ivf_pending_request_add(struct crt_ivns_internal *ivns_internal, iv_ops->ivo_on_put(ivns_internal, &iv_info->ifc_iv_value, iv_info->ifc_user_priv); - IVNS_ADDREF(iv_info->ifc_ivns_internal); pending_fetch->pf_cb_info = iv_info; d_list_add_tail(&pending_fetch->pf_link, diff --git a/src/cart/crt_swim.c b/src/cart/crt_swim.c index db98e894f18..2ae197fabb0 100644 --- a/src/cart/crt_swim.c +++ b/src/cart/crt_swim.c @@ -289,6 +289,7 @@ static void crt_swim_srv_cb(crt_rpc_t *rpc) rpc_out->rc = rc; rpc_out->pad = 0; rc = crt_reply_send(rpc); + D_FREE(rpc_out->upds.ca_arrays); if (rc) D_TRACE_ERROR(rpc, "send reply: "DF_RC" failed: "DF_RC"\n", DP_RC(rpc_out->rc), DP_RC(rc)); @@ -514,6 +515,7 @@ static int crt_swim_send_reply(struct swim_context *ctx, swim_id_t from, * So, we need to decrement reference. * Was incremented in crt_swim_srv_cb(). */ + D_FREE(rpc_out->upds.ca_arrays); rpc_priv = container_of(rpc, struct crt_rpc_priv, crp_pub); RPC_DECREF(rpc_priv); return rc; diff --git a/src/container/srv_target.c b/src/container/srv_target.c index b00b910a6e2..8ee24a5c30c 100644 --- a/src/container/srv_target.c +++ b/src/container/srv_target.c @@ -749,7 +749,7 @@ cont_child_free_ref(struct daos_llink *llink) vos_cont_close(cont->sc_hdl); ds_pool_child_put(cont->sc_pool); daos_csummer_destroy(&cont->sc_csummer); - + D_FREE(cont->sc_snapshots); ABT_cond_free(&cont->sc_dtx_resync_cond); ABT_mutex_free(&cont->sc_mutex); D_FREE(cont); diff --git a/src/mgmt/srv.c b/src/mgmt/srv.c index 0c8478cc17b..b3ebc5a013c 100644 --- a/src/mgmt/srv.c +++ b/src/mgmt/srv.c @@ -212,17 +212,8 @@ ds_mgmt_params_set_hdlr(crt_rpc_t *rpc) tc_in->tps_value_extra = ps_in->ps_value_extra; rc = dss_rpc_send(tc_req); - if (rc != 0) { - crt_req_decref(tc_req); - D_GOTO(out, rc); - } - out = crt_reply_get(tc_req); - rc = out->srv_rc; - if (rc != 0) { - crt_req_decref(tc_req); - D_GOTO(out, rc); - } + crt_req_decref(tc_req); out: out = crt_reply_get(rpc); out->srv_rc = rc; @@ -262,17 +253,8 @@ ds_mgmt_profile_hdlr(crt_rpc_t *rpc) tc_in->p_op = in->p_op; tc_in->p_avg = in->p_avg; rc = dss_rpc_send(tc_req); - if (rc != 0) { - crt_req_decref(tc_req); - D_GOTO(out, rc); - } - out = crt_reply_get(tc_req); - rc = out->p_rc; - if (rc != 0) { - crt_req_decref(tc_req); - D_GOTO(out, rc); - } + crt_req_decref(tc_req); out: D_DEBUG(DB_MGMT, "profile hdlr: rc "DF_RC"\n", DP_RC(rc)); out = crt_reply_get(rpc); @@ -310,17 +292,8 @@ ds_mgmt_mark_hdlr(crt_rpc_t *rpc) tc_in->m_mark = in->m_mark; rc = dss_rpc_send(tc_req); - if (rc != 0) { - crt_req_decref(tc_req); - D_GOTO(out, rc); - } - out = crt_reply_get(tc_req); - rc = out->m_rc; - if (rc != 0) { - crt_req_decref(tc_req); - D_GOTO(out, rc); - } + crt_req_decref(tc_req); out: D_DEBUG(DB_MGMT, "mark hdlr: rc "DF_RC"\n", DP_RC(rc)); out = crt_reply_get(rpc); diff --git a/src/mgmt/srv_pool.c b/src/mgmt/srv_pool.c index d605ee24ea7..300ba5e7785 100644 --- a/src/mgmt/srv_pool.c +++ b/src/mgmt/srv_pool.c @@ -89,7 +89,7 @@ ds_mgmt_tgt_pool_create_ranks(uuid_t pool_uuid, char *tgt_dev, crt_rpc_t *tc_req; crt_opcode_t opc; struct mgmt_tgt_create_in *tc_in; - struct mgmt_tgt_create_out *tc_out; + struct mgmt_tgt_create_out *tc_out = NULL; d_rank_t *tc_out_ranks; uuid_t *tc_out_uuids; unsigned int i; @@ -162,12 +162,14 @@ ds_mgmt_tgt_pool_create_ranks(uuid_t pool_uuid, char *tgt_dev, D_DEBUG(DB_TRACE, "fill ranks %d idx %d "DF_UUID"\n", tc_out_ranks[i], idx, DP_UUID(tc_out_uuids[i])); } - D_FREE(tc_out->tc_tgt_uuids.ca_arrays); - D_FREE(tc_out->tc_ranks.ca_arrays); - rc = DER_SUCCESS; decref: + if (tc_out) { + D_FREE(tc_out->tc_tgt_uuids.ca_arrays); + D_FREE(tc_out->tc_ranks.ca_arrays); + } + crt_req_decref(tc_req); if (rc) { rc_cleanup = ds_mgmt_tgt_pool_destroy_ranks(pool_uuid, diff --git a/src/object/cli_ec.c b/src/object/cli_ec.c index 7c85e6b7882..6c1c29acddc 100644 --- a/src/object/cli_ec.c +++ b/src/object/cli_ec.c @@ -2214,7 +2214,7 @@ obj_ec_recov_task_fini(struct obj_reasb_req *reasb_req) struct obj_ec_fail_info *fail_info = reasb_req->orr_fail; uint32_t i; - for (i = 0; i < fail_info->efi_nrecx_lists; i++) + for (i = 0; i < fail_info->efi_stripe_sgls_nr; i++) d_sgl_fini(&fail_info->efi_stripe_sgls[i], true); D_FREE(fail_info->efi_stripe_sgls); @@ -2250,6 +2250,7 @@ obj_ec_recov_task_init(struct obj_reasb_req *reasb_req, daos_obj_id_t oid, D_ALLOC_ARRAY(fail_info->efi_stripe_sgls, iod_nr); if (fail_info->efi_stripe_sgls == NULL) D_GOTO(out, rc = -DER_NOMEM); + fail_info->efi_stripe_sgls_nr = iod_nr; recx_ep_nr = 0; for (i = 0; i < iod_nr; i++) { diff --git a/src/object/cli_obj.c b/src/object/cli_obj.c index 94b3d570c2e..f484e4674af 100644 --- a/src/object/cli_obj.c +++ b/src/object/cli_obj.c @@ -367,6 +367,7 @@ obj_layout_create(struct dc_object *obj, bool refresh) obj_shard = &obj->cob_shards->do_shards[i]; obj_shard->do_shard = layout->ol_shards[i].po_shard; + obj_shard->do_shard_idx = i; obj_shard->do_target_id = layout->ol_shards[i].po_target; obj_shard->do_fseq = layout->ol_shards[i].po_fseq; obj_shard->do_rebuilding = layout->ol_shards[i].po_rebuilding; @@ -1516,6 +1517,7 @@ dc_obj_layout_get(daos_handle_t oh, struct daos_obj_layout **p_layout) } *p_layout = layout; out: + obj_decref(obj); if (rc && layout != NULL) daos_obj_layout_free(layout); return rc; @@ -5610,6 +5612,8 @@ dc_obj_verify(daos_handle_t oh, daos_epoch_t *epochs, unsigned int nr) if (dova[i].list_buf != dova[i].inline_buf) D_FREE(dova[i].list_buf); + daos_iov_free(&dova[i].cursor.dkey); + daos_iov_free(&dova[i].cursor.iod.iod_name); D_FREE(dova[i].fetch_buf); } diff --git a/src/object/cli_shard.c b/src/object/cli_shard.c index 9d512a8c11b..8bdc41782da 100644 --- a/src/object/cli_shard.c +++ b/src/object/cli_shard.c @@ -21,7 +21,7 @@ static inline struct dc_obj_layout * obj_shard2layout(struct dc_obj_shard *shard) { return container_of(shard, struct dc_obj_layout, - do_shards[shard->do_shard]); + do_shards[shard->do_shard_idx]); } void @@ -80,7 +80,7 @@ dc_obj_shard_open(struct dc_object *obj, daos_unit_oid_t oid, shard->do_target_idx = map_tgt->ta_comp.co_index; shard->do_obj = obj; shard->do_co_hdl = obj->cob_coh; - obj_shard_addref(shard); + obj_shard_addref(shard); /* release this until obj_layout_free */ D_SPIN_LOCK(&obj->cob_spin); obj->cob_shards->do_open_count++; diff --git a/src/object/obj_ec.h b/src/object/obj_ec.h index d6cb739f508..1367991742b 100644 --- a/src/object/obj_ec.h +++ b/src/object/obj_ec.h @@ -249,6 +249,7 @@ struct obj_ec_fail_info { * it contains ((k + p) * cell_byte_size) memory. */ d_sg_list_t *efi_stripe_sgls; + uint32_t efi_stripe_sgls_nr; /* For each daos_recx_ep in efi_stripe_lists will create one recovery * task to fetch the data from servers. */ diff --git a/src/object/obj_internal.h b/src/object/obj_internal.h index f28561cc85b..4e1e922e283 100644 --- a/src/object/obj_internal.h +++ b/src/object/obj_internal.h @@ -50,15 +50,16 @@ extern unsigned int srv_io_mode; struct dc_obj_shard { /** refcount */ unsigned int do_ref; + uint32_t do_target_rank; /** object id */ daos_unit_oid_t do_id; /** container handler of the object */ daos_handle_t do_co_hdl; - uint8_t do_target_idx; /* target VOS index in node */ - uint32_t do_target_rank; struct pl_obj_shard do_pl_shard; /** point back to object */ struct dc_object *do_obj; + uint32_t do_shard_idx; + uint8_t do_target_idx; /* target VOS index in node */ }; #define do_shard do_pl_shard.po_shard diff --git a/src/object/srv_obj_migrate.c b/src/object/srv_obj_migrate.c index b75c1b671bd..7311a514cf1 100644 --- a/src/object/srv_obj_migrate.c +++ b/src/object/srv_obj_migrate.c @@ -109,7 +109,6 @@ obj_tree_destory_cb(daos_handle_t ih, d_iov_t *key_iov, if (rc) D_ERROR("dbtree_destroy, cont "DF_UUID" failed: "DF_RC"\n", DP_UUID(*(uuid_t *)key_iov->iov_buf), DP_RC(rc)); - return rc; } @@ -131,64 +130,47 @@ obj_tree_destroy(daos_handle_t btr_hdl) return rc; } -/* Create tree root by key_iov */ static int -tree_cache_create_internal(daos_handle_t toh, unsigned int tree_class, - d_iov_t *key_iov, struct tree_cache_root **rootp) +container_tree_create(daos_handle_t toh, uuid_t uuid, + struct tree_cache_root **rootp) { + d_iov_t key_iov; d_iov_t val_iov; struct umem_attr uma; - struct tree_cache_root root; - struct btr_root *broot; + struct tree_cache_root root = { 0 }; + struct tree_cache_root *tmp_root; int rc; - D_ALLOC_PTR(broot); - if (broot == NULL) - return -DER_NOMEM; + d_iov_set(&key_iov, uuid, sizeof(uuid_t)); + d_iov_set(&val_iov, &root, sizeof(root)); + rc = dbtree_update(toh, &key_iov, &val_iov); + if (rc) + return rc; + + d_iov_set(&val_iov, NULL, 0); + rc = dbtree_lookup(toh, &key_iov, &val_iov); + if (rc) + D_GOTO(out, rc); + + tmp_root = val_iov.iov_buf; - memset(&root, 0, sizeof(root)); - root.root_hdl = DAOS_HDL_INVAL; memset(&uma, 0, sizeof(uma)); uma.uma_id = UMEM_CLASS_VMEM; - - rc = dbtree_create_inplace(tree_class, BTR_FEAT_DIRECT_KEY, 32, - &uma, broot, &root.root_hdl); + rc = dbtree_create_inplace(DBTREE_CLASS_NV, BTR_FEAT_DIRECT_KEY, 32, + &uma, &tmp_root->btr_root, &tmp_root->root_hdl); if (rc) { D_ERROR("failed to create rebuild tree: "DF_RC"\n", DP_RC(rc)); - D_FREE(broot); D_GOTO(out, rc); } - d_iov_set(&val_iov, &root, sizeof(root)); - rc = dbtree_update(toh, key_iov, &val_iov); - if (rc) - D_GOTO(out, rc); + *rootp = tmp_root; - d_iov_set(&val_iov, NULL, 0); - rc = dbtree_lookup(toh, key_iov, &val_iov); - if (rc) - D_GOTO(out, rc); - - *rootp = val_iov.iov_buf; - D_ASSERT(*rootp != NULL); out: - if (rc < 0 && daos_handle_is_valid(root.root_hdl)) - dbtree_destroy(root.root_hdl, NULL); + if (rc < 0) + dbtree_delete(toh, BTR_PROBE_EQ, &key_iov, NULL); return rc; } -static int -container_tree_create(daos_handle_t toh, uuid_t uuid, - struct tree_cache_root **rootp) -{ - d_iov_t key_iov; - - d_iov_set(&key_iov, uuid, sizeof(uuid_t)); - - return tree_cache_create_internal(toh, DBTREE_CLASS_NV, &key_iov, - rootp); -} - int obj_tree_lookup(daos_handle_t toh, uuid_t co_uuid, daos_unit_oid_t oid, d_iov_t *val_iov) @@ -2796,6 +2778,14 @@ migrate_cont_iter_cb(daos_handle_t ih, d_iov_t *key_iov, D_DEBUG(DB_REBUILD, "iter cont "DF_UUID"/%"PRIx64" finish.\n", DP_UUID(cont_uuid), ih.cookie); + rc = dbtree_destroy(root->root_hdl, NULL); + if (rc) { + /* Ignore the DRAM migrate object tree for the moment, since + * it does not impact the migration on the storage anyway + */ + D_ERROR("dbtree_destroy failed: "DF_RC"\n", DP_RC(rc)); + } + /* Snapshot fetch will yield the ULT, let's reprobe before delete */ d_iov_set(&tmp_iov, cont_uuid, sizeof(uuid_t)); rc = dbtree_iter_probe(ih, BTR_PROBE_EQ, DAOS_INTENT_MIGRATION, diff --git a/src/pool/srv_pool.c b/src/pool/srv_pool.c index 09ab677e2aa..df5779053c4 100644 --- a/src/pool/srv_pool.c +++ b/src/pool/srv_pool.c @@ -3310,7 +3310,7 @@ ds_pool_target_update_state(uuid_t pool_uuid, d_rank_list_t *ranks, crt_endpoint_t ep; struct dss_module_info *info = dss_get_module_info(); crt_rpc_t *rpc; - struct pool_target_addr_list list; + struct pool_target_addr_list list = { 0 }; struct pool_add_in *in; struct pool_add_out *out; crt_opcode_t opcode; @@ -3390,6 +3390,7 @@ ds_pool_target_update_state(uuid_t pool_uuid, d_rank_list_t *ranks, out_rpc: crt_req_decref(rpc); out_client: + pool_target_addr_list_free(&list); rsvc_client_fini(&client); return rc; } diff --git a/src/rebuild/scan.c b/src/rebuild/scan.c index 4bb1675732c..12e926c390c 100644 --- a/src/rebuild/scan.c +++ b/src/rebuild/scan.c @@ -524,6 +524,7 @@ rebuild_obj_scan_cb(daos_handle_t ch, vos_iter_entry_t *ent, still_needed = pl_obj_layout_contains(rpt->rt_pool->sp_map, layout, myrank, mytarget, oid.id_shard); + pl_obj_layout_free(layout); if (!still_needed) { struct rebuild_pool_tls *tls;