Skip to content

Commit

Permalink
DAOS-6628 dtx: code style issues found by coverity
Browse files Browse the repository at this point in the history
To avoid being reported as coverity defects.

Signed-off-by: Fan Yong <[email protected]>
  • Loading branch information
Nasf-Fan committed Feb 2, 2021
1 parent ae487bd commit ecbf367
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
37 changes: 20 additions & 17 deletions src/object/srv_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ obj_set_reply_sizes(crt_rpc_t *rpc, daos_iod_t *iods, int iod_nr)
/* Re-entry case.*/
if (orwo->orw_iod_sizes.ca_count != 0) {
D_ASSERT(orwo->orw_iod_sizes.ca_count == iod_nr);
D_ASSERT(orwo->orw_iod_sizes.ca_arrays != NULL);

sizes = orwo->orw_iod_sizes.ca_arrays;
} else {
D_ALLOC_ARRAY(sizes, iod_nr);
if (sizes == NULL)
Expand Down Expand Up @@ -2872,7 +2875,7 @@ obj_local_punch(struct obj_punch_in *opi, crt_opcode_t opc,
D_GOTO(out, rc = -DER_NOSYS);
}

if (obj_dtx_need_refresh(dth, rc)) {
if (dth != NULL && obj_dtx_need_refresh(dth, rc)) {
rc = dtx_refresh(dth, ioc->ioc_coc);
if (rc == -DER_AGAIN)
goto again;
Expand Down Expand Up @@ -4006,8 +4009,8 @@ obj_obj_dtx_leader(struct dtx_leader_handle *dlh, void *arg, int idx,
static int
ds_obj_dtx_leader_prep_handle(struct daos_cpd_sub_head *dcsh,
struct daos_cpd_sub_req *dcsrs,
struct daos_shard_tgt *tgts, uint32_t tgt_cnt,
uint32_t req_cnt, uint32_t *flags)
struct daos_shard_tgt *tgts,
int tgt_cnt, int req_cnt, uint32_t *flags)
{
int rc = 0;
int i;
Expand Down Expand Up @@ -4046,20 +4049,20 @@ ds_obj_dtx_leader_prep_handle(struct daos_cpd_sub_head *dcsh,
static void
ds_obj_dtx_leader_ult(void *arg)
{
struct daos_cpd_args *dca = arg;
struct dtx_leader_handle dlh;
struct ds_obj_exec_arg exec_arg;
struct obj_cpd_in *oci = crt_req_get(dca->dca_rpc);
struct obj_cpd_out *oco = crt_reply_get(dca->dca_rpc);
struct daos_cpd_sub_head *dcsh;
struct daos_cpd_disp_ent *dcde;
struct daos_cpd_sub_req *dcsrs = NULL;
struct daos_shard_tgt *tgts;
uint32_t flags = 0;
uint32_t dtx_flags = DTX_DIST;
uint32_t tgt_cnt = 0;
uint32_t req_cnt = 0;
int rc = 0;
struct daos_cpd_args *dca = arg;
struct dtx_leader_handle dlh;
struct ds_obj_exec_arg exec_arg;
struct obj_cpd_in *oci = crt_req_get(dca->dca_rpc);
struct obj_cpd_out *oco = crt_reply_get(dca->dca_rpc);
struct daos_cpd_sub_head *dcsh;
struct daos_cpd_disp_ent *dcde;
struct daos_cpd_sub_req *dcsrs = NULL;
struct daos_shard_tgt *tgts;
uint32_t flags = 0;
uint32_t dtx_flags = DTX_DIST;
int tgt_cnt = 0;
int req_cnt = 0;
int rc = 0;

/* TODO: For the daos targets in the first redundancy (modification)
* group, they are the DTX leader candidates when DTX recovery.
Expand Down
24 changes: 18 additions & 6 deletions src/vos/vos_dtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,8 +2110,11 @@ vos_dtx_aggregate(daos_handle_t coh)
dce = d_list_entry(cont->vc_dtx_committed_list.next,
struct vos_dtx_cmt_ent, dce_committed_link);
d_iov_set(&kiov, &DCE_XID(dce), sizeof(DCE_XID(dce)));
dbtree_delete(cont->vc_dtx_committed_hdl, BTR_PROBE_EQ,
&kiov, NULL);
rc = dbtree_delete(cont->vc_dtx_committed_hdl, BTR_PROBE_EQ,
&kiov, NULL);
if (rc != 0)
D_WARN("Failed to remove cmt DTX entry: "DF_RC"\n",
DP_RC(rc));
}

tmp = umem_off2ptr(umm, dbd->dbd_next);
Expand Down Expand Up @@ -2565,10 +2568,19 @@ vos_dtx_cache_reset(daos_handle_t coh)
cont = vos_hdl2cont(coh);
D_ASSERT(cont != NULL);

if (daos_handle_is_valid(cont->vc_dtx_active_hdl))
dbtree_destroy(cont->vc_dtx_active_hdl, NULL);
if (daos_handle_is_valid(cont->vc_dtx_committed_hdl))
dbtree_destroy(cont->vc_dtx_committed_hdl, NULL);
if (daos_handle_is_valid(cont->vc_dtx_active_hdl)) {
rc = dbtree_destroy(cont->vc_dtx_active_hdl, NULL);
if (rc != 0)
D_WARN("Failed to destroy act DTX tree: "DF_RC"\n",
DP_RC(rc));
}

if (daos_handle_is_valid(cont->vc_dtx_committed_hdl)) {
rc = dbtree_destroy(cont->vc_dtx_committed_hdl, NULL);
if (rc != 0)
D_WARN("Failed to destroy cmt DTX tree: "DF_RC"\n",
DP_RC(rc));
}

if (cont->vc_dtx_array)
lrua_array_free(cont->vc_dtx_array);
Expand Down

0 comments on commit ecbf367

Please sign in to comment.