From 54ef5e1e470d02bcd0603b81fecdf008b57cb7fa Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Fri, 26 Jul 2024 20:47:49 +0800 Subject: [PATCH] DAOS-15914: I/O context takes refcount on RPC - I/O context takes refcount on RPC - only release input buffer for target update Signed-off-by: Liang Zhen --- src/object/srv_obj.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/object/srv_obj.c b/src/object/srv_obj.c index c62012205d7..f220149a532 100644 --- a/src/object/srv_obj.c +++ b/src/object/srv_obj.c @@ -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); @@ -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 { @@ -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); @@ -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: @@ -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); } @@ -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); } @@ -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); } @@ -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); @@ -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)); @@ -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)); } @@ -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)); } @@ -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)); } @@ -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)); @@ -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)); } @@ -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));