Commit e5b62c12 authored by Cunyin Chang's avatar Cunyin Chang Committed by Daniel Verkamp
Browse files

bdev/nvme: assign names to hot-inserted devices.



this patch fix the potential possibility of coredump when
we have NVMe device hot inserted.

Change-Id: Idac255f25f42b4746c2d3ae6dfc57a19b7001160
Signed-off-by: default avatarCunyin Chang <cunyin.chang@intel.com>
parent 0488fd84
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ struct nvme_probe_ctx {
	const char *names[NVME_MAX_CONTROLLERS];
};

static int g_hot_insert_nvme_controller_index = 0;
static int g_reset_controller_on_timeout = 0;
static int g_timeout = 0;
static int g_nvme_adminq_poll_timeout_us = 0;
@@ -580,13 +581,16 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
	const char *name = NULL;
	size_t i;

	if (ctx) {
		for (i = 0; i < ctx->count; i++) {
			if (spdk_nvme_transport_id_compare(trid, &ctx->trids[i]) == 0) {
				name = strdup(ctx->names[i]);
				break;
			}
		}

	} else {
		name = spdk_sprintf_alloc("HotInsertNvme%d", g_hot_insert_nvme_controller_index);
	}
	if (!name) {
		SPDK_ERRLOG("Failed to assign name to NVMe device\n");
		return;