Commit caa1f84e authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

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: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9401


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 43299f39
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -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