From a097c8289b51278d5ea9e32dbe7cf272de9a2638 Mon Sep 17 00:00:00 2001 From: Xuezhao Liu Date: Sat, 7 Dec 2024 08:31:58 +0000 Subject: [PATCH] DAOS-16170 cart: refine corpc fail handling for CRT_RPC_FLAG_CO_FAILOUT reset rc to 0 to avoid unnecessary RPC_DECREF in fail case in crt_req_send. Signed-off-by: Xuezhao Liu --- src/cart/crt_corpc.c | 15 ++++++++------- src/cart/crt_rpc.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cart/crt_corpc.c b/src/cart/crt_corpc.c index 5d7b6d79c6e3..ceae5c32da6e 100644 --- a/src/cart/crt_corpc.c +++ b/src/cart/crt_corpc.c @@ -777,6 +777,7 @@ crt_corpc_req_hdlr(struct crt_rpc_priv *rpc_priv) struct crt_opc_info *opc_info; struct crt_corpc_ops *co_ops; bool ver_match; + bool co_failout = false; int i, rc = 0; co_info = rpc_priv->crp_corpc_info; @@ -906,18 +907,18 @@ crt_corpc_req_hdlr(struct crt_rpc_priv *rpc_priv) } forward_done: - if (rc != 0 && rpc_priv->crp_flags & CRT_RPC_FLAG_CO_FAILOUT) { - crt_corpc_complete(rpc_priv); - goto out; - } + if (rc != 0 && rpc_priv->crp_flags & CRT_RPC_FLAG_CO_FAILOUT) + co_failout = true; /* NOOP bcast (no child and root excluded) */ - if (co_info->co_child_num == 0 && co_info->co_root_excluded) + if (co_info->co_child_num == 0 && (co_info->co_root_excluded || co_failout)) crt_corpc_complete(rpc_priv); - if (co_info->co_root_excluded == 1) { + if (co_info->co_root_excluded == 1 || co_failout) { if (co_info->co_grp_priv->gp_self == co_info->co_root) { - /* don't return error for root */ + /* don't return error for root to avoid RPC_DECREF in + * fail case in crt_req_send. + */ rc = 0; } D_GOTO(out, rc); diff --git a/src/cart/crt_rpc.c b/src/cart/crt_rpc.c index 575f653d6c83..b9effbeb9ce3 100644 --- a/src/cart/crt_rpc.c +++ b/src/cart/crt_rpc.c @@ -1532,7 +1532,7 @@ crt_req_send(crt_rpc_t *req, crt_cb_t complete_cb, void *arg) /* failure already reported through complete cb */ if (complete_cb != NULL) rc = 0; - } else if (!crt_rpc_completed(rpc_priv)) { + } else { RPC_DECREF(rpc_priv); } }