Commit 5bbe0c0b authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

nvmf: change reservation functions to use ns instead of ptpl_file



Suggested-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: Ifc66055c001d7fcde42a0520536906137ca53b19
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21488


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 87e4df14
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -1700,7 +1700,8 @@ static struct spdk_bdev_module ns_bdev_module = {
	.name	= "NVMe-oF Target",
};

static int nvmf_ns_load_reservation(const char *file, struct spdk_nvmf_reservation_info *info);
static int nvmf_ns_load_reservation(const struct spdk_nvmf_ns *ns,
				    struct spdk_nvmf_reservation_info *info);
static int nvmf_ns_reservation_restore(struct spdk_nvmf_ns *ns,
				       struct spdk_nvmf_reservation_info *info);

@@ -1852,7 +1853,7 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
			goto err;
		}

		rc = nvmf_ns_load_reservation(ptpl_file, &info);
		rc = nvmf_ns_load_reservation(ns, &info);
		if (!rc) {
			rc = nvmf_ns_reservation_restore(ns, &info);
			if (rc) {
@@ -2214,7 +2215,7 @@ static const struct spdk_json_object_decoder nvmf_ns_pr_decoders[] = {
};

static int
nvmf_ns_load_reservation(const char *file, struct spdk_nvmf_reservation_info *info)
nvmf_ns_load_reservation(const struct spdk_nvmf_ns *ns, struct spdk_nvmf_reservation_info *info)
{
	FILE *fd;
	size_t json_size;
@@ -2222,6 +2223,7 @@ nvmf_ns_load_reservation(const char *file, struct spdk_nvmf_reservation_info *in
	void *json = NULL, *end;
	struct spdk_json_val *values = NULL;
	struct _nvmf_ns_reservation res = {};
	const char *file = ns->ptpl_file;
	uint32_t i;

	fd = fopen(file, "r");
@@ -2385,8 +2387,10 @@ nvmf_ns_json_write_cb(void *cb_ctx, const void *data, size_t size)
}

static int
nvmf_ns_reservation_update(const char *file, struct spdk_nvmf_reservation_info *info)
nvmf_ns_reservation_update(const struct spdk_nvmf_ns *ns,
			   const struct spdk_nvmf_reservation_info *info)
{
	const char *file = ns->ptpl_file;
	struct spdk_json_write_ctx *w;
	uint32_t i;
	int rc = 0;
@@ -2456,7 +2460,7 @@ nvmf_ns_update_reservation_info(struct spdk_nvmf_ns *ns)
	info.num_regs = i;
	info.ptpl_activated = ns->ptpl_activated;

	return nvmf_ns_reservation_update(ns->ptpl_file, &info);
	return nvmf_ns_reservation_update(ns, &info);
}

static struct spdk_nvmf_registrant *
+5 −5
Original line number Diff line number Diff line
@@ -823,7 +823,7 @@ test_reservation_register_with_ptpl(void)
	SPDK_CU_ASSERT_FATAL(!spdk_uuid_compare(&g_ctrlr1_A.hostid, &reg->hostid));
	/* Load reservation information from configuration file */
	memset(&info, 0, sizeof(info));
	rc = nvmf_ns_load_reservation(g_ns.ptpl_file, &info);
	rc = nvmf_ns_load_reservation(&g_ns, &info);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	SPDK_CU_ASSERT_FATAL(info.ptpl_activated == true);

@@ -837,7 +837,7 @@ test_reservation_register_with_ptpl(void)
	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);
	rc = nvmf_ns_load_reservation(&g_ns, &info);
	SPDK_CU_ASSERT_FATAL(rc < 0);
	unlink(g_ns.ptpl_file);

@@ -948,7 +948,7 @@ test_reservation_acquire_release_with_ptpl(void)
	SPDK_CU_ASSERT_FATAL(!spdk_uuid_compare(&g_ctrlr1_A.hostid, &reg->hostid));
	/* Load reservation information from configuration file */
	memset(&info, 0, sizeof(info));
	rc = nvmf_ns_load_reservation(g_ns.ptpl_file, &info);
	rc = nvmf_ns_load_reservation(&g_ns, &info);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	SPDK_CU_ASSERT_FATAL(info.ptpl_activated == true);

@@ -962,7 +962,7 @@ test_reservation_acquire_release_with_ptpl(void)
	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);
	rc = nvmf_ns_load_reservation(&g_ns, &info);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	SPDK_CU_ASSERT_FATAL(info.ptpl_activated == true);
	SPDK_CU_ASSERT_FATAL(info.rtype == SPDK_NVME_RESERVE_WRITE_EXCLUSIVE_REG_ONLY);
@@ -980,7 +980,7 @@ test_reservation_acquire_release_with_ptpl(void)
	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);
	rc = nvmf_ns_load_reservation(&g_ns, &info);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	SPDK_CU_ASSERT_FATAL(info.rtype == 0);
	SPDK_CU_ASSERT_FATAL(info.crkey == 0);