From 5e54cc4dba5fe2ffa12bf9cb2a2d9efa99d26b4d Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 26 Aug 2016 09:28:15 -0700 Subject: [PATCH] nvmf: enable dataset management based on unmap support Rather than comparing the bdev name against "NVMe", use the new I/O type supported API to query whether the unmap operation is supported. Change-Id: I62c7a1ea5529366ff2ae4723b62f24ea78aa8193 Signed-off-by: Daniel Verkamp --- lib/nvmf/virtual.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/nvmf/virtual.c b/lib/nvmf/virtual.c index b72e88a377..9b89078d33 100644 --- a/lib/nvmf/virtual.c +++ b/lib/nvmf/virtual.c @@ -63,16 +63,19 @@ static void nvmf_virtual_set_dsm(struct spdk_nvmf_subsystem *subsys) int i; for (i = 0; i < subsys->ctrlr.dev.virtual.ns_count; i++) { - if (!strncasecmp(subsys->ctrlr.dev.virtual.ns_list[i]->name, "Nvme", 4)) { - continue; - } else { - break; + struct spdk_bdev *bdev = subsys->ctrlr.dev.virtual.ns_list[i]; + + if (!spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP)) { + SPDK_TRACELOG(SPDK_TRACE_NVMF, + "Subsystem%d Namespace %s does not support unmap - not enabling DSM\n", + i, bdev->name); + return; } } - if (i == subsys->ctrlr.dev.virtual.ns_count) { - subsys->session->vcdata.oncs.dsm = 1; - } + SPDK_TRACELOG(SPDK_TRACE_NVMF, "All devices in Subsystem%d support unmap - enabling DSM\n", + subsys->num); + subsys->session->vcdata.oncs.dsm = 1; } static void