Skip to content

Commit

Permalink
DAOS-8082 daos: fix various leak
Browse files Browse the repository at this point in the history
1. missing ivns reference put in crt_ivf_rpc_issue().

2. free btree root allocated in tree_cache_create_internal().

3. pool_target_addr_list is not freed in ds_pool_target_update_state().

4. free layout of reclaim in rebuild_obj_scan_cb().

5. Add crt_rank_abort_all() in server_fini() to abort all rpc before
cleanup to avoid race.

6. Missing collective req put for a few mgmt handler.

Signed-off-by: Di Wang <[email protected]>
  • Loading branch information
Di Wang committed Aug 2, 2021
1 parent 6e8af6c commit e452995
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 36 deletions.
2 changes: 2 additions & 0 deletions src/cart/crt_iv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,8 @@ crt_ivf_rpc_issue(d_rank_t dest_node, crt_iv_key_t *iv_key,
IV_DBG(iv_key, "added to kip_entry=%p\n", entry);
D_MUTEX_UNLOCK(&entry->kip_lock);
D_MUTEX_UNLOCK(&ivns_internal->cii_lock);
if (rc == 0)
IVNS_DECREF(ivns_internal);
return rc;
}
IV_DBG(iv_key, "kip_entry=%p present\n", entry);
Expand Down
1 change: 1 addition & 0 deletions src/engine/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ server_init(int argc, char *argv[])
static void
server_fini(bool force)
{
crt_rank_abort_all(NULL);
D_INFO("Service is shutting down\n");
crt_unregister_event_cb(dss_crt_event_cb, NULL);
D_INFO("unregister event callbacks done\n");
Expand Down
2 changes: 1 addition & 1 deletion src/include/daos_srv/daos_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ unsigned int dss_ctx_nr_get(void);

/* Cache for container root */
struct tree_cache_root {
struct btr_root btr_root;
struct btr_root *btr_root;
daos_handle_t root_hdl;
unsigned int count;
};
Expand Down
33 changes: 3 additions & 30 deletions src/mgmt/srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 17 additions & 4 deletions src/object/srv_obj_migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ 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));

D_FREE_PTR(root->btr_root);
return rc;
}

Expand Down Expand Up @@ -148,14 +148,14 @@ tree_cache_create_internal(daos_handle_t toh, unsigned int tree_class,

memset(&root, 0, sizeof(root));
root.root_hdl = DAOS_HDL_INVAL;
root.btr_root = broot;
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);
if (rc) {
D_ERROR("failed to create rebuild tree: "DF_RC"\n", DP_RC(rc));
D_FREE(broot);
D_GOTO(out, rc);
}

Expand All @@ -171,9 +171,13 @@ tree_cache_create_internal(daos_handle_t toh, unsigned int tree_class,

*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) {
if (daos_handle_is_valid(root.root_hdl))
dbtree_destroy(root.root_hdl, NULL);
D_FREE(broot);
}
return rc;
}

Expand Down Expand Up @@ -2785,6 +2789,15 @@ 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);
D_FREE_PTR(root->btr_root);
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,
Expand Down
3 changes: 2 additions & 1 deletion src/pool/srv_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3318,7 +3318,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;
Expand Down Expand Up @@ -3398,6 +3398,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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/rebuild/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ rebuild_cont_send_cb(daos_handle_t ih, d_iov_t *key_iov,
}

rc = dbtree_destroy(root->root_hdl, NULL);
D_FREE_PTR(root->btr_root);
if (rc) {
D_ERROR("dbtree_destroy failed: "DF_RC"\n", DP_RC(rc));
return rc;
Expand Down Expand Up @@ -524,6 +525,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;

Expand Down

0 comments on commit e452995

Please sign in to comment.