Commit ab3abc15 authored by Ben Walker's avatar Ben Walker Committed by Changpeng Liu
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459753


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
parent 75b4f332
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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) {