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

nvmf: set ns->ptpl_file before nvmf_ns_load_reservation()



The following patches will change nvmf_ns_load_reservation() to use ns
instead of passing the ptpl_file directly, so it needs to be assigned
earlier.

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


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent d0fe26b2
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -1831,7 +1831,7 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
		    (subsystem->zone_append_supported != zone_append_supported ||
		     subsystem->max_zone_append_size_kib != max_zone_append_size_kib)) {
			SPDK_ERRLOG("Namespaces with different zone append support or different zone append size are not allowed.\n");
			goto err_ns_reservation_restore;
			goto err;
		}

		subsystem->zone_append_supported = zone_append_supported;
@@ -1846,18 +1846,19 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
	subsystem->ana_group[ns->anagrpid - 1]++;
	TAILQ_INIT(&ns->registrants);
	if (ptpl_file) {
		ns->ptpl_file = strdup(ptpl_file);
		if (!ns->ptpl_file) {
			SPDK_ERRLOG("Namespace ns->ptpl_file allocation failed\n");
			goto err;
		}

		rc = nvmf_ns_load_reservation(ptpl_file, &info);
		if (!rc) {
			rc = nvmf_ns_reservation_restore(ns, &info);
			if (rc) {
				SPDK_ERRLOG("Subsystem restore reservation failed\n");
				goto err_ns_reservation_restore;
			}
				goto err;
			}
		ns->ptpl_file = strdup(ptpl_file);
		if (!ns->ptpl_file) {
			SPDK_ERRLOG("Namespace ns->ptpl_file allocation failed\n");
			goto err_strdup;
		}
	}

@@ -1867,7 +1868,8 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
			rc = transport->ops->subsystem_add_ns(transport, subsystem, ns);
			if (rc) {
				SPDK_ERRLOG("Namespace attachment is not allowed by %s transport\n", transport->ops->name);
				goto err_subsystem_add_ns;
				nvmf_ns_reservation_clear_all_registrants(ns);
				goto err;
			}
		}
	}
@@ -1882,15 +1884,11 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
	SPDK_DTRACE_PROBE2(nvmf_subsystem_add_ns, subsystem->subnqn, ns->nsid);

	return opts.nsid;

err_subsystem_add_ns:
	free(ns->ptpl_file);
err_strdup:
	nvmf_ns_reservation_clear_all_registrants(ns);
err_ns_reservation_restore:
err:
	subsystem->ns[opts.nsid - 1] = NULL;
	spdk_bdev_module_release_bdev(ns->bdev);
	spdk_bdev_close(ns->desc);
	free(ns->ptpl_file);
	free(ns);

	return 0;