nvmf: update discovery log when removing hostnqn

In NVMF Revision spec 1.1a, discovery log should be updated
when removing hostnqn of subsystem.

Update unit test to check the discovery log when removing
hostnqn and destroying subsystem.

Signed-off-by: Peng Lian <peng.lian@smartx.com>
Change-Id: I51c597a2493295a677a7aa68e4f13a887f7e1140
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10668
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Peng Lian 2021-12-14 07:04:58 -05:00 committed by Tomasz Zawadzki
parent 17a662f9fe
commit 4c1757ffb9
2 changed files with 28 additions and 0 deletions

View File

@ -860,6 +860,11 @@ spdk_nvmf_subsystem_remove_host(struct spdk_nvmf_subsystem *subsystem, const cha
}
nvmf_subsystem_remove_host(subsystem, host);
if (!TAILQ_EMPTY(&subsystem->listeners)) {
nvmf_update_discovery_log(subsystem->tgt, hostnqn);
}
pthread_mutex_unlock(&subsystem->mutex);
return 0;

View File

@ -370,9 +370,32 @@ test_discovery_log(void)
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1,
offsetof(struct spdk_nvmf_discovery_log_page, entries[0]), sizeof(*entry), &trid);
CU_ASSERT(entry->trtype == 42);
/* remove the host and verify that the discovery log contains nothing */
rc = spdk_nvmf_subsystem_remove_host(subsystem, hostnqn);
CU_ASSERT(rc == 0);
/* Get only the header, no entries */
memset(buffer, 0xCC, sizeof(buffer));
disc_log = (struct spdk_nvmf_discovery_log_page *)buffer;
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, sizeof(*disc_log),
&trid);
CU_ASSERT(disc_log->genctr != 0);
CU_ASSERT(disc_log->numrec == 0);
/* destroy the subsystem and verify that the discovery log contains nothing */
subsystem->state = SPDK_NVMF_SUBSYSTEM_INACTIVE;
rc = spdk_nvmf_subsystem_destroy(subsystem, NULL, NULL);
CU_ASSERT(rc == 0);
/* Get only the header, no entries */
memset(buffer, 0xCC, sizeof(buffer));
disc_log = (struct spdk_nvmf_discovery_log_page *)buffer;
nvmf_get_discovery_log_page(&tgt, hostnqn, &iov, 1, 0, sizeof(*disc_log),
&trid);
CU_ASSERT(disc_log->genctr != 0);
CU_ASSERT(disc_log->numrec == 0);
free(tgt.subsystems);
}