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

bdev/nvme: attach_controller RPC returns callback rc as error code



Previously, if the bdev_nvme_attach_controller RPC fails after
bdev_nvme_create() is called, SPDK_JSONRPC_ERROR_INVALID_PARAMS was
returned as error code.

However, this was not good because error code was not consistent for
error due to path duplication. If path was duplicated with the
current active path, -EALREADY was returned. However, if path was
duplicated with any secondary path, SPDK_JSONRPC_ERROR_INVALID_PARAMS
was returned.

To fix this incosistency, we take two steps.

As the first step, in this patch, we change to return callback rc
instead of SPDK_JSONRPC_ERROR_INVALID_PARAMS as error code if the RPC
fails after bdev_nvme_create() is called.

This will be reasonable because if the bdev_nvme_attach_controller
RPC fails before bdev_nvme_create() is called, OS error code has been
used for all cases but decode error.

As the second step, the next patch will change the callback rc for one
case to fix a github issue.

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

 (master)

(cherry picked from commit fe0d81ba)
Change-Id: I49816009d420e9ef23cc683385d78e616a87d4a6
Signed-off-by: default avatarMarek Chomnicki <marek.chomnicki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23278


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent f7b2ff7a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ rpc_bdev_nvme_attach_controller_done(void *cb_ctx, size_t bdev_count, int rc)
	struct spdk_jsonrpc_request *request = ctx->request;

	if (rc < 0) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		free_rpc_bdev_nvme_attach_controller_ctx(ctx);
		return;
	}