Skip to content

Commit

Permalink
DAOS-15914: I/O context takes refcount on RPC
Browse files Browse the repository at this point in the history
- I/O context takes refcount on RPC
- only release input buffer for target update

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
  • Loading branch information
gnailzenh authored and mjean308 committed Sep 23, 2024
1 parent 6c48981 commit 54ef5e1
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/object/srv_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ obj_rw_complete(crt_rpc_t *rpc, struct obj_io_context *ioc,
}

static void
obj_rw_reply(crt_rpc_t *rpc, int status, uint64_t epoch,
obj_rw_reply(crt_rpc_t *rpc, int status, uint64_t epoch, bool release_input,
struct obj_io_context *ioc)
{
struct obj_rw_out *orwo = crt_reply_get(rpc);
Expand All @@ -187,7 +187,11 @@ obj_rw_reply(crt_rpc_t *rpc, int status, uint64_t epoch,
ioc->ioc_map_ver, orwo->orw_epoch, status);

if (!ioc->ioc_lost_reply) {
rc = crt_reply_send_input_free(rpc);
if (release_input)
rc = crt_reply_send_input_free(rpc);
else
rc = crt_reply_send(rpc);

if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));
} else {
Expand Down Expand Up @@ -2079,6 +2083,8 @@ obj_ioc_init(uuid_t pool_uuid, uuid_t coh_uuid, uuid_t cont_uuid, crt_rpc_t *rpc

D_ASSERT(ioc != NULL);
memset(ioc, 0, sizeof(*ioc));

crt_req_addref(rpc);
ioc->ioc_rpc = rpc;
ioc->ioc_opc = opc_get(rpc->cr_opc);
rc = ds_cont_find_hdl(pool_uuid, coh_uuid, &coh);
Expand Down Expand Up @@ -2154,6 +2160,10 @@ obj_ioc_fini(struct obj_io_context *ioc, int err)
ds_cont_child_put(ioc->ioc_coc);
ioc->ioc_coc = NULL;
}
if (ioc->ioc_rpc) {
crt_req_decref(ioc->ioc_rpc);
ioc->ioc_rpc = NULL;
}
}

/* Setup lite IO context, it is only for compound RPC so far:
Expand Down Expand Up @@ -2508,7 +2518,7 @@ ds_obj_ec_rep_handler(crt_rpc_t *rpc)
rc = vos_obj_array_remove(ioc.ioc_coc->sc_hdl, oer->er_oid, &oer->er_epoch_range, dkey,
&iod->iod_name, &recx);
out:
obj_rw_reply(rpc, rc, 0, &ioc);
obj_rw_reply(rpc, rc, 0, false, &ioc);
obj_ioc_end(&ioc, rc);
}

Expand Down Expand Up @@ -2604,7 +2614,7 @@ ds_obj_ec_agg_handler(crt_rpc_t *rpc)
D_ERROR(DF_UOID ": array_remove failed: " DF_RC "\n", DP_UOID(oea->ea_oid),
DP_RC(rc1));
out:
obj_rw_reply(rpc, rc, 0, &ioc);
obj_rw_reply(rpc, rc, 0, false, &ioc);
obj_ioc_end(&ioc, rc);
}

Expand Down Expand Up @@ -2733,7 +2743,7 @@ ds_obj_tgt_update_handler(crt_rpc_t *rpc)
out:
if (dth != NULL)
rc = dtx_end(dth, ioc.ioc_coc, rc);
obj_rw_reply(rpc, rc, 0, &ioc);
obj_rw_reply(rpc, rc, 0, true, &ioc);
D_FREE(mbs);
obj_ioc_end(&ioc, rc);
}
Expand Down Expand Up @@ -3073,7 +3083,7 @@ ds_obj_rw_handler(crt_rpc_t *rpc)
if (ioc.ioc_map_ver < max_ver)
ioc.ioc_map_ver = max_ver;

obj_rw_reply(rpc, rc, epoch.oe_value, &ioc);
obj_rw_reply(rpc, rc, epoch.oe_value, false, &ioc);
D_FREE(mbs);
D_FREE(dti_cos);
obj_ioc_end(&ioc, rc);
Expand All @@ -3093,7 +3103,7 @@ obj_enum_complete(crt_rpc_t *rpc, int status, int map_version,
obj_reply_map_version_set(rpc, map_version);
oeo->oeo_epoch = epoch;

rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));

Expand Down Expand Up @@ -3454,7 +3464,7 @@ obj_punch_complete(crt_rpc_t *rpc, int status, uint32_t map_version)
obj_reply_set_status(rpc, status);
obj_reply_map_version_set(rpc, map_version);

rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));
}
Expand Down Expand Up @@ -4243,7 +4253,7 @@ ds_obj_query_key_handler(crt_rpc_t *rpc)
obj_reply_map_version_set(rpc, version);
okqo->okqo_epoch = okqi->okqi_epoch;

rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));
}
Expand Down Expand Up @@ -4287,7 +4297,7 @@ ds_obj_sync_handler(crt_rpc_t *rpc)
D_DEBUG(DB_IO, "obj_sync stop: "DF_UOID", epc "DF_X64", rd = %d\n",
DP_UOID(osi->osi_oid), oso->oso_epoch, rc);

rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));
}
Expand Down Expand Up @@ -4379,7 +4389,7 @@ obj_cpd_reply(crt_rpc_t *rpc, int status, uint32_t map_version)
D_DEBUG(DB_TRACE, "CPD rpc %p send reply, pmv %d, status %d.\n",
rpc, map_version, status);

rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("Send CPD reply failed: "DF_RC"\n", DP_RC(rc));

Expand Down Expand Up @@ -5573,7 +5583,7 @@ ds_obj_key2anchor_handler(crt_rpc_t *rpc)
obj_reply_set_status(rpc, rc);
obj_reply_map_version_set(rpc, ioc.ioc_map_ver);
obj_ioc_end(&ioc, rc);
rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));
}
Expand Down Expand Up @@ -5911,7 +5921,7 @@ ds_obj_coll_query_handler(crt_rpc_t *rpc)
ocqo->ocqo_flags |= OCRF_RAW_RECX;
}

rc = crt_reply_send_input_free(rpc);
rc = crt_reply_send(rpc);
if (rc != 0)
D_ERROR("send reply failed: "DF_RC"\n", DP_RC(rc));

Expand Down

0 comments on commit 54ef5e1

Please sign in to comment.