Commit 17c821a8 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

nvmf: move out calling nvmf_ns_update_reservation_info()



This allows to have it called from one place instead of three.

Change-Id: I847ae756cb5fb2a76e1740ec24f549f017534806
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21356


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent c6a78e83
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -2831,12 +2831,6 @@ nvmf_ns_reservation_register(struct spdk_nvmf_ns *ns,
	}

exit:
	if (update_sgroup) {
		rc = nvmf_ns_update_reservation_info(ns);
		if (rc != 0) {
			status = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
		}
	}
	req->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
	req->rsp->nvme_cpl.status.sc = status;
	return update_sgroup;
@@ -3001,11 +2995,6 @@ exit:

		}
	}
	if (update_sgroup && ns->ptpl_activated) {
		if (nvmf_ns_update_reservation_info(ns)) {
			status = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
		}
	}
	req->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
	req->rsp->nvme_cpl.status.sc = status;
	return update_sgroup;
@@ -3108,11 +3097,6 @@ nvmf_ns_reservation_release(struct spdk_nvmf_ns *ns,
	}

exit:
	if (update_sgroup && ns->ptpl_activated) {
		if (nvmf_ns_update_reservation_info(ns)) {
			status = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
		}
	}
	req->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
	req->rsp->nvme_cpl.status.sc = status;
	return update_sgroup;
@@ -3244,6 +3228,11 @@ nvmf_ns_reservation_request(void *ctx)

	/* update reservation information to subsystem's poll group */
	if (update_sgroup) {
		if (ns->ptpl_activated || cmd->opc == SPDK_NVME_OPC_RESERVATION_REGISTER) {
			if (nvmf_ns_update_reservation_info(ns) != 0) {
				req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
			}
		}
		update_ctx = calloc(1, sizeof(*update_ctx));
		if (update_ctx == NULL) {
			SPDK_ERRLOG("Can't alloc subsystem poll group update context\n");
+10 −0
Original line number Diff line number Diff line
@@ -816,6 +816,8 @@ test_reservation_register_with_ptpl(void)
	SPDK_CU_ASSERT_FATAL(update_sgroup == true);
	SPDK_CU_ASSERT_FATAL(rsp->status.sc == SPDK_NVME_SC_SUCCESS);
	SPDK_CU_ASSERT_FATAL(g_ns.ptpl_activated == true);
	rc = nvmf_ns_update_reservation_info(&g_ns);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	reg = nvmf_ns_reservation_get_registrant(&g_ns, &g_ctrlr1_A.hostid);
	SPDK_CU_ASSERT_FATAL(reg != NULL);
	SPDK_CU_ASSERT_FATAL(!spdk_uuid_compare(&g_ctrlr1_A.hostid, &reg->hostid));
@@ -833,6 +835,8 @@ test_reservation_register_with_ptpl(void)
	SPDK_CU_ASSERT_FATAL(update_sgroup == true);
	SPDK_CU_ASSERT_FATAL(rsp->status.sc == SPDK_NVME_SC_SUCCESS);
	SPDK_CU_ASSERT_FATAL(g_ns.ptpl_activated == false);
	rc = nvmf_ns_update_reservation_info(&g_ns);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	rc = nvmf_ns_load_reservation(g_ns.ptpl_file, &info);
	SPDK_CU_ASSERT_FATAL(rc < 0);
	unlink(g_ns.ptpl_file);
@@ -937,6 +941,8 @@ test_reservation_acquire_release_with_ptpl(void)
	SPDK_CU_ASSERT_FATAL(update_sgroup == true);
	SPDK_CU_ASSERT_FATAL(rsp->status.sc == SPDK_NVME_SC_SUCCESS);
	SPDK_CU_ASSERT_FATAL(g_ns.ptpl_activated == true);
	rc = nvmf_ns_update_reservation_info(&g_ns);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	reg = nvmf_ns_reservation_get_registrant(&g_ns, &g_ctrlr1_A.hostid);
	SPDK_CU_ASSERT_FATAL(reg != NULL);
	SPDK_CU_ASSERT_FATAL(!spdk_uuid_compare(&g_ctrlr1_A.hostid, &reg->hostid));
@@ -953,6 +959,8 @@ test_reservation_acquire_release_with_ptpl(void)
	update_sgroup = nvmf_ns_reservation_acquire(&g_ns, &g_ctrlr1_A, req);
	SPDK_CU_ASSERT_FATAL(update_sgroup == true);
	SPDK_CU_ASSERT_FATAL(rsp->status.sc == SPDK_NVME_SC_SUCCESS);
	rc = nvmf_ns_update_reservation_info(&g_ns);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	memset(&info, 0, sizeof(info));
	rc = nvmf_ns_load_reservation(g_ns.ptpl_file, &info);
	SPDK_CU_ASSERT_FATAL(rc == 0);
@@ -969,6 +977,8 @@ test_reservation_acquire_release_with_ptpl(void)
	update_sgroup = nvmf_ns_reservation_release(&g_ns, &g_ctrlr1_A, req);
	SPDK_CU_ASSERT_FATAL(update_sgroup == true);
	SPDK_CU_ASSERT_FATAL(rsp->status.sc == SPDK_NVME_SC_SUCCESS);
	rc = nvmf_ns_update_reservation_info(&g_ns);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	memset(&info, 0, sizeof(info));
	rc = nvmf_ns_load_reservation(g_ns.ptpl_file, &info);
	SPDK_CU_ASSERT_FATAL(rc == 0);