Commit edb03a18 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/nvme: Simplify the code flow to handle multipath in bdev_nvme_attach_controller



This clean up makes the following patches a little easier.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I0415de9b99567b4de1ad7b35298ea51a664d4a32
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12049


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 36e81f15
Loading
Loading
Loading
Loading
+18 −20
Original line number Diff line number Diff line
@@ -444,9 +444,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
			}
		}

		drv_opts = spdk_nvme_ctrlr_get_opts(ctrlr->ctrlr);
		ctrlr_trid = spdk_nvme_ctrlr_get_transport_id(ctrlr->ctrlr);

		/* This controller already exists. Check what the user wants to do. */
		if (strcasecmp(ctx->req.multipath, "disable") == 0) {
			/* The user does not want to do any form of multipathing. */
@@ -454,9 +451,19 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
							     "A controller named %s already exists and multipath is disabled\n",
							     ctx->req.name);
			goto cleanup;
		} else if (strcasecmp(ctx->req.multipath, "failover") == 0 ||
			   strcasecmp(ctx->req.multipath, "multipath") == 0) {

		} else if (strcasecmp(ctx->req.multipath, "failover") != 0 &&
			   strcasecmp(ctx->req.multipath, "multipath") != 0) {
			/* Invalid multipath option */
			spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,
							     "Invalid multipath parameter: %s\n",
							     ctx->req.multipath);
			goto cleanup;
		}

		/* The user wants to add this as a failover path or add this to create multipath. */
		drv_opts = spdk_nvme_ctrlr_get_opts(ctrlr->ctrlr);
		ctrlr_trid = spdk_nvme_ctrlr_get_transport_id(ctrlr->ctrlr);

		if (strncmp(trid.traddr, ctrlr_trid->traddr, sizeof(trid.traddr)) == 0 &&
		    strncmp(trid.trsvcid, ctrlr_trid->trsvcid, sizeof(trid.trsvcid)) == 0 &&
@@ -468,13 +475,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
							     ctx->req.name);
			goto cleanup;
		}
		} else {
			/* Invalid multipath option */
			spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,
							     "Invalid multipath parameter: %s\n",
							     ctx->req.multipath);
			goto cleanup;
		}

		if (strncmp(trid.subnqn,
			    ctrlr_trid->subnqn,
@@ -486,8 +486,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
			goto cleanup;
		}



		if (strncmp(ctx->req.drv_opts.hostnqn, drv_opts->hostnqn, SPDK_NVMF_NQN_MAX_LEN) != 0) {
			/* Different HOSTNQN is not allowed when specifying the same controller name. */
			spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,