Commit 0143ff6b authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Darek Stojaczyk
Browse files

bdev/nvme: Set per-controller prchk options by .INI config file



Add "prchk:reftag|guard" to the 3rd item of the TransportID row
in [Nvme] section.

apptag is not supported yet as same as JSON RPC.

These two patches cannot control hot added NVMe controllers, but
we should not set prchk options to hot added NVMe controllers
automatically. Hence the next patch will document this behavior
explicitly.

Change-Id: I74a73ac52779aa50c5b45e20ffb61002e95f33ef
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/443835


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 9562a5c7
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ struct nvme_probe_ctx {
	struct spdk_nvme_transport_id trids[NVME_MAX_CONTROLLERS];
	struct spdk_nvme_host_id hostids[NVME_MAX_CONTROLLERS];
	const char *names[NVME_MAX_CONTROLLERS];
	uint32_t prchk_flags[NVME_MAX_CONTROLLERS];
	const char *hostnqn;
};

@@ -1074,11 +1075,13 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
{
	struct nvme_probe_ctx *ctx = cb_ctx;
	char *name = NULL;
	uint32_t prchk_flags = 0;
	size_t i;

	if (ctx) {
		for (i = 0; i < ctx->count; i++) {
			if (spdk_nvme_transport_id_compare(trid, &ctx->trids[i]) == 0) {
				prchk_flags = ctx->prchk_flags[i];
				name = strdup(ctx->names[i]);
				break;
			}
@@ -1093,7 +1096,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,

	SPDK_DEBUGLOG(SPDK_LOG_BDEV_NVME, "Attached to %s (%s)\n", trid->traddr, name);

	create_ctrlr(ctrlr, name, trid, 0);
	create_ctrlr(ctrlr, name, trid, prchk_flags);

	free(name);
}
@@ -1428,6 +1431,17 @@ bdev_nvme_library_init(void)
		}

		probe_ctx->names[i] = val;

		val = spdk_conf_section_get_nmval(sp, "TransportID", i, 2);
		if (val != NULL) {
			rc = spdk_nvme_prchk_flags_parse(&probe_ctx->prchk_flags[i], val);
			if (rc < 0) {
				SPDK_ERRLOG("Unable to parse prchk: %s\n", val);
				rc = -1;
				goto end;
			}
		}

		probe_ctx->count++;

		if (probe_ctx->trids[i].trtype != SPDK_NVME_TRANSPORT_PCIE) {
@@ -1799,6 +1813,7 @@ bdev_nvme_get_spdk_running_config(FILE *fp)

	TAILQ_FOREACH(nvme_ctrlr, &g_nvme_ctrlrs, tailq) {
		const char *trtype;
		const char *prchk_flags;

		trtype = spdk_nvme_transport_id_trtype_str(nvme_ctrlr->trid.trtype);
		if (!trtype) {
@@ -1813,19 +1828,25 @@ bdev_nvme_get_spdk_running_config(FILE *fp)
			const char *adrfam;

			adrfam = spdk_nvme_transport_id_adrfam_str(nvme_ctrlr->trid.adrfam);
			prchk_flags = spdk_nvme_prchk_flags_str(nvme_ctrlr->prchk_flags);

			if (adrfam) {
				fprintf(fp, "TransportID \"trtype:%s adrfam:%s traddr:%s trsvcid:%s subnqn:%s\" %s\n",
				fprintf(fp, "TransportID \"trtype:%s adrfam:%s traddr:%s trsvcid:%s subnqn:%s\" %s",
					trtype,	adrfam,
					nvme_ctrlr->trid.traddr, nvme_ctrlr->trid.trsvcid,
					nvme_ctrlr->trid.subnqn, nvme_ctrlr->name);
			} else {
				fprintf(fp, "TransportID \"trtype:%s traddr:%s trsvcid:%s subnqn:%s\" %s\n",
				fprintf(fp, "TransportID \"trtype:%s traddr:%s trsvcid:%s subnqn:%s\" %s",
					trtype,
					nvme_ctrlr->trid.traddr, nvme_ctrlr->trid.trsvcid,
					nvme_ctrlr->trid.subnqn, nvme_ctrlr->name);
			}

			if (prchk_flags) {
				fprintf(fp, " \"%s\"\n", prchk_flags);
			} else {
				fprintf(fp, "\n");
			}
		}
	}