From f4f3bef1cce3438a4d9e655d4d5b49f4a17c90b0 Mon Sep 17 00:00:00 2001 From: cunyinch Date: Sat, 27 May 2017 07:41:41 +0800 Subject: [PATCH] nvmf: make sure nvmf target workable when it run as secondary porcess. This patch do the following optimization: 1 when the nvmf target run as secondary process, the nvme probe will not call the probe callback function, which will skip the step to set up the ctx->found, so we set up it when we call attach callback. 2 when the nvmf target run as secondary process, every time when we try to probe one device, it will iterate all the attached devices and call the attach callback, for nvmf target, it will cause the overwrite of the nvme controller for the nvmf subsystem, so we need to compare the attached deivce with the device which we try to attach, if they are not the same one, just return. Change-Id: I606ba75b1dab7fd1b1e4e1cfcf63248a506725d1 Signed-off-by: cunyinch Reviewed-on: https://review.gerrithub.io/362807 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- app/nvmf_tgt/conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/nvmf_tgt/conf.c b/app/nvmf_tgt/conf.c index 42534f6a3..d24804304 100644 --- a/app/nvmf_tgt/conf.c +++ b/app/nvmf_tgt/conf.c @@ -257,7 +257,10 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, struct spdk_pci_device *pci_dev; spdk_pci_addr_parse(&pci_addr, trid->traddr); - + if (ctx->trid.traddr[0] != '\0' && strcmp(trid->traddr, ctx->trid.traddr)) { + SPDK_WARNLOG("Attached device is not expected\n"); + return; + } SPDK_NOTICELOG("Attaching NVMe device %p at %s to subsystem %s\n", ctrlr, trid->traddr, @@ -285,6 +288,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, if (rc < 0) { SPDK_ERRLOG("Failed to add controller to subsystem\n"); } + ctx->found = true; } static int