Commit 820e7c59 authored by Jim Harris's avatar Jim Harris Committed by Konrad Sztyber
Browse files

nvmf: refactor nvmf_tgt_destroy_cb



This preps for some upcoming patches as well as
removing two levels of indentation.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I4f685c1e44ec4aa261e68af1786cfc110f451ed5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17960


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 516639cf
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -360,29 +360,34 @@ static void
nvmf_tgt_destroy_cb(void *io_device)
{
	struct spdk_nvmf_tgt *tgt = io_device;
	struct spdk_nvmf_subsystem *subsystem;
	uint32_t i;
	int rc;

	if (tgt->subsystems) {
	if (tgt->subsystems == NULL) {
		_nvmf_tgt_destroy_next_transport(tgt);
		return;
	}

	for (i = 0; i < tgt->max_subsystems; i++) {
			if (tgt->subsystems[i]) {
				nvmf_subsystem_remove_all_listeners(tgt->subsystems[i], true);
		subsystem = tgt->subsystems[i];
		if (subsystem == NULL) {
			continue;
		}
		nvmf_subsystem_remove_all_listeners(subsystem, true);

				rc = spdk_nvmf_subsystem_destroy(tgt->subsystems[i], nvmf_tgt_destroy_cb, tgt);
		rc = spdk_nvmf_subsystem_destroy(subsystem, nvmf_tgt_destroy_cb, tgt);
		if (rc) {
			if (rc == -EINPROGRESS) {
				/* If rc is -EINPROGRESS, nvmf_tgt_destroy_cb will be called again when subsystem #i
				 * is destroyed, nvmf_tgt_destroy_cb will continue to destroy other subsystems if any */
				return;
			} else {
						SPDK_ERRLOG("Failed to destroy subsystem %s, rc %d\n", tgt->subsystems[i]->subnqn, rc);
					}
				SPDK_ERRLOG("Failed to destroy subsystem %s, rc %d\n", subsystem->subnqn, rc);
			}
		}
	}
	free(tgt->subsystems);
	}

	_nvmf_tgt_destroy_next_transport(tgt);
}