From caa1f84e1c516310c570ec49703731e750e07735 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Mon, 6 Sep 2021 08:38:43 -0400 Subject: [PATCH] lib/idxd: Fix the idxd_ops resource exhaustion in chan->ops_pool The issue is that: We call cb_fn firstly, then add the related idxd_ops into the chan->ops_list. Then if in user's callback, we call spdk_idxd_submit_* function gain, then we will allocate new idxd_opts first. So if there is recursive spdk_idxd_submit_* in the call back function, then we will exhaust all the ops_pool resources. And the function will report -EBUSY issue in _idxd_prep_command function. And this patch fixes this issue by adding back idxd_ops before calling user's call_cb function. Change-Id: I32239fb29be875bc452803a48dc24ff5fa533016 Signed-off-by: Ziye Yang Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9401 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- lib/idxd/idxd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index a6b5394d5..8ba085df1 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -1108,6 +1108,8 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan) struct idxd_ops *op, *tmp; int status = 0; int rc = 0; + void *cb_arg; + spdk_idxd_req_cb cb_fn; assert(chan != NULL); @@ -1144,17 +1146,21 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan) break; } - if (op->cb_fn) { - op->cb_fn(op->cb_arg, status); - } - - op->hw.status = status = 0; - + cb_fn = op->cb_fn; + cb_arg = op->cb_arg; + op->hw.status = 0; if (op->desc->opcode == IDXD_OPCODE_BATCH) { _free_batch(op->batch, chan); } else if (op->batch == NULL) { TAILQ_INSERT_TAIL(&chan->ops_pool, op, link); } + + if (cb_fn) { + cb_fn(cb_arg, status); + } + + /* reset the status */ + status = 0; } else { /* * oldest locations are at the head of the list so if