bdev/nvme: Reverse order of checks in bdev_nvme_attach_controllers

Do simple validity checks first, then check for duplicate controllers.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: Ic21d64574b37a3d9148e5cd6d5a7599449ea8fe1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9341
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: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
This commit is contained in:
Ben Walker 2021-08-30 13:41:16 -07:00 committed by Tomasz Zawadzki
parent ae2ea64740
commit bb555ef1b0

View File

@ -308,8 +308,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
rc = spdk_nvme_transport_id_parse_trtype(&trid.trtype, ctx->req.trtype);
assert(rc == 0);
ctrlr = nvme_ctrlr_get_by_name(ctx->req.name);
/* Parse traddr */
maxlen = sizeof(trid.traddr);
len = strnlen(ctx->req.traddr, maxlen);
@ -360,11 +358,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
memcpy(trid.subnqn, ctx->req.subnqn, len + 1);
}
if (ctrlr && (ctx->req.hostaddr || ctx->req.hostnqn || ctx->req.hostsvcid || ctx->req.prchk_guard ||
ctx->req.prchk_reftag)) {
goto conflicting_arguments;
}
if (ctx->req.hostnqn) {
snprintf(ctx->req.opts.hostnqn, sizeof(ctx->req.opts.hostnqn), "%s",
ctx->req.hostnqn);
@ -392,6 +385,13 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
memcpy(hostid.hostsvcid, ctx->req.hostsvcid, len + 1);
}
ctrlr = nvme_ctrlr_get_by_name(ctx->req.name);
if (ctrlr && (ctx->req.hostaddr || ctx->req.hostnqn || ctx->req.hostsvcid || ctx->req.prchk_guard ||
ctx->req.prchk_reftag)) {
goto conflicting_arguments;
}
if (ctx->req.prchk_reftag) {
prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
}