Commit e1d1df9e authored by Konrad Sztyber's avatar Konrad Sztyber
Browse files

nvme: check process when completing error injected requests



Obviously, requests need to be completed in the process that submitted
them.  However, if one process injects an error to the admin queue while
the other process is polling it, a request with injected errors could be
completed in the wrong process.  To avoid that, we now check the pid of
the process that submitted it before completing it.

Fixes: #3495

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ifce5b0cb5dce8adadbae7f3eeb10f019cfd73f0b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24790


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 87696292
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -785,7 +785,8 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
	/* error injection for those queued error requests */
	if (spdk_unlikely(!STAILQ_EMPTY(&qpair->err_req_head))) {
		STAILQ_FOREACH_SAFE(req, &qpair->err_req_head, stailq, tmp) {
			if (spdk_get_ticks() - req->submit_tick > req->timeout_tsc) {
			if (req->pid == getpid() &&
			    spdk_get_ticks() - req->submit_tick > req->timeout_tsc) {
				STAILQ_REMOVE(&qpair->err_req_head, req, nvme_request, stailq);
				nvme_qpair_manual_complete_request(qpair, req,
								   req->cpl.status.sct,
@@ -913,6 +914,7 @@ nvme_qpair_complete_error_reqs(struct spdk_nvme_qpair *qpair)

	while (!STAILQ_EMPTY(&qpair->err_req_head)) {
		req = STAILQ_FIRST(&qpair->err_req_head);
		assert(req->pid == getpid());
		STAILQ_REMOVE_HEAD(&qpair->err_req_head, stailq);
		nvme_qpair_manual_complete_request(qpair, req,
						   req->cpl.status.sct,
+1 −0
Original line number Diff line number Diff line
@@ -673,6 +673,7 @@ test_nvme_qpair_init_deinit(void)
		/* Check requests address alignment */
		CU_ASSERT((uint64_t)var_req % 64 == 0);
		CU_ASSERT(var_req->qpair == &qpair);
		var_req->pid = getpid();
		reqs[i++] = var_req;
	}
	CU_ASSERT(i == 3);