From ab3abc15aa4a06f16a20212751e4a16d0c2b4da1 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Fri, 28 Jun 2019 01:50:02 -0700 Subject: [PATCH] nvmf: Capture channel variable to stack when updating poll groups This signals to the compiler and analysis programs that this won't change during iteration, so it may produce better code. Change-Id: I478c0c9445d4ddf8a69ab1b3deaf628b82a0eaea Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459753 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Seth Howell --- lib/nvmf/nvmf.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 72e94ffa3..32c3dbd70 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -869,6 +869,7 @@ poll_group_update_subsystem(struct spdk_nvmf_poll_group *group, uint32_t i, j; struct spdk_nvmf_ns *ns; struct spdk_nvmf_registrant *reg, *tmp; + struct spdk_io_channel *ch; /* Make sure our poll group has memory for this subsystem allocated */ if (subsystem->id >= group->num_sgroups) { @@ -933,13 +934,15 @@ poll_group_update_subsystem(struct spdk_nvmf_poll_group *group, /* Detect bdevs that were added or removed */ for (i = 0; i < sgroup->num_ns; i++) { ns = subsystem->ns[i]; - if (ns == NULL && sgroup->ns_info[i].channel == NULL) { + ch = sgroup->ns_info[i].channel; + + if (ns == NULL && ch == NULL) { /* Both NULL. Leave empty */ - } else if (ns == NULL && sgroup->ns_info[i].channel != NULL) { + } else if (ns == NULL && ch != NULL) { /* There was a channel here, but the namespace is gone. */ - spdk_put_io_channel(sgroup->ns_info[i].channel); + spdk_put_io_channel(ch); sgroup->ns_info[i].channel = NULL; - } else if (ns != NULL && sgroup->ns_info[i].channel == NULL) { + } else if (ns != NULL && ch == NULL) { /* A namespace appeared but there is no channel yet */ sgroup->ns_info[i].channel = spdk_bdev_get_io_channel(ns->desc); if (sgroup->ns_info[i].channel == NULL) {